@@ -334,6 +334,21 @@ do_ping()
334
334
return 0
335
335
}
336
336
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
+
337
352
# $1: ns, $2: port
338
353
wait_local_port_listen ()
339
354
{
@@ -410,10 +425,10 @@ do_transfer()
410
425
sleep 1
411
426
fi
412
427
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" )
417
432
418
433
ip netns exec ${listener_ns} ./mptcp_connect -t $timeout -l -p $port -s ${srv_proto} $extra_args $local_addr < " $sin " > " $sout " &
419
434
local spid=$!
@@ -448,15 +463,17 @@ do_transfer()
448
463
449
464
local duration
450
465
duration=$(( stop- start))
451
- duration= $( printf " (duration %05sms)" $ duration)
466
+ printf " (duration %05sms) " " ${ duration} "
452
467
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
454
469
echo -e " \nnetns ${listener_ns} socket stat for ${port} :" 1>&2
455
470
ip netns exec ${listener_ns} ss -Menita 1>&2 -o " sport = :$port "
456
471
cat /tmp/${listener_ns} .out
457
472
echo -e " \nnetns ${connector_ns} socket stat for ${port} :" 1>&2
458
473
ip netns exec ${connector_ns} ss -Menita 1>&2 -o " dport = :$port "
459
474
[ ${listener_ns} != ${connector_ns} ] && cat /tmp/${connector_ns} .out
475
+
476
+ echo
460
477
cat " $capout "
461
478
return 1
462
479
fi
@@ -466,11 +483,14 @@ do_transfer()
466
483
check_transfer $cin $sout " file received by server"
467
484
rets=$?
468
485
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
471
489
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" )
474
494
475
495
expect_synrx=$(( stat_synrx_last_l))
476
496
expect_ackrx=$(( stat_ackrx_last_l))
@@ -484,35 +504,32 @@ do_transfer()
484
504
fi
485
505
if [ $cookies -eq 2 ]; then
486
506
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"
488
508
fi
489
509
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"
491
511
fi
492
512
else
493
513
if [ $stat_cookietx_last -ne $stat_cookietx_now ] ; then
494
- echo " ${listener_ns} CookieSent: ${cl_proto} -> ${srv_proto} : changed"
514
+ printf " WARN: CookieSent : changed"
495
515
fi
496
516
if [ $stat_cookierx_last -ne $stat_cookierx_now ] ; then
497
- echo " ${listener_ns} CookieRecv: ${cl_proto} -> ${srv_proto} : changed"
517
+ printf " WARN: CookieRecv : changed"
498
518
fi
499
519
fi
500
520
501
521
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} "
503
524
fi
504
525
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} "
512
528
fi
513
529
530
+ echo
514
531
cat " $capout "
515
- return 1
532
+ [ $retc -eq 0 ] && [ $rets -eq 0 ]
516
533
}
517
534
518
535
make_file ()
0 commit comments