Skip to content

Commit d7ced75

Browse files
geliangtangkuba-moo
authored andcommitted
selftests: mptcp: check subflow and addr infos
New MPTCP info are being checked in multiple places to improve the code coverage when using the userspace PM. This patch makes chk_mptcp_info() more generic to be able to check subflows, add_addr_signal and add_addr_accepted info (and even more later). New arguments are now required to get different infos from the two namespaces because some counters are specific to the client or the server. Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Mat Martineau <martineau@kernel.org> Link: https://lore.kernel.org/r/20230623-send-net-next-20230623-v1-2-a883213c8ba9@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4369c19 commit d7ced75

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,31 +1832,26 @@ chk_subflow_nr()
18321832

18331833
chk_mptcp_info()
18341834
{
1835-
local nr_info=$1
1836-
local info
1835+
local info1=$1
1836+
local exp1=$2
1837+
local info2=$3
1838+
local exp2=$4
18371839
local cnt1
18381840
local cnt2
18391841
local dump_stats
18401842

1841-
if [[ $nr_info = "subflows_"* ]]; then
1842-
info="subflows"
1843-
nr_info=${nr_info:9}
1844-
else
1845-
echo "[fail] unsupported argument: $nr_info"
1846-
fail_test
1847-
return 1
1848-
fi
1849-
1850-
printf "%-${nr_blank}s %-30s" " " "mptcp_info $info=$nr_info"
1843+
printf "%-${nr_blank}s %-30s" " " "mptcp_info $info1:$info2=$exp1:$exp2"
18511844

1852-
cnt1=$(ss -N $ns1 -inmHM | grep "$info:" |
1853-
sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
1845+
cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" |
1846+
sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q')
1847+
cnt2=$(ss -N $ns2 -inmHM | grep "$info2:" |
1848+
sed -n 's/.*\('"$info2"':\)\([[:digit:]]*\).*$/\2/p;q')
1849+
# 'ss' only display active connections and counters that are not 0.
18541850
[ -z "$cnt1" ] && cnt1=0
1855-
cnt2=$(ss -N $ns2 -inmHM | grep "$info:" |
1856-
sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
18571851
[ -z "$cnt2" ] && cnt2=0
1858-
if [ "$cnt1" != "$nr_info" ] || [ "$cnt2" != "$nr_info" ]; then
1859-
echo "[fail] got $cnt1:$cnt2 $info expected $nr_info"
1852+
1853+
if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then
1854+
echo "[fail] got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2"
18601855
fail_test
18611856
dump_stats=1
18621857
else
@@ -3332,8 +3327,11 @@ userspace_tests()
33323327
userspace_pm_add_addr 10.0.2.1 10
33333328
chk_join_nr 1 1 1
33343329
chk_add_nr 1 1
3330+
chk_mptcp_info subflows 1 subflows 1
3331+
chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
33353332
userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
33363333
chk_rm_nr 1 1 invert
3334+
chk_mptcp_info subflows 0 subflows 0
33373335
kill_events_pids
33383336
wait $tests_pid
33393337
fi
@@ -3348,8 +3346,10 @@ userspace_tests()
33483346
wait_mpj $ns2
33493347
userspace_pm_add_sf 10.0.3.2 20
33503348
chk_join_nr 1 1 1
3349+
chk_mptcp_info subflows 1 subflows 1
33513350
userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
33523351
chk_rm_nr 1 1
3352+
chk_mptcp_info subflows 0 subflows 0
33533353
kill_events_pids
33543354
wait $tests_pid
33553355
fi
@@ -3369,6 +3369,8 @@ endpoint_tests()
33693369
wait_mpj $ns1
33703370
pm_nl_check_endpoint 1 "creation" \
33713371
$ns2 10.0.2.2 id 1 flags implicit
3372+
chk_mptcp_info subflows 1 subflows 1
3373+
chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
33723374

33733375
pm_nl_add_endpoint $ns2 10.0.2.2 id 33
33743376
pm_nl_check_endpoint 0 "ID change is prevented" \
@@ -3389,17 +3391,17 @@ endpoint_tests()
33893391

33903392
wait_mpj $ns2
33913393
chk_subflow_nr needtitle "before delete" 2
3392-
chk_mptcp_info subflows_1
3394+
chk_mptcp_info subflows 1 subflows 1
33933395

33943396
pm_nl_del_endpoint $ns2 2 10.0.2.2
33953397
sleep 0.5
33963398
chk_subflow_nr "" "after delete" 1
3397-
chk_mptcp_info subflows_0
3399+
chk_mptcp_info subflows 0 subflows 0
33983400

33993401
pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
34003402
wait_mpj $ns2
34013403
chk_subflow_nr "" "after re-add" 2
3402-
chk_mptcp_info subflows_1
3404+
chk_mptcp_info subflows 1 subflows 1
34033405
kill_tests_wait
34043406
fi
34053407
}

0 commit comments

Comments
 (0)