2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-08 13:44:01 +08:00

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>
This commit is contained in:
Geliang Tang 2023-06-23 10:34:08 -07:00 committed by Jakub Kicinski
parent 4369c198e5
commit d7ced753aa

View File

@ -1832,31 +1832,26 @@ chk_subflow_nr()
chk_mptcp_info() chk_mptcp_info()
{ {
local nr_info=$1 local info1=$1
local info local exp1=$2
local info2=$3
local exp2=$4
local cnt1 local cnt1
local cnt2 local cnt2
local dump_stats local dump_stats
if [[ $nr_info = "subflows_"* ]]; then printf "%-${nr_blank}s %-30s" " " "mptcp_info $info1:$info2=$exp1:$exp2"
info="subflows"
nr_info=${nr_info:9}
else
echo "[fail] unsupported argument: $nr_info"
fail_test
return 1
fi
printf "%-${nr_blank}s %-30s" " " "mptcp_info $info=$nr_info" cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" |
sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q')
cnt1=$(ss -N $ns1 -inmHM | grep "$info:" | cnt2=$(ss -N $ns2 -inmHM | grep "$info2:" |
sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q') sed -n 's/.*\('"$info2"':\)\([[:digit:]]*\).*$/\2/p;q')
# 'ss' only display active connections and counters that are not 0.
[ -z "$cnt1" ] && cnt1=0 [ -z "$cnt1" ] && cnt1=0
cnt2=$(ss -N $ns2 -inmHM | grep "$info:" |
sed -n 's/.*\('"$info"':\)\([[:digit:]]*\).*$/\2/p;q')
[ -z "$cnt2" ] && cnt2=0 [ -z "$cnt2" ] && cnt2=0
if [ "$cnt1" != "$nr_info" ] || [ "$cnt2" != "$nr_info" ]; then
echo "[fail] got $cnt1:$cnt2 $info expected $nr_info" if [ "$cnt1" != "$exp1" ] || [ "$cnt2" != "$exp2" ]; then
echo "[fail] got $cnt1:$cnt2 $info1:$info2 expected $exp1:$exp2"
fail_test fail_test
dump_stats=1 dump_stats=1
else else
@ -3332,8 +3327,11 @@ userspace_tests()
userspace_pm_add_addr 10.0.2.1 10 userspace_pm_add_addr 10.0.2.1 10
chk_join_nr 1 1 1 chk_join_nr 1 1 1
chk_add_nr 1 1 chk_add_nr 1 1
chk_mptcp_info subflows 1 subflows 1
chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
userspace_pm_rm_sf_addr_ns1 10.0.2.1 10 userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
chk_rm_nr 1 1 invert chk_rm_nr 1 1 invert
chk_mptcp_info subflows 0 subflows 0
kill_events_pids kill_events_pids
wait $tests_pid wait $tests_pid
fi fi
@ -3348,8 +3346,10 @@ userspace_tests()
wait_mpj $ns2 wait_mpj $ns2
userspace_pm_add_sf 10.0.3.2 20 userspace_pm_add_sf 10.0.3.2 20
chk_join_nr 1 1 1 chk_join_nr 1 1 1
chk_mptcp_info subflows 1 subflows 1
userspace_pm_rm_sf_addr_ns2 10.0.3.2 20 userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
chk_rm_nr 1 1 chk_rm_nr 1 1
chk_mptcp_info subflows 0 subflows 0
kill_events_pids kill_events_pids
wait $tests_pid wait $tests_pid
fi fi
@ -3369,6 +3369,8 @@ endpoint_tests()
wait_mpj $ns1 wait_mpj $ns1
pm_nl_check_endpoint 1 "creation" \ pm_nl_check_endpoint 1 "creation" \
$ns2 10.0.2.2 id 1 flags implicit $ns2 10.0.2.2 id 1 flags implicit
chk_mptcp_info subflows 1 subflows 1
chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
pm_nl_add_endpoint $ns2 10.0.2.2 id 33 pm_nl_add_endpoint $ns2 10.0.2.2 id 33
pm_nl_check_endpoint 0 "ID change is prevented" \ pm_nl_check_endpoint 0 "ID change is prevented" \
@ -3389,17 +3391,17 @@ endpoint_tests()
wait_mpj $ns2 wait_mpj $ns2
chk_subflow_nr needtitle "before delete" 2 chk_subflow_nr needtitle "before delete" 2
chk_mptcp_info subflows_1 chk_mptcp_info subflows 1 subflows 1
pm_nl_del_endpoint $ns2 2 10.0.2.2 pm_nl_del_endpoint $ns2 2 10.0.2.2
sleep 0.5 sleep 0.5
chk_subflow_nr "" "after delete" 1 chk_subflow_nr "" "after delete" 1
chk_mptcp_info subflows_0 chk_mptcp_info subflows 0 subflows 0
pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
wait_mpj $ns2 wait_mpj $ns2
chk_subflow_nr "" "after re-add" 2 chk_subflow_nr "" "after re-add" 2
chk_mptcp_info subflows_1 chk_mptcp_info subflows 1 subflows 1
kill_tests_wait kill_tests_wait
fi fi
} }