diff mbox series

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

Message ID 07d8d4f6ea1988bb56bca312c112deea1fd3e2c4.1710832493.git.tanggeliang@kylinos.cn (mailing list archive)
State Accepted, archived
Commit d4812471cbd3ee02d146a7e967a41dbf861fb824
Delegated to: Matthieu Baerts
Headers show
Series add helpers and vars in mptcp_lib.sh, final | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 29 lines checked
matttbe/shellcheck fail ShellCheck issues: pm_netlink.sh
matttbe/KVM_Validation__normal success Success! ✅
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang March 19, 2024, 7:16 a.m. UTC
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(-)

Comments

Matthieu Baerts (NGI0) March 19, 2024, 5:01 p.m. UTC | #1
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
diff mbox series

Patch

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)"