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

selftests: net: amt: wait longer for connection before sending packets

Both send_mcast4() and send_mcast6() use sleep 2 to wait for the tunnel
connection between the gateway and the relay, and for the listener
socket to be created in the LISTENER namespace.

However, tests sometimes fail because packets are sent before the
connection is fully established.

Increase the waiting time to make the tests more reliable, and use
wait_local_port_listen() to explicitly wait for the listener socket.

Fixes: c08e8baea78e ("selftests: add amt interface selftest script")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Link: https://patch.msgid.link/20260120133930.863845-1-ap420073@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Taehee Yoo and committed by
Jakub Kicinski
04708606 82157944

+5 -2
+5 -2
tools/testing/selftests/net/amt.sh
··· 73 73 # +------------------------+ 74 74 #============================================================================== 75 75 76 + source lib.sh 77 + 76 78 readonly LISTENER=$(mktemp -u listener-XXXXXXXX) 77 79 readonly GATEWAY=$(mktemp -u gateway-XXXXXXXX) 78 80 readonly RELAY=$(mktemp -u relay-XXXXXXXX) ··· 248 246 249 247 send_mcast4() 250 248 { 251 - sleep 2 249 + sleep 5 250 + wait_local_port_listen ${LISTENER} 4000 udp 252 251 ip netns exec "${SOURCE}" bash -c \ 253 252 'printf "%s %128s" 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' & 254 253 } 255 254 256 255 send_mcast6() 257 256 { 258 - sleep 2 257 + wait_local_port_listen ${LISTENER} 6000 udp 259 258 ip netns exec "${SOURCE}" bash -c \ 260 259 'printf "%s %128s" 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' & 261 260 }