Skip to content

Comments

egressgw: Let the EGW manager relax rp_filter on egress device#7

Open
MitchLewis930 wants to merge 1 commit intopr_047_beforefrom
pr_047_after
Open

egressgw: Let the EGW manager relax rp_filter on egress device#7
MitchLewis930 wants to merge 1 commit intopr_047_beforefrom
pr_047_after

Conversation

@MitchLewis930
Copy link

PR_047

Pods running on the Egress GW node fail to communicate with an external
endpoint through the Egress GW due to the rp_filter in an environment
where egress IP is assigned to a different interface than the one with
the default route. The reply packets from the external endpoints are
dropped by the rp_filter

- A request from a local pod hits eth0 with the default route.
  It matches an IEGP, gets masqueraded & bpf-redirected to eth1 with Egress IP.
- Replies hit eth1, are revSNATed, and passed on to the stack.
  rp-filter complains that they are received on eth1, when the route doesn't point towards eth1.

This PR fixes this issue by relaxing rp_filter on interfaces with Egress IP.

Signed-off-by: Yusuke Suzuki <yusuke.suzuki@isovalent.com>
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 01:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements automatic relaxation of rp_filter settings on egress gateway interfaces to ensure proper packet routing for SNAT traffic.

Changes:

  • Extended gatewayConfig to track interface names and whether the local node acts as an egress gateway
  • Modified the manager to automatically set rp_filter=2 on egress interfaces when the node is configured as a gateway
  • Refactored TestForIfaceWithIPv4Address to return the interface name instead of just testing for existence

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/egressgateway/policy.go Added interface name tracking and local gateway flag to gatewayConfig
pkg/egressgateway/manager.go Implemented relaxRPFilter method to apply sysctl settings during reconciliation
pkg/datapath/linux/netdevice/netdevice.go Refactored to expose interface name retrieval alongside existence check
pkg/egressgateway/manager_privileged_test.go Added test coverage for rp_filter settings and helper functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +141 to +142
gwc.localNodeConfiguredAsGateway = false

Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting localNodeConfiguredAsGateway to false at the start of deriveFromPolicyGatewayConfig and then unconditionally setting it to true at line 175 means it will always be true when the function succeeds. This initialization appears unnecessary since the value is always overwritten before return. Consider removing the initial false assignment or documenting why this pattern is needed.

Suggested change
gwc.localNodeConfiguredAsGateway = false

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants