Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: convert arp_ndisc_untracked_subnets.sh to run it in unique namespace

Here is the test result after conversion.

2 tests also failed without this patch

]# ./arp_ndisc_untracked_subnets.sh
TEST: test_arp: accept_arp=0 [ OK ]
TEST: test_arp: accept_arp=1 [ OK ]
TEST: test_arp: accept_arp=2 same_subnet=0 [ OK ]
TEST: test_arp: accept_arp=2 same_subnet=1 [ OK ]
TEST: test_ndisc: accept_untracked_na=0 [ OK ]
TEST: test_ndisc: accept_untracked_na=1 [ OK ]
TEST: test_ndisc: accept_untracked_na=2 same_subnet=0 [ OK ]
TEST: test_ndisc: accept_untracked_na=2 same_subnet=1 [ OK ]

Acked-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Hangbin Liu and committed by
Paolo Abeni
3a0f3367 7f770d28

+6 -12
+6 -12
tools/testing/selftests/net/arp_ndisc_untracked_subnets.sh
··· 5 5 # garp to the router. Router accepts or ignores based on its arp_accept 6 6 # or accept_untracked_na configuration. 7 7 8 + source lib.sh 9 + 8 10 TESTS="arp ndisc" 9 11 10 - ROUTER_NS="ns-router" 11 - ROUTER_NS_V6="ns-router-v6" 12 12 ROUTER_INTF="veth-router" 13 13 ROUTER_ADDR="10.0.10.1" 14 14 ROUTER_ADDR_V6="2001:db8:abcd:0012::1" 15 15 16 - HOST_NS="ns-host" 17 - HOST_NS_V6="ns-host-v6" 18 16 HOST_INTF="veth-host" 19 17 HOST_ADDR="10.0.10.2" 20 18 HOST_ADDR_V6="2001:db8:abcd:0012::2" ··· 21 23 PREFIX_WIDTH_V6=64 22 24 23 25 cleanup() { 24 - ip netns del ${HOST_NS} 25 - ip netns del ${ROUTER_NS} 26 + cleanup_ns ${HOST_NS} ${ROUTER_NS} 26 27 } 27 28 28 29 cleanup_v6() { 29 - ip netns del ${HOST_NS_V6} 30 - ip netns del ${ROUTER_NS_V6} 30 + cleanup_ns ${HOST_NS_V6} ${ROUTER_NS_V6} 31 31 } 32 32 33 33 setup() { ··· 33 37 local arp_accept=$1 34 38 35 39 # Set up two namespaces 36 - ip netns add ${ROUTER_NS} 37 - ip netns add ${HOST_NS} 40 + setup_ns HOST_NS ROUTER_NS 38 41 39 42 # Set up interfaces veth0 and veth1, which are pairs in separate 40 43 # namespaces. veth0 is veth-router, veth1 is veth-host. ··· 67 72 local accept_untracked_na=$1 68 73 69 74 # Set up two namespaces 70 - ip netns add ${ROUTER_NS_V6} 71 - ip netns add ${HOST_NS_V6} 75 + setup_ns HOST_NS_V6 ROUTER_NS_V6 72 76 73 77 # Set up interfaces veth0 and veth1, which are pairs in separate 74 78 # namespaces. veth0 is veth-router, veth1 is veth-host.