[PATCH mptcp-next v4 4/9] selftests: mptcp: add change_address helper

Geliang Tang posted 9 patches 1 year, 10 months ago
[PATCH mptcp-next v4 4/9] selftests: mptcp: add change_address helper
Posted by Geliang Tang 1 year, 10 months ago
From: Geliang Tang <tanggeliang@kylinos.cn>

The address that needs to change flags can only be identified by an address
ID in change_endpoint() helper. This patch adds another helper named
change_address(), its 2nd parameter is an IP address.

Usage:
	Address ID - change_endpoint $ns id $id $flags
	IP address - change_address $ns $addr $flags

Use this new helper in pm_netlink.sh to replace all 'pm_nl_ctl set'
commands.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index ff4355db03cd..08b78007e8c1 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -74,6 +74,17 @@ get_endpoint() {
 	mptcp_lib_pm_nl_get_endpoint "${ns1}" "${@}"
 }
 
+change_address() {
+	local addr=${1}
+	local flags=${2}
+
+	if mptcp_lib_is_ip_mptcp; then
+		ip -n "${ns1}" mptcp endpoint change "${addr}" "${flags}"
+	else
+		ip netns exec "${ns1}" ./pm_nl_ctl set "${addr}" flags "${flags}"
+	fi
+}
+
 check()
 {
 	local cmd="$1"
@@ -196,10 +207,10 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
 
 ip netns exec $ns1 ./pm_nl_ctl flush
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow
-ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags backup
+change_address 10.0.1.1 backup
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
 	"set flags (backup)"
-ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
+change_address 10.0.1.1 nobackup
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \
 	"          (nobackup)"
 
-- 
2.40.1
Re: [PATCH mptcp-next v4 4/9] selftests: mptcp: add change_address helper
Posted by Matthieu Baerts 1 year, 10 months ago
Hi Geliang,

On 19/03/2024 08:16, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The address that needs to change flags can only be identified by an address
> ID in change_endpoint() helper. This patch adds another helper named
> change_address(), its 2nd parameter is an IP address.
> 
> Usage:
> 	Address ID - change_endpoint $ns id $id $flags
> 	IP address - change_address $ns $addr $flags

It is confusing, there is no 'change_endpoint' helper.

> 
> Use this new helper in pm_netlink.sh to replace all 'pm_nl_ctl set'
> commands.

(...)

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.