Skip to contentSkip to conversation

kselftests: fib_rule_tests: fix "from $SRC_IP iif $DEV" match testing

PATCH In review Hangbin Liu 3 participants 5 messages May 20, 2019 – May 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover kselftests: fib_rule_tests: fix "from $SRC_IP iif $DEV" match testing

As all the IPv4 testing addresses are in the same subnet and egress device == ingress device, to pass "from $SRC_IP iif $DEV" match test, we need enable forwarding to get the route entry.

Hangbin Liu (2):
selftests: fib_rule_tests: fix local IPv4 address typo
selftests: fib_rule_tests: enable forwarding before ipv4 from/iif test

 tools/testing/selftests/net/fib_rule_tests.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.2
#1 lore raw

PATCH 1/2 selftests: fib_rule_tests: fix local IPv4 address typo

The IPv4 testing address are all in 192.51.100.0 subnet. It doesn't make sense to set a 198.51.100.1 local address. Should be a typo.

Fixes 65b2b4939a64 ("selftests: net: initial fib rule tests")
---
 tools/testing/selftests/net/fib_rule_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/fib_rule_tests.sh +1 -1
index 4b7e107865bf..1ba069967fa2 100755
@@ -55,7 +55,7 @@ setup()
 
 	$IP link add dummy0 type dummy
 	$IP link set dev dummy0 up
-	$IP address add 198.51.100.1/24 dev dummy0
+	$IP address add 192.51.100.1/24 dev dummy0
 	$IP -6 address add 2001:db8:1::1/64 dev dummy0
 
 	set +e
Signature · 1 line
2.19.2
#3 lore raw

PATCH 2/2 selftests: fib_rule_tests: enable forwarding before ipv4 from/iif test

In reply to Hangbin Liu

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")
---
 tools/testing/selftests/net/fib_rule_tests.sh | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/net/fib_rule_tests.sh +5 -0
index 1ba069967fa2..617321d3b801 100755
@@ -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"
Signature · 1 line
2.19.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH net 1/2] selftests: fib_rule_tests: fix local IPv4 address typo

In reply to Hangbin Liu
Quoted 2 lines · Hangbin Liu

The IPv4 testing address are all in 192.51.100.0 subnet. It doesn't make sense to set a 198.51.100.1 local address. Should be a typo.

The unused DEV_ADDR suggests you are correct. That should be removed as well or the IPv6 address encoded and used for consistency.

Quoted 13 lines
Fixes 65b2b4939a64 ("selftests: net: initial fib rule tests")
---
 tools/testing/selftests/net/fib_rule_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/fib_rule_tests.sh +0 -0
index 4b7e107865bf..1ba069967fa2 100755

tools/testing/selftests/net/fib_rule_tests.sh setup() · line 61

Quoted 8 lines
tools/testing/selftests/net/fib_rule_tests.sh +1 -1
@@ -55,7 +55,7 @@ setup()
 
 	$IP link add dummy0 type dummy
 	$IP link set dev dummy0 up
-	$IP address add 198.51.100.1/24 dev dummy0
+	$IP address add 192.51.100.1/24 dev dummy0
 	$IP -6 address add 2001:db8:1::1/64 dev dummy0
 
 	set +e
maintainer
#4 lore raw
In reply to Hangbin Liu

From: Hangbin Liu <[email protected]>
Date: Mon, 20 May 2019 12:36:53 +0800

Quoted 3 lines

As all the IPv4 testing addresses are in the same subnet and egress device == ingress device, to pass "from $SRC_IP iif $DEV" match test, we need enable forwarding to get the route entry.

Series applied, thanks.