Skip to content

Commit 691bb4e

Browse files
Paolo Abenikuba-moo
authored andcommitted
selftests: net: avoid just another constant wait
Using hard-coded constant timeout to wait for some expected event is deemed to fail sooner or later, especially in slow env. Our CI has spotted another of such race: # TEST: ipv6: cleanup of cached exceptions - nexthop objects [FAIL] # can't delete veth device in a timely manner, PMTU dst likely leaked Replace the crude sleep with a loop looking for the expected condition at low interval for a much longer range. Fixes: b3cc4f8 ("selftests: pmtu: add explicit tests for PMTU exceptions cleanup") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/fd5c745e9bb665b724473af6a9373a8c2a62b247.1706812005.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e71e016 commit 691bb4e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,13 @@ check_command() {
19571957
return 0
19581958
}
19591959

1960+
check_running() {
1961+
pid=${1}
1962+
cmd=${2}
1963+
1964+
[ "$(cat /proc/${pid}/cmdline 2>/dev/null | tr -d '\0')" = "{cmd}" ]
1965+
}
1966+
19601967
test_cleanup_vxlanX_exception() {
19611968
outer="${1}"
19621969
encap="vxlan"
@@ -1987,11 +1994,12 @@ test_cleanup_vxlanX_exception() {
19871994

19881995
${ns_a} ip link del dev veth_A-R1 &
19891996
iplink_pid=$!
1990-
sleep 1
1991-
if [ "$(cat /proc/${iplink_pid}/cmdline 2>/dev/null | tr -d '\0')" = "iplinkdeldevveth_A-R1" ]; then
1992-
err " can't delete veth device in a timely manner, PMTU dst likely leaked"
1993-
return 1
1994-
fi
1997+
for i in $(seq 1 20); do
1998+
check_running ${iplink_pid} "iplinkdeldevveth_A-R1" || return 0
1999+
sleep 0.1
2000+
done
2001+
err " can't delete veth device in a timely manner, PMTU dst likely leaked"
2002+
return 1
19952003
}
19962004

19972005
test_cleanup_ipv6_exception() {

0 commit comments

Comments
 (0)