Skip to content

Commit

Permalink
selftests: mptcp: join: skip check if MIB counter not supported (part 2)
Browse files Browse the repository at this point in the history
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: #368
Fixes: 0639fa2 ("selftests: mptcp: add explicit check for new mibs")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
matttbe authored and jenkins-tessares committed Jun 20, 2023
1 parent c322649 commit dd35ec1
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1683,22 +1683,23 @@ chk_add_tx_nr()
timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout)

printf "%-${nr_blank}s %s" " " "add TX"
count=$(ip netns exec $ns1 nstat -as MPTcpExtAddAddrTx | grep MPTcpExtAddAddrTx | awk '{print $2}')
[ -z "$count" ] && count=0

count=$(get_counter ${ns1} "MPTcpExtAddAddrTx")
if [ -z "$count" ]; then
echo -n "[skip]"
# if the test configured a short timeout tolerate greater then expected
# 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"
fail_test
else
echo -n "[ ok ]"
fi

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

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

printf "%-${nr_blank}s %s" " " "rm TX "
count=$(ip netns exec $ns2 nstat -as MPTcpExtRmAddrTx | grep MPTcpExtRmAddrTx | awk '{print $2}')
[ -z "$count" ] && count=0
if [ "$count" != "$rm_addr_tx_nr" ]; then
count=$(get_counter ${ns2} "MPTcpExtRmAddrTx")
if [ -z "$count" ]; then
echo "[skip]"
elif [ "$count" != "$rm_addr_tx_nr" ]; then
echo "[fail] got $count RM_ADDR[s] expected $rm_addr_tx_nr"
fail_test
else
echo -n "[ ok ]"
echo "[ ok ]"
fi

echo "$extra_msg"
}

chk_prio_nr()
Expand Down

0 comments on commit dd35ec1

Please sign in to comment.