Skip to content

Commit e3c0f3b

Browse files
committed
feat(NSC): ensure rp_filter is set correctly
rp_filter on RedHat based OS's is often set to 1 instead of 2 which is more permissive and allows the outbound route for traffic to differ from the route of incoming traffic.
1 parent 1f0a2cf commit e3c0f3b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/controllers/proxy/network_services_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,20 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
289289
// https://github.com/kubernetes/kubernetes/pull/70530/files
290290
setSysCtlAndCheckError(utils.IPv4ConfAllArpAnnounce, arpAnnounceUseBestLocalAddress)
291291

292+
// Ensure rp_filter=2 for DSR capability, see:
293+
// * https://access.redhat.com/solutions/53031
294+
// * https://github.com/cloudnativelabs/kube-router/pull/1651#issuecomment-2072851683
295+
if nsc.isIPv4Capable {
296+
sysctlErr := utils.SetSysctlSingleTemplate(utils.IPv4ConfRPFilterTemplate, "all", 2)
297+
if sysctlErr != nil {
298+
if sysctlErr.IsFatal() {
299+
klog.Fatal(sysctlErr.Error())
300+
} else {
301+
klog.Error(sysctlErr.Error())
302+
}
303+
}
304+
}
305+
292306
// https://github.com/cloudnativelabs/kube-router/issues/282
293307
err = nsc.setupIpvsFirewall()
294308
if err != nil {

0 commit comments

Comments
 (0)