Skip to content

Commit 378f082

Browse files
liuhangbindavem330
authored andcommitted
selftests/net: convert pmtu.sh to run it in unique namespace
pmtu test use /bin/sh, so we need to source ./lib.sh instead of lib.sh Here is the test result after conversion. # ./pmtu.sh TEST: ipv4: PMTU exceptions [ OK ] TEST: ipv4: PMTU exceptions - nexthop objects [ OK ] TEST: ipv6: PMTU exceptions [ OK ] TEST: ipv6: PMTU exceptions - nexthop objects [ OK ] ... TEST: ipv4: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv6: list and flush cached exceptions [ OK ] TEST: ipv6: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv4: PMTU exception w/route replace [ OK ] TEST: ipv4: PMTU exception w/route replace - nexthop objects [ OK ] TEST: ipv6: PMTU exception w/route replace [ OK ] TEST: ipv6: PMTU exception w/route replace - nexthop objects [ OK ] Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4416c5f commit 378f082

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@
198198
# - pmtu_ipv6_route_change
199199
# Same as above but with IPv6
200200

201-
# Kselftest framework requirement - SKIP code is 4.
202-
ksft_skip=4
201+
source ./lib.sh
203202

204203
PAUSE_ON_FAIL=no
205204
VERBOSE=0
@@ -268,16 +267,6 @@ tests="
268267
pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1
269268
pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1"
270269

271-
NS_A="ns-A"
272-
NS_B="ns-B"
273-
NS_C="ns-C"
274-
NS_R1="ns-R1"
275-
NS_R2="ns-R2"
276-
ns_a="ip netns exec ${NS_A}"
277-
ns_b="ip netns exec ${NS_B}"
278-
ns_c="ip netns exec ${NS_C}"
279-
ns_r1="ip netns exec ${NS_R1}"
280-
ns_r2="ip netns exec ${NS_R2}"
281270
# Addressing and routing for tests with routers: four network segments, with
282271
# index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
283272
# identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2).
@@ -543,13 +532,17 @@ setup_ip6ip6() {
543532
}
544533

545534
setup_namespaces() {
535+
setup_ns NS_A NS_B NS_C NS_R1 NS_R2
546536
for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
547-
ip netns add ${n} || return 1
548-
549537
# Disable DAD, so that we don't have to wait to use the
550538
# configured IPv6 addresses
551539
ip netns exec ${n} sysctl -q net/ipv6/conf/default/accept_dad=0
552540
done
541+
ns_a="ip netns exec ${NS_A}"
542+
ns_b="ip netns exec ${NS_B}"
543+
ns_c="ip netns exec ${NS_C}"
544+
ns_r1="ip netns exec ${NS_R1}"
545+
ns_r2="ip netns exec ${NS_R2}"
553546
}
554547

555548
setup_veth() {
@@ -839,7 +832,7 @@ setup_bridge() {
839832
run_cmd ${ns_a} ip link set br0 up
840833

841834
run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C
842-
run_cmd ${ns_c} ip link set veth_A-C netns ns-A
835+
run_cmd ${ns_c} ip link set veth_A-C netns ${NS_A}
843836

844837
run_cmd ${ns_a} ip link set veth_A-C up
845838
run_cmd ${ns_c} ip link set veth_C-A up
@@ -944,9 +937,7 @@ cleanup() {
944937
done
945938
socat_pids=
946939

947-
for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
948-
ip netns del ${n} 2> /dev/null
949-
done
940+
cleanup_all_ns
950941

951942
ip link del veth_A-C 2>/dev/null
952943
ip link del veth_A-R1 2>/dev/null

0 commit comments

Comments
 (0)