Commit 00079f18 authored by Matthieu Baerts's avatar Matthieu Baerts Committed by Jakub Kicinski

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 fc518953
("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: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: 0639fa23 ("selftests: mptcp: add explicit check for new mibs")
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent aa723d5b
...@@ -1683,12 +1683,12 @@ chk_add_tx_nr() ...@@ -1683,12 +1683,12 @@ chk_add_tx_nr()
timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)
printf "%-${nr_blank}s %s" " " "add TX" printf "%-${nr_blank}s %s" " " "add TX"
count=$(ip netns exec $ns1 nstat -as MPTcpExtAddAddrTx | grep MPTcpExtAddAddrTx | awk '{print $2}') count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
[ -z "$count" ] && count=0 if [ -z "$count" ]; then
echo -n "[skip]"
# if the test configured a short timeout tolerate greater then expected # if the test configured a short timeout tolerate greater then expected
# add addrs options, due to retransmissions # add addrs options, due to retransmissions
if [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then elif [ "$count" != "$add_tx_nr" ] && { [ "$timeout" -gt 1 ] || [ "$count" -lt "$add_tx_nr" ]; }; then
echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr" echo "[fail] got $count ADD_ADDR[s] TX, expected $add_tx_nr"
fail_test fail_test
else else
...@@ -1696,9 +1696,10 @@ chk_add_tx_nr() ...@@ -1696,9 +1696,10 @@ chk_add_tx_nr()
fi fi
echo -n " - echo TX " echo -n " - echo TX "
count=$(ip netns exec $ns2 nstat -as MPTcpExtEchoAddTx | grep MPTcpExtEchoAddTx | awk '{print $2}') count=$(get_counter ${ns2} "MPTcpExtEchoAddTx")
[ -z "$count" ] && count=0 if [ -z "$count" ]; then
if [ "$count" != "$echo_tx_nr" ]; then echo "[skip]"
elif [ "$count" != "$echo_tx_nr" ]; then
echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr" echo "[fail] got $count ADD_ADDR echo[s] TX, expected $echo_tx_nr"
fail_test fail_test
else else
...@@ -1734,9 +1735,10 @@ chk_rm_nr() ...@@ -1734,9 +1735,10 @@ chk_rm_nr()
fi fi
printf "%-${nr_blank}s %s" " " "rm " printf "%-${nr_blank}s %s" " " "rm "
count=$(ip netns exec $addr_ns nstat -as MPTcpExtRmAddr | grep MPTcpExtRmAddr | awk '{print $2}') count=$(get_counter ${addr_ns} "MPTcpExtRmAddr")
[ -z "$count" ] && count=0 if [ -z "$count" ]; then
if [ "$count" != "$rm_addr_nr" ]; then echo -n "[skip]"
elif [ "$count" != "$rm_addr_nr" ]; then
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr"
fail_test fail_test
else else
...@@ -1778,16 +1780,15 @@ chk_rm_tx_nr() ...@@ -1778,16 +1780,15 @@ chk_rm_tx_nr()
local rm_addr_tx_nr=$1 local rm_addr_tx_nr=$1
printf "%-${nr_blank}s %s" " " "rm TX " printf "%-${nr_blank}s %s" " " "rm TX "
count=$(ip netns exec $ns2 nstat -as MPTcpExtRmAddrTx | grep MPTcpExtRmAddrTx | awk '{print $2}') count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
[ -z "$count" ] && count=0 if [ -z "$count" ]; then
if [ "$count" != "$rm_addr_tx_nr" ]; then echo "[skip]"
elif [ "$count" != "$rm_addr_tx_nr" ]; then
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr" echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr"
fail_test fail_test
else else
echo -n "[ ok ]" echo "[ ok ]"
fi fi
echo "$extra_msg"
} }
chk_prio_nr() chk_prio_nr()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment