selftests: mptcp: check MP_FAIL response mibs
authorGeliang Tang <geliang.tang@suse.com>
Tue, 26 Apr 2022 21:57:16 +0000 (14:57 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Apr 2022 09:45:54 +0000 (10:45 +0100)
This patch extends chk_fail_nr to check the MP_FAIL response mibs.

Add a new argument invert for chk_fail_nr to allow it can check the
MP_FAIL TX and RX mibs from the opposite direction.

When the infinite map is received before the MP_FAIL response, the
response will be lost. A '-' can be added into fail_tx or fail_rx to
represent that MP_FAIL response TX or RX can be lost when doing the
checks.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/mptcp/mptcp_join.sh

index 34152a5..8023c07 100755 (executable)
@@ -1054,13 +1054,38 @@ chk_fail_nr()
 {
        local fail_tx=$1
        local fail_rx=$2
+       local ns_invert=${3:-""}
        local count
        local dump_stats
+       local ns_tx=$ns1
+       local ns_rx=$ns2
+       local extra_msg=""
+       local allow_tx_lost=0
+       local allow_rx_lost=0
+
+       if [[ $ns_invert = "invert" ]]; then
+               ns_tx=$ns2
+               ns_rx=$ns1
+               extra_msg=" invert"
+       fi
+
+       if [[ "${fail_tx}" = "-"* ]]; then
+               allow_tx_lost=1
+               fail_tx=${fail_tx:1}
+       fi
+       if [[ "${fail_rx}" = "-"* ]]; then
+               allow_rx_lost=1
+               fail_rx=${fail_rx:1}
+       fi
 
        printf "%-${nr_blank}s %s" " " "ftx"
-       count=$(ip netns exec $ns1 nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}')
+       count=$(ip netns exec $ns_tx nstat -as | grep MPTcpExtMPFailTx | awk '{print $2}')
        [ -z "$count" ] && count=0
        if [ "$count" != "$fail_tx" ]; then
+               extra_msg="$extra_msg,tx=$count"
+       fi
+       if { [ "$count" != "$fail_tx" ] && [ $allow_tx_lost -eq 0 ]; } ||
+          { [ "$count" -gt "$fail_tx" ] && [ $allow_tx_lost -eq 1 ]; }; then
                echo "[fail] got $count MP_FAIL[s] TX expected $fail_tx"
                fail_test
                dump_stats=1
@@ -1069,17 +1094,23 @@ chk_fail_nr()
        fi
 
        echo -n " - failrx"
-       count=$(ip netns exec $ns2 nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}')
+       count=$(ip netns exec $ns_rx nstat -as | grep MPTcpExtMPFailRx | awk '{print $2}')
        [ -z "$count" ] && count=0
        if [ "$count" != "$fail_rx" ]; then
+               extra_msg="$extra_msg,rx=$count"
+       fi
+       if { [ "$count" != "$fail_rx" ] && [ $allow_rx_lost -eq 0 ]; } ||
+          { [ "$count" -gt "$fail_rx" ] && [ $allow_rx_lost -eq 1 ]; }; then
                echo "[fail] got $count MP_FAIL[s] RX expected $fail_rx"
                fail_test
                dump_stats=1
        else
-               echo "[ ok ]"
+               echo -n "[ ok ]"
        fi
 
        [ "${dump_stats}" = 1 ] && dump_stats
+
+       echo "$extra_msg"
 }
 
 chk_fclose_nr()
@@ -2654,6 +2685,7 @@ fail_tests()
        if reset_with_fail "Infinite map" 1; then
                run_tests $ns1 $ns2 10.0.1.1 128
                chk_join_nr 0 0 0 +1 +0 1 0 1 "$(pedit_action_pkts)"
+               chk_fail_nr 1 -1 invert
        fi
 }