selftests: mptcp: add the MP_RST mibs check
authorGeliang Tang <geliang.tang@suse.com>
Fri, 4 Mar 2022 19:36:30 +0000 (11:36 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 5 Mar 2022 05:54:30 +0000 (21:54 -0800)
This patch added a new function chk_rst_nr() to check the numbers
of the MP_RST sending and receiving mibs.

Showed in the output whether the inverted namespaces check order is used.
Since if we pass -Cz to mptcp_join.sh, the MP_RST information is showed
twice.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/mptcp_join.sh

index 10339a796325df8ae406cfe8ad501a93990688b3..12008640d9f44cfa8ef00de535e46b54e15f0a51 100755 (executable)
@@ -824,6 +824,50 @@ chk_fclose_nr()
        [ "${dump_stats}" = 1 ] && dump_stats
 }
 
+chk_rst_nr()
+{
+       local rst_tx=$1
+       local rst_rx=$2
+       local ns_invert=${3:-""}
+       local count
+       local dump_stats
+       local ns_tx=$ns1
+       local ns_rx=$ns2
+       local extra_msg=""
+
+       if [[ $ns_invert = "invert" ]]; then
+               ns_tx=$ns2
+               ns_rx=$ns1
+               extra_msg="   invert"
+       fi
+
+       printf "%-${nr_blank}s %s" " " "rtx"
+       count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPRstTx | awk '{print $2}')
+       [ -z "$count" ] && count=0
+       if [ "$count" != "$rst_tx" ]; then
+               echo "[fail] got $count MP_RST[s] TX expected $rst_tx"
+               ret=1
+               dump_stats=1
+       else
+               echo -n "[ ok ]"
+       fi
+
+       echo -n " - rstrx "
+       count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPRstRx | awk '{print $2}')
+       [ -z "$count" ] && count=0
+       if [ "$count" != "$rst_rx" ]; then
+               echo "[fail] got $count MP_RST[s] RX expected $rst_rx"
+               ret=1
+               dump_stats=1
+       else
+               echo -n "[ ok ]"
+       fi
+
+       [ "${dump_stats}" = 1 ] && dump_stats
+
+       echo "$extra_msg"
+}
+
 chk_join_nr()
 {
        local msg="$1"
@@ -878,6 +922,7 @@ chk_join_nr()
        if [ $checksum -eq 1 ]; then
                chk_csum_nr
                chk_fail_nr 0 0
+               chk_rst_nr 0 0
        fi
 }