Commit 4369c198 authored by Geliang Tang's avatar Geliang Tang Committed by Jakub Kicinski

selftests: mptcp: test userspace pm out of transfer

This patch moves userspace pm tests out of do_transfer(). Move add address
test into a new function userspace_pm_add_addr(), and remove address test
into userspace_pm_rm_sf_addr_ns1(). Move add subflow test into
userspace_pm_add_sf() and remove subflow into
userspace_pm_rm_sf_addr_ns2().
Reviewed-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarGeliang Tang <geliang.tang@suse.com>
Signed-off-by: default avatarMat Martineau <martineau@kernel.org>
Link: https://lore.kernel.org/r/20230623-send-net-next-20230623-v1-1-a883213c8ba9@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c4015bbe
...@@ -589,6 +589,26 @@ wait_rm_addr() ...@@ -589,6 +589,26 @@ wait_rm_addr()
done done
} }
rm_sf_count()
{
get_counter "${1}" "MPTcpExtRmSubflow"
}
# $1: ns, $2: old rm_sf counter in $ns
wait_rm_sf()
{
local ns="${1}"
local old_cnt="${2}"
local cnt
local i
for i in $(seq 10); do
cnt=$(rm_sf_count ${ns})
[ "$cnt" = "${old_cnt}" ] || break
sleep 0.1
done
}
wait_mpj() wait_mpj()
{ {
local ns="${1}" local ns="${1}"
...@@ -813,7 +833,6 @@ do_transfer() ...@@ -813,7 +833,6 @@ do_transfer()
local port=$((10000 + TEST_COUNT - 1)) local port=$((10000 + TEST_COUNT - 1))
local cappid local cappid
local userspace_pm=0
:> "$cout" :> "$cout"
:> "$sout" :> "$sout"
...@@ -850,11 +869,6 @@ do_transfer() ...@@ -850,11 +869,6 @@ do_transfer()
extra_args="-r ${speed:6}" extra_args="-r ${speed:6}"
fi fi
if [[ "${addr_nr_ns1}" = "userspace_"* ]]; then
userspace_pm=1
addr_nr_ns1=${addr_nr_ns1:10}
fi
local flags="subflow" local flags="subflow"
local extra_cl_args="" local extra_cl_args=""
local extra_srv_args="" local extra_srv_args=""
...@@ -882,9 +896,6 @@ do_transfer() ...@@ -882,9 +896,6 @@ do_transfer()
return 1 return 1
fi fi
addr_nr_ns2=0 addr_nr_ns2=0
elif [[ "${addr_nr_ns2}" = "userspace_"* ]]; then
userspace_pm=1
addr_nr_ns2=${addr_nr_ns2:10}
elif [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then elif [[ "${addr_nr_ns2}" = "fullmesh_"* ]]; then
flags="${flags},fullmesh" flags="${flags},fullmesh"
addr_nr_ns2=${addr_nr_ns2:9} addr_nr_ns2=${addr_nr_ns2:9}
...@@ -938,7 +949,6 @@ do_transfer() ...@@ -938,7 +949,6 @@ do_transfer()
local counter=2 local counter=2
local add_nr_ns1=${addr_nr_ns1} local add_nr_ns1=${addr_nr_ns1}
local id=10 local id=10
local tk
while [ $add_nr_ns1 -gt 0 ]; do while [ $add_nr_ns1 -gt 0 ]; do
local addr local addr
if is_v6 "${connect_addr}"; then if is_v6 "${connect_addr}"; then
...@@ -946,24 +956,7 @@ do_transfer() ...@@ -946,24 +956,7 @@ do_transfer()
else else
addr="10.0.$counter.1" addr="10.0.$counter.1"
fi fi
if [ $userspace_pm -eq 0 ]; then pm_nl_add_endpoint $ns1 $addr flags signal
pm_nl_add_endpoint $ns1 $addr flags signal
else
tk=$(grep "type:1," "$evts_ns1" |
sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec ${listener_ns} ./pm_nl_ctl ann $addr token $tk id $id
sleep 1
sp=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
da=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q')
dp=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec ${listener_ns} ./pm_nl_ctl rem token $tk id $id
ip netns exec ${listener_ns} ./pm_nl_ctl dsf lip "::ffff:$addr" \
lport $sp rip $da rport $dp token $tk
fi
counter=$((counter + 1)) counter=$((counter + 1))
add_nr_ns1=$((add_nr_ns1 - 1)) add_nr_ns1=$((add_nr_ns1 - 1))
id=$((id + 1)) id=$((id + 1))
...@@ -1008,7 +1001,6 @@ do_transfer() ...@@ -1008,7 +1001,6 @@ do_transfer()
local add_nr_ns2=${addr_nr_ns2} local add_nr_ns2=${addr_nr_ns2}
local counter=3 local counter=3
local id=20 local id=20
local tk da dp sp
while [ $add_nr_ns2 -gt 0 ]; do while [ $add_nr_ns2 -gt 0 ]; do
local addr local addr
if is_v6 "${connect_addr}"; then if is_v6 "${connect_addr}"; then
...@@ -1016,21 +1008,7 @@ do_transfer() ...@@ -1016,21 +1008,7 @@ do_transfer()
else else
addr="10.0.$counter.2" addr="10.0.$counter.2"
fi fi
if [ $userspace_pm -eq 0 ]; then pm_nl_add_endpoint $ns2 $addr flags $flags
pm_nl_add_endpoint $ns2 $addr flags $flags
else
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
ip netns exec ${connector_ns} ./pm_nl_ctl csf lip $addr lid $id \
rip $da rport $dp token $tk
sleep 1
sp=$(grep "type:10" "$evts_ns2" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec ${connector_ns} ./pm_nl_ctl rem token $tk id $id
ip netns exec ${connector_ns} ./pm_nl_ctl dsf lip $addr lport $sp \
rip $da rport $dp token $tk
fi
counter=$((counter + 1)) counter=$((counter + 1))
add_nr_ns2=$((add_nr_ns2 - 1)) add_nr_ns2=$((add_nr_ns2 - 1))
id=$((id + 1)) id=$((id + 1))
...@@ -3205,6 +3183,71 @@ fail_tests() ...@@ -3205,6 +3183,71 @@ fail_tests()
fi fi
} }
userspace_pm_add_addr()
{
local addr=$1
local id=$2
local tk
tk=$(grep "type:1," "$evts_ns1" |
sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec $ns1 ./pm_nl_ctl ann $addr token $tk id $id
sleep 1
}
userspace_pm_rm_sf_addr_ns1()
{
local addr=$1
local id=$2
local tk sp da dp
tk=$(grep "type:1," "$evts_ns1" |
sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
sp=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
da=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q')
dp=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec $ns1 ./pm_nl_ctl rem token $tk id $id
ip netns exec $ns1 ./pm_nl_ctl dsf lip "::ffff:$addr" \
lport $sp rip $da rport $dp token $tk
wait_rm_addr $ns1 1
wait_rm_sf $ns1 1
}
userspace_pm_add_sf()
{
local addr=$1
local id=$2
local tk da dp
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
ip netns exec $ns2 ./pm_nl_ctl csf lip $addr lid $id \
rip $da rport $dp token $tk
sleep 1
}
userspace_pm_rm_sf_addr_ns2()
{
local addr=$1
local id=$2
local tk da dp sp
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
sp=$(grep "type:10" "$evts_ns2" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
ip netns exec $ns2 ./pm_nl_ctl rem token $tk id $id
ip netns exec $ns2 ./pm_nl_ctl dsf lip $addr lport $sp \
rip $da rport $dp token $tk
wait_rm_addr $ns2 1
wait_rm_sf $ns2 1
}
userspace_tests() userspace_tests()
{ {
# userspace pm type prevents add_addr # userspace pm type prevents add_addr
...@@ -3283,11 +3326,16 @@ userspace_tests() ...@@ -3283,11 +3326,16 @@ userspace_tests()
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
set_userspace_pm $ns1 set_userspace_pm $ns1
pm_nl_set_limits $ns2 1 1 pm_nl_set_limits $ns2 1 1
run_tests $ns1 $ns2 10.0.1.1 0 userspace_1 0 slow run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10 &
local tests_pid=$!
wait_mpj $ns1
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
userspace_pm_rm_sf_addr_ns1 10.0.2.1 10
chk_rm_nr 1 1 invert chk_rm_nr 1 1 invert
kill_events_pids kill_events_pids
wait $tests_pid
fi fi
# userspace pm create destroy subflow # userspace pm create destroy subflow
...@@ -3295,10 +3343,15 @@ userspace_tests() ...@@ -3295,10 +3343,15 @@ userspace_tests()
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
set_userspace_pm $ns2 set_userspace_pm $ns2
pm_nl_set_limits $ns1 0 1 pm_nl_set_limits $ns1 0 1
run_tests $ns1 $ns2 10.0.1.1 0 0 userspace_1 slow run_tests $ns1 $ns2 10.0.1.1 0 0 0 speed_10 &
local tests_pid=$!
wait_mpj $ns2
userspace_pm_add_sf 10.0.3.2 20
chk_join_nr 1 1 1 chk_join_nr 1 1 1
userspace_pm_rm_sf_addr_ns2 10.0.3.2 20
chk_rm_nr 1 1 chk_rm_nr 1 1
kill_events_pids kill_events_pids
wait $tests_pid
fi fi
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment