Skip to content

Commit

Permalink
selftests: mptcp: use wait_local_port_listen helper
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed May 24, 2024
1 parent 318882a commit 0e9d7f8
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions tools/testing/selftests/net/mptcp/mptcp_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-2.0

. "$(dirname "${0}")/../lib.sh"
. "$(dirname "${0}")/../net_helper.sh"

readonly KSFT_PASS=0
readonly KSFT_FAIL=1
Expand Down Expand Up @@ -363,20 +364,7 @@ mptcp_lib_check_transfer() {

# $1: ns, $2: port
mptcp_lib_wait_local_port_listen() {
local listener_ns="${1}"
local port="${2}"

local port_hex
port_hex="$(printf "%04X" "${port}")"

local _
for _ in $(seq 10); do
ip netns exec "${listener_ns}" cat /proc/net/tcp* | \
awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) \
{rc=0; exit}} END {exit rc}" &&
break
sleep 0.1
done
wait_local_port_listen "${@}" "tcp"
}

mptcp_lib_check_output() {
Expand Down

0 comments on commit 0e9d7f8

Please sign in to comment.