Skip to content

Commit 5a9aacf

Browse files
Paolo Abenimehmetb0
Paolo Abeni
authored andcommittedNov 8, 2024
selftests: net: more strict check in net_helper
BugLink: https://bugs.launchpad.net/bugs/2086242 commit a71d090 upstream. The helper waiting for a listener port can match any socket whose hexadecimal representation of source or destination addresses matches that of the given port. Additionally, any socket state is accepted. All the above can let the helper return successfully before the relevant listener is actually ready, with unexpected results. So far I could not find any related failure in the netdev CI, but the next patch is going to make the critical event more easily reproducible. Address the issue matching the port hex only vs the relevant socket field and additionally checking the socket state for TCP sockets. Fixes: 3bdd9fd ("selftests/net: synchronize udpgro tests' tx and rx connection") Signed-off-by: Paolo Abeni <[email protected]> Link: https://lore.kernel.org/r/192b3dbc443d953be32991d1b0ca432bd4c65008.1707731086.git.pabeni@redhat.com Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent d187a88 commit 5a9aacf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎tools/testing/selftests/net/net_helper.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ wait_local_port_listen()
88
local listener_ns="${1}"
99
local port="${2}"
1010
local protocol="${3}"
11-
local port_hex
11+
local pattern
1212
local i
1313

14-
port_hex="$(printf "%04X" "${port}")"
14+
pattern=":$(printf "%04X" "${port}") "
15+
16+
# for tcp protocol additionally check the socket state
17+
[ ${protocol} = "tcp" ] && pattern="${pattern}0A"
1518
for i in $(seq 10); do
16-
if ip netns exec "${listener_ns}" cat /proc/net/"${protocol}"* | \
17-
grep -q "${port_hex}"; then
19+
if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
20+
/proc/net/"${protocol}"* | grep -q "${pattern}"; then
1821
break
1922
fi
2023
sleep 0.1

0 commit comments

Comments
 (0)