selftests: fib_rule_tests: enable forwarding before ipv4 from/iif test
authorHangbin Liu <liuhangbin@gmail.com>
Mon, 20 May 2019 04:36:55 +0000 (12:36 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 May 2019 00:20:20 +0000 (20:20 -0400)
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 <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/fib_rule_tests.sh

index 1ba069967fa2b653f905167b5d9fb9282e263f66..617321d3b8013b010200fcd0863e1654d8666bcc 100755 (executable)
@@ -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"