Skip to content

Commit b3cc4f8

Browse files
Paolo Abenidavem330
authored andcommitted
selftests: pmtu: add explicit tests for PMTU exceptions cleanup
Add a couple of new tests, explicitly checking that the kernel timely releases PMTU exceptions on related device removal. This is mostly a regression test vs the issue fixed by commit f5b51fe ("ipv6: route: purge exception on removal") Only 2 new test cases have been added, instead of extending all the existing ones, because the reproducer requires executing several commands and would slow down too much the tests otherwise. v2 -> v3: - more cleanup, still from Stefano v1 -> v2: - several script cleanups, as suggested by Stefano Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 651eb32 commit b3cc4f8

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@
103103
# and check that configured MTU is used on link creation and changes, and
104104
# that MTU is properly calculated instead when MTU is not configured from
105105
# userspace
106+
#
107+
# - cleanup_ipv4_exception
108+
# Similar to pmtu_ipv4_vxlan4_exception, but explicitly generate PMTU
109+
# exceptions on multiple CPUs and check that the veth device tear-down
110+
# happens in a timely manner
111+
#
112+
# - cleanup_ipv6_exception
113+
# Same as above, but use IPv6 transport from A to B
114+
106115

107116
# Kselftest framework requirement - SKIP code is 4.
108117
ksft_skip=4
@@ -135,7 +144,9 @@ tests="
135144
pmtu_vti6_default_mtu vti6: default MTU assignment
136145
pmtu_vti4_link_add_mtu vti4: MTU setting on link creation
137146
pmtu_vti6_link_add_mtu vti6: MTU setting on link creation
138-
pmtu_vti6_link_change_mtu vti6: MTU changes on link changes"
147+
pmtu_vti6_link_change_mtu vti6: MTU changes on link changes
148+
cleanup_ipv4_exception ipv4: cleanup of cached exceptions
149+
cleanup_ipv6_exception ipv6: cleanup of cached exceptions"
139150

140151
NS_A="ns-$(mktemp -u XXXXXX)"
141152
NS_B="ns-$(mktemp -u XXXXXX)"
@@ -1006,6 +1017,61 @@ test_pmtu_vti6_link_change_mtu() {
10061017
return ${fail}
10071018
}
10081019

1020+
check_command() {
1021+
cmd=${1}
1022+
1023+
if ! which ${cmd} > /dev/null 2>&1; then
1024+
err " missing required command: '${cmd}'"
1025+
return 1
1026+
fi
1027+
return 0
1028+
}
1029+
1030+
test_cleanup_vxlanX_exception() {
1031+
outer="${1}"
1032+
encap="vxlan"
1033+
ll_mtu=4000
1034+
1035+
check_command taskset || return 2
1036+
cpu_list=$(grep -m 2 processor /proc/cpuinfo | cut -d ' ' -f 2)
1037+
1038+
setup namespaces routing ${encap}${outer} || return 2
1039+
trace "${ns_a}" ${encap}_a "${ns_b}" ${encap}_b \
1040+
"${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1041+
"${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
1042+
1043+
# Create route exception by exceeding link layer MTU
1044+
mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
1045+
mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
1046+
mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1047+
mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1048+
1049+
mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
1050+
mtu "${ns_b}" ${encap}_b $((${ll_mtu} + 1000))
1051+
1052+
# Fill exception cache for multiple CPUs (2)
1053+
# we can always use inner IPv4 for that
1054+
for cpu in ${cpu_list}; do
1055+
taskset --cpu-list ${cpu} ${ns_a} ping -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${tunnel4_b_addr} > /dev/null
1056+
done
1057+
1058+
${ns_a} ip link del dev veth_A-R1 &
1059+
iplink_pid=$!
1060+
sleep 1
1061+
if [ "$(cat /proc/${iplink_pid}/cmdline 2>/dev/null | tr -d '\0')" = "iplinkdeldevveth_A-R1" ]; then
1062+
err " can't delete veth device in a timely manner, PMTU dst likely leaked"
1063+
return 1
1064+
fi
1065+
}
1066+
1067+
test_cleanup_ipv6_exception() {
1068+
test_cleanup_vxlanX_exception 6
1069+
}
1070+
1071+
test_cleanup_ipv4_exception() {
1072+
test_cleanup_vxlanX_exception 4
1073+
}
1074+
10091075
usage() {
10101076
echo
10111077
echo "$0 [OPTIONS] [TEST]..."

0 commit comments

Comments
 (0)