Add two more versatile helpers for userspace pm remove subflow or address:
userspace_pm_rm_addr() and userspace_pm_rm_sf(). The original test helpers
userspace_pm_rm_sf_addr_ns1() and userspace_pm_rm_sf_addr_ns2() can be
replaced by these new helpers.
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 59 +++++++++----------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 3e2745717913..2017f14408b5 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3277,25 +3277,17 @@ userspace_pm_add_addr()
sleep 1
}
-userspace_pm_rm_sf_addr_ns1()
+# $1: ns ; $2: id
+userspace_pm_rm_addr()
{
- 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
+ local evts=$evts_ns1
+ local tk
+
+ [ "$1" == "$ns2" ] && evts=$evts_ns2
+ tk=$(evts_get_info token "$evts")
+
+ ip netns exec $1 ./pm_nl_ctl rem token $tk id $2
+ wait_rm_addr $1 1
}
# $1: ns ; $2: addr ; $3: id
@@ -3314,22 +3306,23 @@ userspace_pm_add_sf()
sleep 1
}
-userspace_pm_rm_sf_addr_ns2()
+# $1: ns ; $2: event type ; $3: addr
+userspace_pm_rm_sf()
{
- local addr=$1
- local id=$2
+ local evts=$evts_ns1
+ local ip=4
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 \
+ [ "$1" == "$ns2" ] && evts=$evts_ns2
+ if is_v6 $3; then ip=6; fi
+ tk=$(evts_get_info token "$evts")
+ da=$(evts_get_info "daddr$ip" "$evts" "$2")
+ dp=$(evts_get_info dport "$evts" "$2")
+ sp=$(evts_get_info sport "$evts" "$2")
+
+ ip netns exec $1 ./pm_nl_ctl dsf lip $3 lport $sp \
rip $da rport $dp token $tk
- wait_rm_addr $ns2 1
- wait_rm_sf $ns2 1
+ wait_rm_sf $1 1
}
userspace_tests()
@@ -3421,7 +3414,8 @@ userspace_tests()
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_addr $ns1 10
+ userspace_pm_rm_sf $ns1 10 "::ffff:10.0.2.1"
chk_rm_nr 1 1 invert
chk_mptcp_info subflows 0 subflows 0
kill_events_pids
@@ -3440,7 +3434,8 @@ userspace_tests()
userspace_pm_add_sf $ns2 10.0.3.2 20
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_addr $ns2 20
+ userspace_pm_rm_sf $ns2 10 10.0.3.2
chk_rm_nr 1 1
chk_mptcp_info subflows 0 subflows 0
kill_events_pids
--
2.35.3