Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 16ac627

Browse files
geliangtanggregkh
authored andcommitted
selftests: mptcp: add chk_subflows_total helper
commit 8077541 upstream. This patch adds a new helper chk_subflows_total(), in it use the newly added counter mptcpi_subflows_total to get the "correct" amount of subflows, including the initial one. To be compatible with old 'ss' or kernel versions not supporting this counter, get the total subflows by listing TCP connections that are MPTCP subflows: ss -ti state state established state syn-sent state syn-recv | grep -c tcp-ulp-mptcp. Reviewed-by: Matthieu Baerts <matttbe@kernel.org> Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Mat Martineau <martineau@kernel.org> Link: https://lore.kernel.org/r/20231128-send-net-next-2023107-v4-3-8d6b94150f6b@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 21dada9 commit 16ac627

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ chk_mptcp_info()
18431843
local cnt2
18441844
local dump_stats
18451845

1846-
print_check "mptcp_info ${info1:0:8}=$exp1:$exp2"
1846+
print_check "mptcp_info ${info1:0:15}=$exp1:$exp2"
18471847

18481848
cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1")
18491849
cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2")
@@ -1864,6 +1864,42 @@ chk_mptcp_info()
18641864
fi
18651865
}
18661866

1867+
# $1: subflows in ns1 ; $2: subflows in ns2
1868+
# number of all subflows, including the initial subflow.
1869+
chk_subflows_total()
1870+
{
1871+
local cnt1
1872+
local cnt2
1873+
local info="subflows_total"
1874+
local dump_stats
1875+
1876+
# if subflows_total counter is supported, use it:
1877+
if [ -n "$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value $info $info)" ]; then
1878+
chk_mptcp_info $info $1 $info $2
1879+
return
1880+
fi
1881+
1882+
print_check "$info $1:$2"
1883+
1884+
# if not, count the TCP connections that are in fact MPTCP subflows
1885+
cnt1=$(ss -N $ns1 -ti state established state syn-sent state syn-recv |
1886+
grep -c tcp-ulp-mptcp)
1887+
cnt2=$(ss -N $ns2 -ti state established state syn-sent state syn-recv |
1888+
grep -c tcp-ulp-mptcp)
1889+
1890+
if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then
1891+
fail_test "got subflows $cnt1:$cnt2 expected $1:$2"
1892+
dump_stats=1
1893+
else
1894+
print_ok
1895+
fi
1896+
1897+
if [ "$dump_stats" = 1 ]; then
1898+
ss -N $ns1 -ti
1899+
ss -N $ns2 -ti
1900+
fi
1901+
}
1902+
18671903
chk_link_usage()
18681904
{
18691905
local ns=$1
@@ -3407,10 +3443,12 @@ userspace_tests()
34073443
chk_join_nr 1 1 1
34083444
chk_add_nr 1 1
34093445
chk_mptcp_info subflows 1 subflows 1
3446+
chk_subflows_total 2 2
34103447
chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
34113448
userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
34123449
chk_rm_nr 1 1 invert
34133450
chk_mptcp_info subflows 0 subflows 0
3451+
chk_subflows_total 1 1
34143452
kill_events_pids
34153453
mptcp_lib_kill_wait $tests_pid
34163454
fi
@@ -3427,9 +3465,11 @@ userspace_tests()
34273465
userspace_pm_add_sf 10.0.3.2 20
34283466
chk_join_nr 1 1 1
34293467
chk_mptcp_info subflows 1 subflows 1
3468+
chk_subflows_total 2 2
34303469
userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
34313470
chk_rm_nr 1 1
34323471
chk_mptcp_info subflows 0 subflows 0
3472+
chk_subflows_total 1 1
34333473
kill_events_pids
34343474
mptcp_lib_kill_wait $tests_pid
34353475
fi

0 commit comments

Comments
 (0)