[SRU][J][PATCH 6/6] selftests: net: disable rp_filter after namespace initialization

Ian Whitfield ian.whitfield at canonical.com
Thu Oct 1 20:39:48 UTC 2026


From: Hangbin Liu <liuhangbin at gmail.com>

BugLink: https://bugs.launchpad.net/bugs/2055473

Some distributions enable rp_filter globally by default. To ensure consistent
behavior across environments, we explicitly disable it in several test cases.

This patch moves the rp_filter disabling logic to immediately after the
network namespace is initialized. With this change, individual test cases
with creating namespace via setup_ns no longer need to disable rp_filter
again.

This helps avoid redundancy and ensures test consistency.

Signed-off-by: Hangbin Liu <liuhangbin at gmail.com>
Reviewed-by: Simon Horman <horms at kernel.org>
Link: https://patch.msgid.link/20250508081910.84216-2-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba at kernel.org>
(backported from commit ce17831f8e970cadaba88605b4b1b1a8b2b50808)
[ijwhitfield: Adjusted context due to missing unrelated functions from:
4d0dac499bf38 ("selftests/net: test tcp connection load balancing")
b219bcfcc92e9 ("selftests: net: lib: Move logging from forwarding/lib.sh here")
601d9d70a40a8 ("selftests: net: lib: Move tests_run from forwarding/lib.sh here")
56c8a23f8a0f3 ("selftests: net: use netdevsim in netns test")
There was also previously a partial backport of
ea63ac1429256 ("selftests/net: use tc rule to filter the na packet")
in our backport of
d83a580675927 ("selftests: net: use slowwait to stabilize vrf_route_leaking test")
which led to similar context adjustment due to missing unrelated functions.
There are also three missing small fixes/changes in the affected function:
f8a2d2f874b71 ("selftests: net: lib: remove 'ns' var in setup_ns")
92fe5670271a5 ("selftests: net: lib: remove ns from list after clean-up")]
79322174bcc78 ("selftests: net: lib: avoid error removing empty netns name")
which required adjusting context of the patch.]
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
 tools/testing/selftests/net/lib.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index 7c5a267517be6..9c26297dffbeb 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -103,6 +103,8 @@ setup_ns()
 			return $ksft_skip
 		fi
 		ip -n "$ns" link set lo up
+		ip netns exec "${!ns_name}" sysctl -wq net.ipv4.conf.all.rp_filter=0
+		ip netns exec "${!ns_name}" sysctl -wq net.ipv4.conf.default.rp_filter=0
 		ns_list="$ns_list $ns"
 	done
 	NS_LIST="$NS_LIST $ns_list"
-- 
2.43.0




More information about the kernel-team mailing list