Skip to content

Commit 3340b17

Browse files
Gang Yanintel-lab-lkp
authored andcommitted
selftests: mptcp: add chk_sublfow in diag.sh
This patch aims to add chk_dump_subflow in diag.sh. The subflow's info can be obtained through "ss -tin", then use the 'mptcp_diag' to verify the token in subflow_info. Co-developed-by: Geliang Tang <[email protected]> Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Gang Yan <[email protected]>
1 parent c942c3e commit 3340b17

File tree

1 file changed

+55
-0
lines changed
  • tools/testing/selftests/net/mptcp

1 file changed

+55
-0
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,60 @@ chk_dump_one()
225225
fi
226226
}
227227

228+
get_endpoint_addr()
229+
{
230+
echo $1 | cut -d ":" -f 1
231+
}
232+
233+
get_endpoint_port()
234+
{
235+
echo $1 | cut -d ":" -f 2
236+
}
237+
238+
chk_dump_subflow()
239+
{
240+
local inet_diag_token
241+
local subflow_line
242+
local remote_addr
243+
local remote_port
244+
local local_addr
245+
local local_port
246+
local ss_token
247+
local msg
248+
249+
subflow_line=$(ss -tnN $ns | \
250+
grep -m1 -Eo '[0-9.]+:[0-9].+ +[0-9.]+:[0-9.]+')
251+
252+
if [ -n "$subflow_line" ]; then
253+
read -r local_endpoint remote_endpoint <<< $subflow_line
254+
255+
local_addr=$(get_endpoint_addr $local_endpoint)
256+
local_port=$(get_endpoint_port $local_endpoint)
257+
258+
remote_addr=$(get_endpoint_addr $remote_endpoint)
259+
remote_port=$(get_endpoint_port $remote_endpoint)
260+
fi
261+
262+
ss_token=$(ss -tniN $ns | \
263+
grep -m1 -Eo 'token:[^ ]+')
264+
265+
inet_diag_token=$(ip netns exec $ns ./mptcp_diag -s \
266+
"$local_addr $local_port $remote_addr $remote_port" | \
267+
grep -Eo 'token:[^ ]+')
268+
269+
msg="....chk dump_subflow"
270+
271+
mptcp_lib_print_title "$msg"
272+
if [[ $ss_token == $inet_diag_token ]]; then
273+
mptcp_lib_pr_ok
274+
mptcp_lib_result_pass "${msg}"
275+
else
276+
mptcp_lib_pr_fail "expected $ss_token but $inet_diag_token"
277+
mptcp_lib_result_fail "${msg}"
278+
ret=${KSFT_FAIL}
279+
fi
280+
}
281+
228282
msk_info_get_value()
229283
{
230284
local port="${1}"
@@ -316,6 +370,7 @@ chk_msk_fallback_nr 0 "....chk no fallback"
316370
chk_msk_inuse 2
317371
chk_msk_cestab 2
318372
chk_dump_one
373+
chk_dump_subflow
319374
flush_pids
320375

321376
chk_msk_inuse 0 "2->0"

0 commit comments

Comments
 (0)