egressgw: Let the EGW manager relax rp_filter on egress device#7
egressgw: Let the EGW manager relax rp_filter on egress device#7MitchLewis930 wants to merge 1 commit intopr_047_beforefrom
Conversation
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>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||
User description
PR_047
PR Type
Enhancement, Bug fix
Description
Relax rp_filter on egress interfaces to fix reply packet drops
Add interface name tracking to gateway configuration
Refactor netdevice functions to return interface names
Add comprehensive rp_filter testing and validation
Diagram Walkthrough
File Walkthrough
netdevice.go
Refactor netdevice functions to return interface namespkg/datapath/linux/netdevice/netdevice.go
TestForIfaceWithIPv4Addressto extract privategetIfaceWithIPv4AddressfunctionGetIfaceWithIPv4Addressfunction that returns interfacename instead of just error
variants
manager.go
Add rp_filter relaxation to egress gateway managerpkg/egressgateway/manager.go
sysctlfield to Manager struct for system control operationssysctl.Sysctldependency through Params structrelaxRPFilter()method to set rp_filter to 2 on egressinterfaces
relaxRPFilter()call into reconciliation flow after gatewayconfig regeneration
policy.go
Track interface name and gateway configuration statuspkg/egressgateway/policy.go
ifaceNamefield togatewayConfigstruct to track interface namelocalNodeConfiguredAsGatewayboolean flag to indicate local nodegateway role
deriveFromPolicyGatewayConfigto populate interface name inall code paths
TestForIfaceWithIPv4AddresstoGetIfaceWithIPv4Addresstocapture interface name
manager_privileged_test.go
Add rp_filter validation and testing infrastructurepkg/egressgateway/manager_privileged_test.go
rpFilterSettingstruct to represent rp_filter test assertionssysctl.Sysctldependency into test suite and helper functionsensureRPFilterIsEnabledto verify rp_filter is set to 1 ontest interfaces
assertRPFilterandtryAssertRPFilterSettingsfunctions tovalidate rp_filter values
createTestInterfaceto initialize rp_filter on test interfaces