Skip to content

Commit 00079f1

Browse files
matttbekuba-moo
authored andcommitted
selftests: mptcp: join: skip check if MIB counter not supported (part 2)
Selftests are supposed to run on any kernels, including the old ones not supporting all MPTCP features. One of them is the MPTCP MIB counters introduced in commit fc51895 ("mptcp: add and use MIB counter infrastructure") and more later. The MPTCP Join selftest heavily relies on these counters. If a counter is not supported by the kernel, it is not displayed when using 'nstat -z'. We can then detect that and skip the verification. A new helper (get_counter()) has been added recently in the -net tree to do the required checks and return an error if the counter is not available. This commit is similar to the one with the same title applied in the -net tree but it modifies code only present in net-next for the moment, see the Fixes commit below. While at it, we can also remove the use of ${extra_msg} variable which is never assigned in chk_rm_tx_nr() function and use 'echo' without '-n' parameter. Link: multipath-tcp/mptcp_net-next#368 Fixes: 0639fa2 ("selftests: mptcp: add explicit check for new mibs") Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent aa723d5 commit 00079f1

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,22 +1683,23 @@ chk_add_tx_nr()
16831683
timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
16841684

16851685
printf "%-${nr_blank}s %s" " " "add TX"
1686-
count=$(ip netns exec $ns1 nstat -as MPTcpExtAddAddrTx | grep MPTcpExtAddAddrTx | awk '{print $2}')
1687-
[ -z "$count" ] && count=0
1688-
1686+
count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
1687+
if [ -z "$count" ]; then
1688+
echo -n "[skip]"
16891689
# if the test configured a short timeout tolerate greater then expected
16901690
# add addrs options, due to retransmissions
1691-
if [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
1691+
elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
16921692
echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr"
16931693
fail_test
16941694
else
16951695
echo -n "[ ok ]"
16961696
fi
16971697

16981698
echo -n " - echo TX "
1699-
count=$(ip netns exec $ns2 nstat -as MPTcpExtEchoAddTx | grep MPTcpExtEchoAddTx | awk '{print $2}')
1700-
[ -z "$count" ] && count=0
1701-
if [ "$count" != "$echo_tx_nr" ]; then
1699+
count=$(get_counter ${ns2} "MPTcpExtEchoAddTx")
1700+
if [ -z "$count" ]; then
1701+
echo "[skip]"
1702+
elif [ "$count" != "$echo_tx_nr" ]; then
17021703
echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr"
17031704
fail_test
17041705
else
@@ -1734,9 +1735,10 @@ chk_rm_nr()
17341735
fi
17351736

17361737
printf "%-${nr_blank}s %s" " " "rm "
1737-
count=$(ip netns exec $addr_ns nstat -as MPTcpExtRmAddr | grep MPTcpExtRmAddr | awk '{print $2}')
1738-
[ -z "$count" ] && count=0
1739-
if [ "$count" != "$rm_addr_nr" ]; then
1738+
count=$(get_counter ${addr_ns} "MPTcpExtRmAddr")
1739+
if [ -z "$count" ]; then
1740+
echo -n "[skip]"
1741+
elif [ "$count" != "$rm_addr_nr" ]; then
17401742
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
17411743
fail_test
17421744
else
@@ -1778,16 +1780,15 @@ chk_rm_tx_nr()
17781780
local rm_addr_tx_nr=$1
17791781

17801782
printf "%-${nr_blank}s %s" " " "rm TX "
1781-
count=$(ip netns exec $ns2 nstat -as MPTcpExtRmAddrTx | grep MPTcpExtRmAddrTx | awk '{print $2}')
1782-
[ -z "$count" ] && count=0
1783-
if [ "$count" != "$rm_addr_tx_nr" ]; then
1783+
count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
1784+
if [ -z "$count" ]; then
1785+
echo "[skip]"
1786+
elif [ "$count" != "$rm_addr_tx_nr" ]; then
17841787
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr"
17851788
fail_test
17861789
else
1787-
echo -n "[ ok ]"
1790+
echo "[ ok ]"
17881791
fi
1789-
1790-
echo "$extra_msg"
17911792
}
17921793

17931794
chk_prio_nr()

0 commit comments

Comments
 (0)