Skip to content

Commit 1af3bc9

Browse files
Geliang Tangkuba-moo
authored andcommitted
selftests: mptcp: lib: use wait_local_port_listen helper
This patch includes net_helper.sh into mptcp_lib.sh, uses the helper wait_local_port_listen() defined in it to implement the similar mptcp helper. This can drop some duplicate code. It looks like this helper from net_helper.sh was originally coming from MPTCP, but MPTCP selftests have not been updated to use it from this shared place. Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://lore.kernel.org/r/20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-6-e36986faac94@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f265d31 commit 1af3bc9

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

tools/testing/selftests/net/mptcp/mptcp_lib.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: GPL-2.0
33

44
. "$(dirname "${0}")/../lib.sh"
5+
. "$(dirname "${0}")/../net_helper.sh"
56

67
readonly KSFT_PASS=0
78
readonly KSFT_FAIL=1
@@ -363,20 +364,7 @@ mptcp_lib_check_transfer() {
363364

364365
# $1: ns, $2: port
365366
mptcp_lib_wait_local_port_listen() {
366-
local listener_ns="${1}"
367-
local port="${2}"
368-
369-
local port_hex
370-
port_hex="$(printf "%04X" "${port}")"
371-
372-
local _
373-
for _ in $(seq 10); do
374-
ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
375-
awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) \
376-
{rc=0; exit}} END {exit rc}" &&
377-
break
378-
sleep 0.1
379-
done
367+
wait_local_port_listen "${@}" "tcp"
380368
}
381369

382370
mptcp_lib_check_output() {

0 commit comments

Comments
 (0)