Skip to content

Commit

Permalink
selftests: mptcp: join: skip check if MIB counter not supported
Browse files Browse the repository at this point in the history
commit 47867f0a7e831e24e5eab3330667ce9682d50fb1 upstream.

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 to do the required checks and
return an error if the counter is not available.

Note that if we expect to have these features available and if
SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var is set to 1, the tests
will be marked as failed instead of skipped.

This new helper also makes sure we get the exact counter we want to
avoid issues we had in the past, e.g. with MPTcpExtRmAddr and
MPTcpExtRmAddrDrop sharing the same prefix. While at it, we uniform the
way we fetch a MIB counter.

Note for the backports: we rarely change these modified blocks so if
there is are conflicts, it is very l(CR) because a counter is not used
in the older kernels and we don't need that chunk.

Link: multipath-tcp/mptcp_net-next#368
Fixes: b08fbf2 ("selftests: add test-cases for MPTCP MP_JOIN")
Cc: [email protected]
Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
matttbe authored and gregkh committed Jun 28, 2023
1 parent bb9add9 commit 2806036
Showing 1 changed file with 44 additions and 21 deletions.
65 changes: 44 additions & 21 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ do_ping()
fi
}

# $1: ns ; $2: counter
get_counter()
{
local ns="${1}"
local counter="${2}"
local count

count=$(ip netns exec ${ns} nstat -asz "${counter}" | awk 'NR==1 {next} {print $2}')
if [ -z "${count}" ]; then
mptcp_lib_fail_if_expected_feature "${counter} counter"
return 1
fi

echo "${count}"
}

do_transfer()
{
listener_ns="$1"
Expand Down Expand Up @@ -291,9 +307,10 @@ chk_join_nr()
local dump_stats

printf "%02u %-36s %s" "$TEST_COUNT" "$msg" "syn"
count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinSynRx | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$syn_nr" ]; then
count=$(get_counter ${ns1} "MPTcpExtMPJoinSynRx")
if [ -z "$count" ]; then
echo -n "[skip]"
elif [ "$count" != "$syn_nr" ]; then
echo "[fail] got $count JOIN[s] syn expected $syn_nr"
ret=1
dump_stats=1
Expand All @@ -302,9 +319,10 @@ chk_join_nr()
fi

echo -n " - synack"
count=`ip netns exec $ns2 nstat -as | grep MPTcpExtMPJoinSynAckRx | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$syn_ack_nr" ]; then
count=$(get_counter ${ns2} "MPTcpExtMPJoinSynAckRx")
if [ -z "$count" ]; then
echo -n "[skip]"
elif [ "$count" != "$syn_ack_nr" ]; then
echo "[fail] got $count JOIN[s] synack expected $syn_ack_nr"
ret=1
dump_stats=1
Expand All @@ -313,9 +331,10 @@ chk_join_nr()
fi

echo -n " - ack"
count=`ip netns exec $ns1 nstat -as | grep MPTcpExtMPJoinAckRx | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$ack_nr" ]; then
count=$(get_counter ${ns1} "MPTcpExtMPJoinAckRx")
if [ -z "$count" ]; then
echo "[skip]"
elif [ "$count" != "$ack_nr" ]; then
echo "[fail] got $count JOIN[s] ack expected $ack_nr"
ret=1
dump_stats=1
Expand All @@ -338,9 +357,10 @@ chk_add_nr()
local dump_stats

printf "%-39s %s" " " "add"
count=`ip netns exec $ns2 nstat -as | grep MPTcpExtAddAddr | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$add_nr" ]; then
count=$(get_counter ${ns2} "MPTcpExtAddAddr")
if [ -z "$count" ]; then
echo -n "[skip]"
elif [ "$count" != "$add_nr" ]; then
echo "[fail] got $count ADD_ADDR[s] expected $add_nr"
ret=1
dump_stats=1
Expand All @@ -349,9 +369,10 @@ chk_add_nr()
fi

echo -n " - echo "
count=`ip netns exec $ns1 nstat -as | grep MPTcpExtEchoAdd | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$echo_nr" ]; then
count=$(get_counter ${ns1} "MPTcpExtEchoAdd")
if [ -z "$count" ]; then
echo "[skip]"
elif [ "$count" != "$echo_nr" ]; then
echo "[fail] got $count ADD_ADDR echo[s] expected $echo_nr"
ret=1
dump_stats=1
Expand All @@ -375,9 +396,10 @@ chk_rm_nr()
local dump_stats

printf "%-39s %s" " " "rm "
count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$rm_addr_nr" ]; then
count=$(get_counter ${ns1} "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"
ret=1
dump_stats=1
Expand All @@ -386,9 +408,10 @@ chk_rm_nr()
fi

echo -n " - sf "
count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'`
[ -z "$count" ] && count=0
if [ "$count" != "$rm_subflow_nr" ]; then
count=$(get_counter ${ns2} "MPTcpExtRmSubflow")
if [ -z "$count" ]; then
echo "[skip]"
elif [ "$count" != "$rm_subflow_nr" ]; then
echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr"
ret=1
dump_stats=1
Expand Down

0 comments on commit 2806036

Please sign in to comment.