Skip to content

Commit 45759a8

Browse files
matttbedavem330
authored andcommitted
selftests: mptcp: display warnings on one line
Before we had this in case of SYN retransmissions: (...) # ns4 MPTCP -> ns2 (10.0.1.2:10034 ) MPTCP (duration 1201ms) [ OK ] # ns4 MPTCP -> ns2 (dead:beef:1::2:10035) MPTCP (duration 1242ms) [ OK ] # ns4 MPTCP -> ns2 (10.0.2.1:10036 ) MPTCP ns2-60143c00-cDZWo4 SYNRX: MPTCP -> MPTCP: expect 11, got # 13 # (duration 6221ms) [ OK ] # ns4 MPTCP -> ns2 (dead:beef:2::1:10037) MPTCP (duration 1427ms) [ OK ] # ns4 MPTCP -> ns3 (10.0.2.2:10038 ) MPTCP (duration 881ms) [ OK ] (...) Now we have: (...) # ns4 MPTCP -> ns2 (10.0.1.2:10034 ) MPTCP (duration 1201ms) [ OK ] # ns4 MPTCP -> ns2 (dead:beef:1::2:10035) MPTCP (duration 1242ms) [ OK ] # ns4 MPTCP -> ns2 (10.0.2.1:10036 ) MPTCP (duration 6221ms) [ OK ] WARN: SYNRX: expect 11, got 13 # ns4 MPTCP -> ns2 (dead:beef:2::1:10037) MPTCP (duration 1427ms) [ OK ] # ns4 MPTCP -> ns3 (10.0.2.2:10038 ) MPTCP (duration 881ms) [ OK ] (...) So we put everything on one line, keep the durations and "OK" aligned and removed duplicated info to short the warning. Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f384221 commit 45759a8

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed

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

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,21 @@ do_ping()
334334
return 0
335335
}
336336

337+
# $1: ns, $2: MIB counter
338+
get_mib_counter()
339+
{
340+
local listener_ns="${1}"
341+
local mib="${2}"
342+
343+
# strip the header
344+
ip netns exec "${listener_ns}" \
345+
nstat -z -a "${mib}" | \
346+
tail -n+2 | \
347+
while read a count c rest; do
348+
echo $count
349+
done
350+
}
351+
337352
# $1: ns, $2: port
338353
wait_local_port_listen()
339354
{
@@ -410,10 +425,10 @@ do_transfer()
410425
sleep 1
411426
fi
412427

413-
local stat_synrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ;do echo $count;done)
414-
local stat_ackrx_last_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ;do echo $count;done)
415-
local stat_cookietx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do echo $count;done)
416-
local stat_cookierx_last=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do echo $count;done)
428+
local stat_synrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
429+
local stat_ackrx_last_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
430+
local stat_cookietx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
431+
local stat_cookierx_last=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
417432

418433
ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < "$sin" > "$sout" &
419434
local spid=$!
@@ -448,15 +463,17 @@ do_transfer()
448463

449464
local duration
450465
duration=$((stop-start))
451-
duration=$(printf "(duration %05sms)" $duration)
466+
printf "(duration %05sms) " "${duration}"
452467
if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
453-
echo "$duration [ FAIL ] client exit code $retc, server $rets" 1>&2
468+
echo "[ FAIL ] client exit code $retc, server $rets" 1>&2
454469
echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
455470
ip netns exec ${listener_ns} ss -Menita 1>&2 -o "sport = :$port"
456471
cat /tmp/${listener_ns}.out
457472
echo -e "\nnetns ${connector_ns} socket stat for ${port}:" 1>&2
458473
ip netns exec ${connector_ns} ss -Menita 1>&2 -o "dport = :$port"
459474
[ ${listener_ns} != ${connector_ns} ] && cat /tmp/${connector_ns}.out
475+
476+
echo
460477
cat "$capout"
461478
return 1
462479
fi
@@ -466,11 +483,14 @@ do_transfer()
466483
check_transfer $cin $sout "file received by server"
467484
rets=$?
468485

469-
local stat_synrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableSYNRX | while read a count c rest ;do echo $count;done)
470-
local stat_ackrx_now_l=$(ip netns exec ${listener_ns} nstat -z -a MPTcpExtMPCapableACKRX | while read a count c rest ;do echo $count;done)
486+
if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
487+
printf "[ OK ]"
488+
fi
471489

472-
local stat_cookietx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesSent | while read a count c rest ;do echo $count;done)
473-
local stat_cookierx_now=$(ip netns exec ${listener_ns} nstat -z -a TcpExtSyncookiesRecv | while read a count c rest ;do echo $count;done)
490+
local stat_synrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
491+
local stat_ackrx_now_l=$(get_mib_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
492+
local stat_cookietx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesSent")
493+
local stat_cookierx_now=$(get_mib_counter "${listener_ns}" "TcpExtSyncookiesRecv")
474494

475495
expect_synrx=$((stat_synrx_last_l))
476496
expect_ackrx=$((stat_ackrx_last_l))
@@ -484,35 +504,32 @@ do_transfer()
484504
fi
485505
if [ $cookies -eq 2 ];then
486506
if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
487-
echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: did not advance"
507+
printf " WARN: CookieSent: did not advance"
488508
fi
489509
if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
490-
echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: did not advance"
510+
printf " WARN: CookieRecv: did not advance"
491511
fi
492512
else
493513
if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
494-
echo "${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto}: changed"
514+
printf " WARN: CookieSent: changed"
495515
fi
496516
if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
497-
echo "${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto}: changed"
517+
printf " WARN: CookieRecv: changed"
498518
fi
499519
fi
500520

501521
if [ $expect_synrx -ne $stat_synrx_now_l ] ;then
502-
echo "${listener_ns} SYNRX: ${cl_proto} -> ${srv_proto}: expect ${expect_synrx}, got ${stat_synrx_now_l}"
522+
printf " WARN: SYNRX: expect %d, got %d" \
523+
"${expect_synrx}" "${stat_synrx_now_l}"
503524
fi
504525
if [ $expect_ackrx -ne $stat_ackrx_now_l ] ;then
505-
echo "${listener_ns} ACKRX: ${cl_proto} -> ${srv_proto}: expect ${expect_ackrx}, got ${stat_ackrx_now_l} "
506-
fi
507-
508-
if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
509-
echo "$duration [ OK ]"
510-
cat "$capout"
511-
return 0
526+
printf " WARN: ACKRX: expect %d, got %d" \
527+
"${expect_ackrx}" "${stat_ackrx_now_l}"
512528
fi
513529

530+
echo
514531
cat "$capout"
515-
return 1
532+
[ $retc -eq 0 ] && [ $rets -eq 0 ]
516533
}
517534

518535
make_file()

0 commit comments

Comments
 (0)