As all the testing addresses are in the same subnet and egress device ==
ingress device. We need enable forwarding to get the route entry.

Also disable rp_filer separately as some distributions enable it in
startup scripts.

Fixes: 65b2b4939a64 ("selftests: net: initial fib rule tests")
Signed-off-by: Hangbin Liu <[email protected]>
---
 tools/testing/selftests/net/fib_rule_tests.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/fib_rule_tests.sh 
b/tools/testing/selftests/net/fib_rule_tests.sh
index 1ba069967fa2..617321d3b801 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -186,8 +186,13 @@ fib_rule4_test()
        match="oif $DEV"
        fib_rule4_test_match_n_redirect "$match" "$match" "oif redirect to 
table"
 
+       # need enable forwarding and disable rp_filter temporarily as all the
+       # addresses are in the same subnet and egress device == ingress device.
+       ip netns exec testns sysctl -w net.ipv4.ip_forward=1
+       ip netns exec testns sysctl -w net.ipv4.conf.$DEV.rp_filter=0
        match="from $SRC_IP iif $DEV"
        fib_rule4_test_match_n_redirect "$match" "$match" "iif redirect to 
table"
+       ip netns exec testns sysctl -w net.ipv4.ip_forward=0
 
        match="tos 0x10"
        fib_rule4_test_match_n_redirect "$match" "$match" "tos redirect to 
table"
-- 
2.19.2

Reply via email to