[SRU][J][PATCH v2 1/1] selftests: net: use slowwait to stabilize vrf_route_leaking test
Alessio Faina
alessio.faina at canonical.com
Thu Dec 11 08:12:05 UTC 2025
From: Hangbin Liu <liuhangbin at gmail.com>
The vrf_route_leaking test occasionally fails due to connectivity issues
in our testing environment. A sample failure message shows that the ping
check fails intermittently
PING 2001:db8:16:2::2 (2001:db8:16:2::2) 56 data bytes
--- 2001:db8:16:2::2 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
TEST: Basic IPv6 connectivity [FAIL]
This is likely due to insufficient wait time on slower machines. To address
this, switch to using slowwait, which provides a longer and more reliable
wait for setup completion.
Before this change, the test failed 3 out of 10 times. After applying this
fix, the test was run 30 times without any failure.
Signed-off-by: Hangbin Liu <liuhangbin at gmail.com>
Reviewed-by: Simon Horman <horms at kernel.org>
Link: https://patch.msgid.link/20250617105101.433718-2-liuhangbin@gmail.com
Signed-off-by: Paolo Abeni <pabeni at redhat.com>
(backported from commit d83a5806759278c4898cd7c2116432e5b08df1df)
[alessiofaina:
* Added file lib.sh, containing the loopy_wait and slowwait functions
from commits a4022a332f437, 25ae948b44788 and ea63ac1429256 ]
Signed-off-by: Alessio Faina <alessio.faina at canonical.com>
---
tools/testing/selftests/net/lib.sh | 42 +++++++++++++++++++
.../selftests/net/vrf_route_leaking.sh | 5 ++-
2 files changed, 45 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/net/lib.sh
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
new file mode 100644
index 000000000000..5e31809ff7b3
--- /dev/null
+++ b/tools/testing/selftests/net/lib.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+loopy_wait()
+{
+ local sleep_cmd=$1; shift
+ local timeout_ms=$1; shift
+
+ local start_time="$(date -u +%s%3N)"
+ while true
+ do
+ local out
+ if out=$("$@"); then
+ echo -n "$out"
+ return 0
+ fi
+
+ local current_time="$(date -u +%s%3N)"
+ if ((current_time - start_time > timeout_ms)); then
+ echo -n "$out"
+ return 1
+ fi
+
+ $sleep_cmd
+ done
+}
+
+busywait()
+{
+ local timeout_ms=$1; shift
+
+ loopy_wait : "$timeout_ms" "$@"
+}
+
+# timeout in seconds
+slowwait()
+{
+ local timeout_sec=$1; shift
+
+ loopy_wait "sleep 0.1" "$((timeout_sec * 1000))" "$@"
+}
+
diff --git a/tools/testing/selftests/net/vrf_route_leaking.sh b/tools/testing/selftests/net/vrf_route_leaking.sh
index 23cf924754a5..aae0f5a86395 100755
--- a/tools/testing/selftests/net/vrf_route_leaking.sh
+++ b/tools/testing/selftests/net/vrf_route_leaking.sh
@@ -58,6 +58,7 @@
# to send an ICMP error back to the source when the ttl of a packet reaches 1
# while it is forwarded between different vrfs.
+source lib.sh
VERBOSE=0
PAUSE_ON_FAIL=no
DEFAULT_TTYPE=sym
@@ -281,7 +282,7 @@ setup_sym()
# Wait for ip config to settle
- sleep 2
+ slowwait 5 ip netns exec $h1 "${ping6}" -c1 -w1 ${H2_N2_IP6} >/dev/null 2>&1
}
setup_asym()
@@ -379,7 +380,7 @@ setup_asym()
ip -netns r2 -6 addr add dev eth1 ${R2_N2_IP6}/64 nodad
# Wait for ip config to settle
- sleep 2
+ slowwait 5 ip netns exec $h1 "${ping6}" -c1 -w1 ${H2_N2_IP6} >/dev/null 2>&1
}
check_connectivity()
--
2.43.0
More information about the kernel-team
mailing list