Skip to contentSkip to conversation

add helpers and vars in mptcp_lib.sh, final

PATCH Superseded Geliang Tang 3 participants 22 messages Mar 11, 2024 – Mar 16, 2024

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Geliang Tang

author reviewer
#0 lore raw

cover add helpers and vars in mptcp_lib.sh, final

From: Geliang Tang <[email protected]>

This is the last part for "add helpers and vars in mptcp_lib.sh" series, add endpoint operation helpers into mptcp_lib.sh.

Geliang Tang (10):
selftests: mptcp: export ip_mptcp to mptcp_lib
selftests: mptcp: get support for limits
selftests: mptcp: id support for show_endpoints
selftests: mptcp: addr support for change_endpoint
selftests: mptcp: netlink: fix positions of newline
selftests: mptcp: netlink: add outputs for ip_mptcp
selftests: mptcp: add endpoint_ops API helper
selftests: mptcp: use mptcp_lib_endpoint_ops
selftests: mptcp: add ip_mptcp option for more scripts
selftests: mptcp: netlink: drop disable=SC2086

 .../testing/selftests/net/mptcp/mptcp_join.sh | 108 ++-----
 .../testing/selftests/net/mptcp/mptcp_lib.sh  | 166 ++++++++++
 .../selftests/net/mptcp/mptcp_sockopt.sh      |  34 ++-
 .../testing/selftests/net/mptcp/pm_netlink.sh | 288 +++++++++++-------
 .../selftests/net/mptcp/simult_flows.sh       |  14 +-
 5 files changed, 401 insertions(+), 209 deletions(-)
Signature · 1 line
2.40.1
author reviewer
#1 lore raw

PATCH 1/10 selftests: mptcp: export ip_mptcp to mptcp_lib

From: Geliang Tang <[email protected]>

This patch exports ip_mptcp into mptcp_lib.sh as a public variable, named mptcp_lib_ip_mptcp. Add a helper mptcp_lib_set_ip_mptcp() to set it, and a helper mptcp_lib_is_ip_mptcp() to test whether it is set. Use these two helpers in mptcp_join.sh.

This patch is prepared for coming commits.

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 17 ++++++++---------
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  | 13 +++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +8 -9
index 5e9211e89825..7fd32f645650 100755
@@ -31,7 +31,6 @@ timeout_poll=30
 timeout_test=$((timeout_poll * 2 + 1))
 capture=false
 checksum=false
-ip_mptcp=0
 check_invert=0
 validate_checksum=false
 init=0
@@ -610,7 +609,7 @@ pm_nl_set_limits()
 	local addrs=$2
 	local subflows=$3
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
 	else
 		ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
@@ -650,7 +649,7 @@ pm_nl_add_endpoint()
 		nr=$((nr + 1))
 	done
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
 	else
 		ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
@@ -663,7 +662,7 @@ pm_nl_del_endpoint()
 	local id=$2
 	local addr=$3
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		[ $id -ne 0 ] && addr=''
 		ip -n $ns mptcp endpoint delete id $id $addr
 	else
@@ -675,7 +674,7 @@ pm_nl_flush_endpoint()
 {
 	local ns=$1
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		ip -n $ns mptcp endpoint flush
 	else
 		ip netns exec $ns ./pm_nl_ctl flush
@@ -686,7 +685,7 @@ pm_nl_show_endpoints()
 {
 	local ns=$1
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		ip -n $ns mptcp endpoint show
 	else
 		ip netns exec $ns ./pm_nl_ctl dump
@@ -699,7 +698,7 @@ pm_nl_change_endpoint()
 	local id=$2
 	local flags=$3
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
 	else
 		ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
@@ -749,7 +748,7 @@ pm_nl_check_endpoint()
 		return
 	fi
 
-	if [ $ip_mptcp -eq 1 ]; then
+	if mptcp_lib_is_ip_mptcp; then
 		# get line and trim trailing whitespace
 		line=$(ip -n $ns mptcp endpoint show $id)
 		line="${line% }"
@@ -3700,7 +3699,7 @@ while getopts "${all_tests_args}cCih" opt; do
 			checksum=true
 			;;
 		i)
-			ip_mptcp=1
+			mptcp_lib_set_ip_mptcp
 			;;
 		h)
 			usage
tools/testing/selftests/net/mptcp/mptcp_lib.sh +13 -0
index d529b4b37af8..d84f2f4986a7 100644
@@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=()
 MPTCP_LIB_SUBTESTS_DUPLICATED=0
 MPTCP_LIB_TEST_COUNTER=0
 MPTCP_LIB_TEST_FORMAT="%02u %-50s"
+mptcp_lib_ip_mptcp=0
 
 # only if supported (or forced) and not disabled, see no-color.org
 if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
@@ -505,3 +506,15 @@ mptcp_lib_verify_listener_events() {
 	mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}"
 	return "${rc}"
 }
+
+mptcp_lib_set_ip_mptcp() {
+	: "${mptcp_lib_ip_mptcp:?}"
+
+	mptcp_lib_ip_mptcp=1
+}
+
+mptcp_lib_is_ip_mptcp() {
+	: "${mptcp_lib_ip_mptcp:?}"
+
+	[ ${mptcp_lib_ip_mptcp} -eq 1 ]
+}
Signature · 1 line
2.40.1
maintainer
#2 lore raw

Re: [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib

Hi Geliang,

Quoted 8 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This patch exports ip_mptcp into mptcp_lib.sh as a public variable, named mptcp_lib_ip_mptcp. Add a helper mptcp_lib_set_ip_mptcp() to set it, and a helper mptcp_lib_is_ip_mptcp() to test whether it is set. Use these two helpers in mptcp_join.sh.

This patch is prepared for coming commits.

(...)

tools/testing/selftests/net/mptcp/mptcp_lib.sh MPTCP_LIB_SUBTESTS=() · line 26

Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1 -0
index d529b4b37af8..d84f2f4986a7 100644
@@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=()
 MPTCP_LIB_SUBTESTS_DUPLICATED=0
 MPTCP_LIB_TEST_COUNTER=0
 MPTCP_LIB_TEST_FORMAT="%02u %-50s"
+mptcp_lib_ip_mptcp=0

Please use capital letters for these global variables, like the other ones here above.

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_verify_listener_events() { · line 511

Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +3 -0
 # only if supported (or forced) and not disabled, see no-color.org
 if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
@@ -505,3 +506,15 @@ mptcp_lib_verify_listener_events() {
 	mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}"
 	return "${rc}"
 }
+
+mptcp_lib_set_ip_mptcp() {
+	: "${mptcp_lib_ip_mptcp:?}"

I don't think you need that, the variable is declared in the same file. (and you are going to modify it anyway, no "read")

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_verify_listener_events() { · line 517

Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -0
+	mptcp_lib_ip_mptcp=1
+}
+
+mptcp_lib_is_ip_mptcp() {
+	: "${mptcp_lib_ip_mptcp:?}"

Same here, not needed I think.

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_verify_listener_events() { · line 518

Quoted 2 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -0
+
+	[ ${mptcp_lib_ip_mptcp} -eq 1 ]

detail: because global variables could be modified elsewhere, I usually find it safer to use double quotes, and compare strings:

  [ "${MPTCP_LIB_IP_MPTCP}" = "1" ]

But on the other hand, this global variable is not supposed to be modified elsewhere... So up to you.

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_verify_listener_events() { · line 519

Quoted 1 line
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1 -0
+}

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#3 lore raw

PATCH 2/10 selftests: mptcp: get support for limits

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

There's only 'set limits' ability in pm_nl_set_limits(), this patch adds 'get limits' support for it as well to show the limits, and rename it as pm_nl_limits(). Then pm_nl_set_limits() can be a wrapper of it. Also add another wrapper pm_nl_get_limits() to get limits.

Usage:
Set limits - pm_nl_set_limits $ns $addrs $subflows Get limits - pm_nl_get_limits $ns

A test for 'get limits' is added in endpoint_tests().

---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +21 -2
index 7fd32f645650..8eb5cf54ea42 100755
@@ -603,19 +603,34 @@ kill_events_pids()
 	evts_ns2_pid=0
 }
 
-pm_nl_set_limits()
+pm_nl_limits()
 {
 	local ns=$1
 	local addrs=$2
 	local subflows=$3
 
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
+		local limits="limits"
+
+		if [ -n "$addrs" ] && [ -n "$subflows" ]; then
+			limits+=" set add_addr_accepted $addrs subflows $subflows"
+		fi
+		ip -n $ns mptcp $limits
 	else
 		ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
 	fi
 }
 
+pm_nl_set_limits()
+{
+	pm_nl_limits "${@}"
+}
+
+pm_nl_get_limits()
+{
+	pm_nl_limits "${@}"
+}
+
 pm_nl_add_endpoint()
 {
 	local ns=$1
@@ -3578,6 +3593,10 @@ endpoint_tests()
 	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		pm_nl_set_limits $ns1 2 2
 		pm_nl_set_limits $ns2 2 2
+		print_check "get limits"
+		local output=$'accept 2\nsubflows 2'
+		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "
+		check_output "pm_nl_get_limits ${ns1}" "${output}"
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
Signature · 1 line
2.40.1
maintainer
#4 lore raw

Re: [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits

Hi Geliang,

Quoted 44 lines · Geliang Tang

From: Geliang Tang <[email protected]>

There's only 'set limits' ability in pm_nl_set_limits(), this patch adds 'get limits' support for it as well to show the limits, and rename it as pm_nl_limits(). Then pm_nl_set_limits() can be a wrapper of it. Also add another wrapper pm_nl_get_limits() to get limits.

Usage:
Set limits - pm_nl_set_limits $ns $addrs $subflows Get limits - pm_nl_get_limits $ns

A test for 'get limits' is added in endpoint_tests().

---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +7 -2
index 7fd32f645650..8eb5cf54ea42 100755
@@ -603,19 +603,34 @@ kill_events_pids()
 	evts_ns2_pid=0
 }
 
-pm_nl_set_limits()
+pm_nl_limits()
 {
 	local ns=$1
 	local addrs=$2
 	local subflows=$3
 
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
+		local limits="limits"
+
+		if [ -n "$addrs" ] && [ -n "$subflows" ]; then
+			limits+=" set add_addr_accepted $addrs subflows $subflows"
+		fi
+		ip -n $ns mptcp $limits
 	else
 		ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
 	fi

tools/testing/selftests/net/mptcp/mptcp_join.sh kill_events_pids() · line 631

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +8 -0
 }
 
+pm_nl_set_limits()
+{
+	pm_nl_limits "${@}"
+}
+
+pm_nl_get_limits()
+{
+	pm_nl_limits "${@}"

Even if it is explained in the commit message, I find it confusing.

Is it not clearer to have dedicated functions for such simple helpers?

  pm_nl_get_limits()
  {
      local ns="${1}"
      if mptcp_lib_is_ip_mptcp; then
          ip -n "${ns}" mptcp limits
      else
          ip netns exec "${ns}" ./pm_nl_ctl limits
      fi

}

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3598

Quoted 12 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +5 -0
+}
+
 pm_nl_add_endpoint()
 {
 	local ns=$1
@@ -3578,6 +3593,10 @@ endpoint_tests()
 	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		pm_nl_set_limits $ns1 2 2
 		pm_nl_set_limits $ns2 2 2
+		print_check "get limits"
+		local output=$'accept 2\nsubflows 2'
+		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "

(maybe clearer with a dedicated helper to get the limit depending on which tool we use?)

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3599

Quoted 1 line
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+		check_output "pm_nl_get_limits ${ns1}" "${output}"

Mmh, I appreciate new tests, but I think we should only add tests that are covering new kernel code. The goal of MPTCP Join, compared to other selftests, is to check behaviours when there are multiple subflows. Here, you are validating the limits, which is already something managed by pm_netlink.sh which is dedicated to that. And this doesn't depend on how many subflows are established.

So I think we should drop the patch. WDYT?

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3602

Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#5 lore raw

PATCH 3/10 selftests: mptcp: id support for show_endpoints

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

All endpoints are showed in pm_nl_show_endpoints(). This patch adds support for showing a specofic endpoint identified by the given address ID.

Usage:
All endpoints - pm_nl_show_endpoints $ns One endpoint - pm_nl_show_endpoints $ns $id

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +13 -2
index 8eb5cf54ea42..e33a136aef8e 100755
@@ -699,11 +699,18 @@ pm_nl_flush_endpoint()
 pm_nl_show_endpoints()
 {
 	local ns=$1
+	local id=$2
 
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint show
+		local show="show"
+
+		[ -n "$id" ] && show+=" id $id"
+		ip -n $ns mptcp endpoint $show
 	else
-		ip netns exec $ns ./pm_nl_ctl dump
+		local dump="dump"
+
+		[ -n "$id" ] && dump="get $id"
+		ip netns exec $ns ./pm_nl_ctl $dump
 	fi
 }
 
@@ -3598,6 +3605,10 @@ endpoint_tests()
 		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "
 		check_output "pm_nl_get_limits ${ns1}" "${output}"
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
+		print_check "show id 1 addr"
+		output="id 1 flags signal 10.0.2.1"
+		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
+		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!
Signature · 1 line
2.40.1
maintainer
#6 lore raw

Re: [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints

Hi Geliang,

Quoted 40 lines · Geliang Tang

From: Geliang Tang <[email protected]>

All endpoints are showed in pm_nl_show_endpoints(). This patch adds support for showing a specofic endpoint identified by the given address ID.

Usage:
All endpoints - pm_nl_show_endpoints $ns One endpoint - pm_nl_show_endpoints $ns $id

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +9 -2
index 8eb5cf54ea42..e33a136aef8e 100755
@@ -699,11 +699,18 @@ pm_nl_flush_endpoint()
 pm_nl_show_endpoints()
 {
 	local ns=$1
+	local id=$2
 
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint show
+		local show="show"
+
+		[ -n "$id" ] && show+=" id $id"
+		ip -n $ns mptcp endpoint $show
 	else
-		ip netns exec $ns ./pm_nl_ctl dump
+		local dump="dump"
+
+		[ -n "$id" ] && dump="get $id"
+		ip netns exec $ns ./pm_nl_ctl $dump
 	fi
 }
 

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3611

Quoted 7 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +4 -0
@@ -3598,6 +3605,10 @@ endpoint_tests()
 		mptcp_lib_is_ip_mptcp && output="add_addr_accepted 2 subflows 2 "
 		check_output "pm_nl_get_limits ${ns1}" "${output}"
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
+		print_check "show id 1 addr"
+		output="id 1 flags signal 10.0.2.1"
+		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
+		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"

Same here, that's already validated in pm_netlink.sh, no need to duplicate the test validating the same kernel code path. WDYT?

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3614

Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#7 lore raw

PATCH 4/10 selftests: mptcp: addr support for change_endpoint

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

The address that needs to change flags can only be identified by an address ID in pm_nl_change_endpoint(). This patch adds support for passing an IP address directly to this helper.

Address ID:
pm_nl_change_endpoint $ns id $id $flags

IP address:
pm_nl_change_endpoint $ns $addr $flags

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++++++++---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  |  5 +++++
 2 files changed, 17 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +12 -3
index e33a136aef8e..431233e25abc 100755
@@ -717,13 +717,17 @@ pm_nl_show_endpoints()
 pm_nl_change_endpoint()
 {
 	local ns=$1
-	local id=$2
+	local addr=$2
 	local flags=$3
 
+	if ! mptcp_lib_is_addr "$addr"; then
+		[ $addr -gt 0 ] && [ $addr -lt 256 ] && addr="id $addr"
+	fi
+
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
+		ip -n $ns mptcp endpoint change $addr ${flags//","/" "}
 	else
-		ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
+		ip netns exec $ns ./pm_nl_ctl set $addr flags $flags
 	fi
 }
 
@@ -3609,6 +3613,11 @@ endpoint_tests()
 		output="id 1 flags signal 10.0.2.1"
 		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
 		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"
+		pm_nl_change_endpoint ${ns1} 1 backup
+		print_check "change id 1 addr"
+		output="id 1 flags signal,backup 10.0.2.1"
+		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal backup "
+		check_output "pm_nl_show_endpoints ${ns1}" "${output}"
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -0
index d84f2f4986a7..c465f1d59419 100644
@@ -284,6 +284,11 @@ mptcp_lib_is_v6() {
 	[ -z "${1##*:*}" ]
 }
 
+# $1: IP address
+mptcp_lib_is_addr() {
+	[ -z "${1##*.*}" ] || [ -z "${1##*:*}" ]
+}
+
 # $1: ns, $2: MIB counter
 mptcp_lib_get_counter() {
 	local ns="${1}"
Signature · 1 line
2.40.1
maintainer
#8 lore raw

Re: [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint

Hi Geliang,

Quoted 44 lines · Geliang Tang

From: Geliang Tang <[email protected]>

The address that needs to change flags can only be identified by an address ID in pm_nl_change_endpoint(). This patch adds support for passing an IP address directly to this helper.

Address ID:
pm_nl_change_endpoint $ns id $id $flags

IP address:
pm_nl_change_endpoint $ns $addr $flags

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++++++++---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  |  5 +++++
 2 files changed, 17 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +7 -3
index e33a136aef8e..431233e25abc 100755
@@ -717,13 +717,17 @@ pm_nl_show_endpoints()
 pm_nl_change_endpoint()
 {
 	local ns=$1
-	local id=$2
+	local addr=$2
 	local flags=$3
 
+	if ! mptcp_lib_is_addr "$addr"; then
+		[ $addr -gt 0 ] && [ $addr -lt 256 ] && addr="id $addr"
+	fi
+
 	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
+		ip -n $ns mptcp endpoint change $addr ${flags//","/" "}
 	else
-		ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
+		ip netns exec $ns ./pm_nl_ctl set $addr flags $flags
 	fi
 }
 

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3620

Quoted 8 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +5 -0
@@ -3609,6 +3613,11 @@ endpoint_tests()
 		output="id 1 flags signal 10.0.2.1"
 		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal "
 		check_output "pm_nl_show_endpoints ${ns1} 1" "${output}"
+		pm_nl_change_endpoint ${ns1} 1 backup
+		print_check "change id 1 addr"
+		output="id 1 flags signal,backup 10.0.2.1"
+		mptcp_lib_is_ip_mptcp && output="10.0.2.1 id 1 signal backup "
+		check_output "pm_nl_show_endpoints ${ns1}" "${output}"

I feel like here as well, that's something already validated in pm_netlink.sh, and this will not check anything new, no?

tools/testing/selftests/net/mptcp/mptcp_join.sh endpoint_tests() · line 3623

Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
 		speed=slow \
 			run_tests $ns1 $ns2 10.0.1.1 &
 		local tests_pid=$!

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#9 lore raw

PATCH 5/10 selftests: mptcp: netlink: fix positions of newline

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Some positions of the new line are arranged a bit strangely in script pm_netlink.sh. For example, the output of 'pm_nl_ctl limits':

"accept 0
subflows 2" "defaults limits"

This one can be refactored using $'...\n...':

$'accept 0\nsubflows 2' "defaults limits"

For longer output results, such as the output of 'pm_nl_ctl dump':

                                        "id 1 flags  10.0.1.1

id 3 flags signal,backup 10.0.1.3 id 4 flags signal 10.0.1.4
id 5 flags signal 10.0.1.5
id 6 flags signal 10.0.1.6
id 7 flags signal 10.0.1.7
id 8 flags signal 10.0.1.8" "id limit"

This one can be refactored using "$(printf '%s\n' "..." "...")":

        "$(printf '%s\n' \
	"id 1 flags  10.0.1.1" \
        "id 3 flags signal,backup 10.0.1.3" \
        "id 4 flags signal 10.0.1.4" \
	"id 5 flags signal 10.0.1.5" \
        "id 6 flags signal 10.0.1.6" \
        "id 7 flags signal 10.0.1.7" \
	"id 8 flags signal 10.0.1.8")" \
        "id limit"

This patch uses such methods to rearrange the outputs into different lines.

---
 .../testing/selftests/net/mptcp/pm_netlink.sh | 101 ++++++++++--------
 1 file changed, 56 insertions(+), 45 deletions(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +56 -45
index 6ab8c5d36340..00949f73153a 100755
@@ -71,36 +71,41 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
 
 default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)"
 if mptcp_lib_expect_all_features; then
-	check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0
-subflows 2" "defaults limits"
+	limits=$'accept 0\nsubflows 2'
+	check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "defaults limits"
 fi
 
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup
-check "ip netns exec $ns1 ./pm_nl_ctl get 1" "id 1 flags  10.0.1.1" "simple add/get addr"
+endpoint="id 1 flags  10.0.1.1"
+check "ip netns exec $ns1 ./pm_nl_ctl get 1" "${endpoint}" "simple add/get addr"
 
+dump="$(printf '%s\n' \
+	"id 1 flags  10.0.1.1" \
+	"id 2 flags subflow dev lo 10.0.1.2" \
+	"id 3 flags signal,backup 10.0.1.3")"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" \
-"id 1 flags  10.0.1.1
-id 2 flags subflow dev lo 10.0.1.2
-id 3 flags signal,backup 10.0.1.3" "dump addrs"
+	"${dump}" "dump addrs"
 
 ip netns exec $ns1 ./pm_nl_ctl del 2
+dump=$'id 1 flags  10.0.1.1\nid 3 flags signal,backup 10.0.1.3'
 check "ip netns exec $ns1 ./pm_nl_ctl get 2" "" "simple del addr"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" \
-"id 1 flags  10.0.1.1
-id 3 flags signal,backup 10.0.1.3" "dump addrs after del"
+	"${dump}" "dump addrs after del"
 
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 2>/dev/null
 check "ip netns exec $ns1 ./pm_nl_ctl get 4" "" "duplicate addr"
 
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal
-check "ip netns exec $ns1 ./pm_nl_ctl get 4" "id 4 flags signal 10.0.1.4" "id addr increment"
+endpoint="id 4 flags signal 10.0.1.4"
+check "ip netns exec $ns1 ./pm_nl_ctl get 4" "${endpoint}" "id addr increment"
 
 for i in $(seq 5 9); do
 	ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.$i flags signal >/dev/null 2>&1
 done
-check "ip netns exec $ns1 ./pm_nl_ctl get 9" "id 9 flags signal 10.0.1.9" "hard addr limit"
+endpoint="id 9 flags signal 10.0.1.9"
+check "ip netns exec $ns1 ./pm_nl_ctl get 9" "${endpoint}" "hard addr limit"
 check "ip netns exec $ns1 ./pm_nl_ctl get 10" "" "above hard addr limit"
 
 ip netns exec $ns1 ./pm_nl_ctl del 9
@@ -108,13 +113,15 @@ for i in $(seq 10 255); do
 	ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.9 id $i
 	ip netns exec $ns1 ./pm_nl_ctl del $i
 done
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags  10.0.1.1
-id 3 flags signal,backup 10.0.1.3
-id 4 flags signal 10.0.1.4
-id 5 flags signal 10.0.1.5
-id 6 flags signal 10.0.1.6
-id 7 flags signal 10.0.1.7
-id 8 flags signal 10.0.1.8" "id limit"
+dump="$(printf '%s\n' \
+	"id 1 flags  10.0.1.1" \
+	"id 3 flags signal,backup 10.0.1.3" \
+	"id 4 flags signal 10.0.1.4" \
+	"id 5 flags signal 10.0.1.5" \
+	"id 6 flags signal 10.0.1.6" \
+	"id 7 flags signal 10.0.1.7" \
+	"id 8 flags signal 10.0.1.8")"
+check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "id limit"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs"
@@ -126,8 +133,8 @@ ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null
 check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "subflows above hard limit"
 
 ip netns exec $ns1 ./pm_nl_ctl limits 8 8
-check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8
-subflows 8" "set limits"
+limits=$'accept 8\nsubflows 8'
+check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "set limits"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
@@ -138,14 +145,16 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags  10.0.1.1
-id 2 flags  10.0.1.2
-id 3 flags  10.0.1.7
-id 4 flags  10.0.1.8
-id 100 flags  10.0.1.3
-id 101 flags  10.0.1.4
-id 254 flags  10.0.1.5
-id 255 flags  10.0.1.6" "set ids"
+dump="$(printf '%s\n' \
+	"id 1 flags  10.0.1.1" \
+	"id 2 flags  10.0.1.2" \
+	"id 3 flags  10.0.1.7" \
+	"id 4 flags  10.0.1.8" \
+	"id 100 flags  10.0.1.3" \
+	"id 101 flags  10.0.1.4" \
+	"id 254 flags  10.0.1.5" \
+	"id 255 flags  10.0.1.6")"
+check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "set ids"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1
@@ -156,36 +165,38 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags  10.0.0.1
-id 2 flags  10.0.0.4
-id 3 flags  10.0.0.6
-id 4 flags  10.0.0.7
-id 5 flags  10.0.0.8
-id 253 flags  10.0.0.5
-id 254 flags  10.0.0.2
-id 255 flags  10.0.0.3" "wrap-around ids"
+dump="$(printf '%s\n' \
+	"id 1 flags  10.0.0.1" \
+	"id 2 flags  10.0.0.4" \
+	"id 3 flags  10.0.0.6" \
+	"id 4 flags  10.0.0.7" \
+	"id 5 flags  10.0.0.8" \
+	"id 253 flags  10.0.0.5" \
+	"id 254 flags  10.0.0.2" \
+	"id 255 flags  10.0.0.3")"
+check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "wrap-around ids"
 
 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
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
-subflow,backup 10.0.1.1" "set flags (backup)"
+dump="id 1 flags subflow,backup 10.0.1.1"
+check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "set flags (backup)"
 ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
-subflow 10.0.1.1" "          (nobackup)"
+dump="id 1 flags subflow 10.0.1.1"
+check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (nobackup)"
 
 # fullmesh support has been added later
 ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null
 if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" ||
    mptcp_lib_expect_all_features; then
-	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
-subflow,fullmesh 10.0.1.1" "          (fullmesh)"
+	dump="id 1 flags subflow,fullmesh 10.0.1.1"
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (fullmesh)"
 	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
-	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
-subflow 10.0.1.1" "          (nofullmesh)"
+	dump="id 1 flags subflow 10.0.1.1"
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (nofullmesh)"
 	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
-	check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
-subflow,backup,fullmesh 10.0.1.1" "          (backup,fullmesh)"
+	dump="id 1 flags subflow,backup,fullmesh 10.0.1.1"
+	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (backup,fullmesh)"
 else
 	for st in fullmesh nofullmesh backup,fullmesh; do
 		st="          (${st})"
Signature · 1 line
2.40.1
author reviewer
#10 lore raw

PATCH 6/10 selftests: mptcp: netlink: add outputs for ip_mptcp

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

The outputs of 'ip mptcp' are different from that of 'pm_nl_ctl'. This patch adds corresponding outputs of 'ip mptcp' together with 'pm_nl_ctl'. Use mptcp_lib_is_ip_mptcp() helper to test whether ip_mptcp is set. If it it, use 'ip mptcp' format outputs for check().

---
 .../testing/selftests/net/mptcp/pm_netlink.sh | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
tools/testing/selftests/net/mptcp/pm_netlink.sh +45 -0
index 00949f73153a..2096c52b3a4b 100755
@@ -72,6 +72,7 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
 default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)"
 if mptcp_lib_expect_all_features; then
 	limits=$'accept 0\nsubflows 2'
+	mptcp_lib_is_ip_mptcp && limits="add_addr_accepted 0 subflows 2 "
 	check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "defaults limits"
 fi
 
@@ -79,17 +80,24 @@ ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup
 endpoint="id 1 flags  10.0.1.1"
+mptcp_lib_is_ip_mptcp && endpoint="10.0.1.1 id 1 "
 check "ip netns exec $ns1 ./pm_nl_ctl get 1" "${endpoint}" "simple add/get addr"
 
 dump="$(printf '%s\n' \
 	"id 1 flags  10.0.1.1" \
 	"id 2 flags subflow dev lo 10.0.1.2" \
 	"id 3 flags signal,backup 10.0.1.3")"
+mptcp_lib_is_ip_mptcp && \
+dump="$(printf '%s\n' \
+	"10.0.1.1 id 1 " \
+	"10.0.1.2 id 2 subflow dev lo " \
+	"10.0.1.3 id 3 signal backup ")"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" \
 	"${dump}" "dump addrs"
 
 ip netns exec $ns1 ./pm_nl_ctl del 2
 dump=$'id 1 flags  10.0.1.1\nid 3 flags signal,backup 10.0.1.3'
+mptcp_lib_is_ip_mptcp && dump=$'10.0.1.1 id 1 \n10.0.1.3 id 3 signal backup '
 check "ip netns exec $ns1 ./pm_nl_ctl get 2" "" "simple del addr"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" \
 	"${dump}" "dump addrs after del"
@@ -99,12 +107,14 @@ check "ip netns exec $ns1 ./pm_nl_ctl get 4" "" "duplicate addr"
 
 ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal
 endpoint="id 4 flags signal 10.0.1.4"
+mptcp_lib_is_ip_mptcp && endpoint="10.0.1.4 id 4 signal "
 check "ip netns exec $ns1 ./pm_nl_ctl get 4" "${endpoint}" "id addr increment"
 
 for i in $(seq 5 9); do
 	ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.$i flags signal >/dev/null 2>&1
 done
 endpoint="id 9 flags signal 10.0.1.9"
+mptcp_lib_is_ip_mptcp && endpoint="10.0.1.9 id 9 signal "
 check "ip netns exec $ns1 ./pm_nl_ctl get 9" "${endpoint}" "hard addr limit"
 check "ip netns exec $ns1 ./pm_nl_ctl get 10" "" "above hard addr limit"
 
@@ -121,6 +131,15 @@ dump="$(printf '%s\n' \
 	"id 6 flags signal 10.0.1.6" \
 	"id 7 flags signal 10.0.1.7" \
 	"id 8 flags signal 10.0.1.8")"
+mptcp_lib_is_ip_mptcp && \
+dump="$(printf '%s\n' \
+	"10.0.1.1 id 1 " \
+	"10.0.1.3 id 3 signal backup " \
+	"10.0.1.4 id 4 signal " \
+	"10.0.1.5 id 5 signal " \
+	"10.0.1.6 id 6 signal " \
+	"10.0.1.7 id 7 signal " \
+	"10.0.1.8 id 8 signal ")"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "id limit"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
@@ -134,6 +153,7 @@ check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "subflows above
 
 ip netns exec $ns1 ./pm_nl_ctl limits 8 8
 limits=$'accept 8\nsubflows 8'
+mptcp_lib_is_ip_mptcp && limits="add_addr_accepted 8 subflows 8 "
 check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "set limits"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
@@ -154,6 +174,16 @@ dump="$(printf '%s\n' \
 	"id 101 flags  10.0.1.4" \
 	"id 254 flags  10.0.1.5" \
 	"id 255 flags  10.0.1.6")"
+mptcp_lib_is_ip_mptcp && \
+dump="$(printf '%s\n' \
+	"10.0.1.1 id 1 " \
+	"10.0.1.2 id 2 " \
+	"10.0.1.7 id 3 " \
+	"10.0.1.8 id 4 " \
+	"10.0.1.3 id 100 " \
+	"10.0.1.4 id 101 " \
+	"10.0.1.5 id 254 " \
+	"10.0.1.6 id 255 ")"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "set ids"
 
 ip netns exec $ns1 ./pm_nl_ctl flush
@@ -174,15 +204,27 @@ dump="$(printf '%s\n' \
 	"id 253 flags  10.0.0.5" \
 	"id 254 flags  10.0.0.2" \
 	"id 255 flags  10.0.0.3")"
+mptcp_lib_is_ip_mptcp && \
+dump="$(printf '%s\n' \
+	"10.0.0.1 id 1 " \
+	"10.0.0.4 id 2 " \
+	"10.0.0.6 id 3 " \
+	"10.0.0.7 id 4 " \
+	"10.0.0.8 id 5 " \
+	"10.0.0.5 id 253 " \
+	"10.0.0.2 id 254 " \
+	"10.0.0.3 id 255 ")"
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "wrap-around ids"
 
 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
 dump="id 1 flags subflow,backup 10.0.1.1"
+mptcp_lib_is_ip_mptcp && dump="10.0.1.1 id 1 subflow backup "
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "set flags (backup)"
 ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
 dump="id 1 flags subflow 10.0.1.1"
+mptcp_lib_is_ip_mptcp && dump="10.0.1.1 id 1 subflow "
 check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (nobackup)"
 
 # fullmesh support has been added later
@@ -190,12 +232,15 @@ ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null
 if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" ||
    mptcp_lib_expect_all_features; then
 	dump="id 1 flags subflow,fullmesh 10.0.1.1"
+	mptcp_lib_is_ip_mptcp && dump="10.0.1.1 id 1 subflow fullmesh "
 	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (fullmesh)"
 	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
 	dump="id 1 flags subflow 10.0.1.1"
+	mptcp_lib_is_ip_mptcp && dump="10.0.1.1 id 1 subflow "
 	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (nofullmesh)"
 	ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
 	dump="id 1 flags subflow,backup,fullmesh 10.0.1.1"
+	mptcp_lib_is_ip_mptcp && dump="10.0.1.1 id 1 subflow backup fullmesh "
 	check "ip netns exec $ns1 ./pm_nl_ctl dump" "${dump}" "          (backup,fullmesh)"
 else
 	for st in fullmesh nofullmesh backup,fullmesh; do
Signature · 1 line
2.40.1
maintainer
#11 lore raw

Re: [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp

Hi Geliang,

Quoted 17 lines · Geliang Tang

From: Geliang Tang <[email protected]>

The outputs of 'ip mptcp' are different from that of 'pm_nl_ctl'. This patch adds corresponding outputs of 'ip mptcp' together with 'pm_nl_ctl'. Use mptcp_lib_is_ip_mptcp() helper to test whether ip_mptcp is set. If it it, use 'ip mptcp' format outputs for check().

---
 .../testing/selftests/net/mptcp/pm_netlink.sh | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
tools/testing/selftests/net/mptcp/pm_netlink.sh +0 -0
index 00949f73153a..2096c52b3a4b 100755

tools/testing/selftests/net/mptcp/pm_netlink.sh check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" · line 75

Quoted 4 lines
tools/testing/selftests/net/mptcp/pm_netlink.sh +1 -0
@@ -72,6 +72,7 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
 default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)"
 if mptcp_lib_expect_all_features; then
 	limits=$'accept 0\nsubflows 2'
+	mptcp_lib_is_ip_mptcp && limits="add_addr_accepted 0 subflows 2 "

Do you think new helpers could be added to avoid all these mptcp_lib_is_ip_mptcp in the test description? e.g.

  get_limits() {
      local accept="${1}"
      local subflows="${2}"
      if mptcp_lib_is_ip_mptcp; then
          # with a space at the end
          printf "add_addr_accepted %d subflows %d \n" \
                 "${accept}" "${subflows} "
      else
          printf "accept %d\nsubflows %d\n" "${accept}" "${subflows}"
      fi

}

(...)

  limits="$(get_limits 0 2)"

That's clearer when you check what the test is doing.

Same idea for the dumps/endpoints below, we could have:

# format: <id>,<ip>,<flags>,<dev>

  get_endpoints() {
      local entry id ip flags dev

      for entry in "${@}"; do
          IFS=, read -r id ip flags dev <<< "${entry}"
          if mptcp_lib_is_ip_mptcp; then
              echo -n "${ip} id ${id}"
              [ -n "${flags}" ] && echo -n " ${flags}"
              [ -n "${dev}" ] && echo -n " dev ${dev}"
              echo " " # always a space at the end
          else
              echo -n "id ${id} flags ${flags//" "/","}"
              [ -n "${dev}" ] && echo -n " dev ${dev}"
              echo "${ip}"
          fi
      done

}

  (...)
  endpoint="$(get_endpoints "1,10.0.1.1")
  (...)
  dump="$(get_endpoints "1,10.0.1.1" "2,10.0.1.2,subflow backup,lo")"

WDYT?

tools/testing/selftests/net/mptcp/pm_netlink.sh check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" · line 77

Quoted 2 lines
tools/testing/selftests/net/mptcp/pm_netlink.sh +0 -0
 	check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "defaults limits"
 fi

(...)

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#12 lore raw

PATCH 7/10 selftests: mptcp: add endpoint_ops API helper

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

This patch moves six endpoint operation helpers with the pm_nl_ prefix:

	pm_nl_limits(),
	pm_nl_add_endpoint(),
	pm_nl_del_endpoint(),
	pm_nl_flush_endpoint(),
	pm_nl_show_endpoints() and
	pm_nl_change_endpoint()

from mptcp_join.sh into mptcp_lib.sh as public functions, and renamed each of them with a mptcp_lib_ prefix.

Add a new helper mptcp_lib_endpoint_ops() in mptcp_lib.sh as the API for all endpoint operation helpers, which invokes each of mptcp_lib_ prefix helpers according to the first argument of it is "limits", "add", "del", "flush", "show" or "change".

Usage:
mptcp_lib_endpoint_ops limits $ns $addrs $subflows mptcp_lib_endpoint_ops add $ns $addr mptcp_lib_endpoint_ops del $ns $id $addr mptcp_lib_endpoint_ops flush $ns mptcp_lib_endpoint_ops show $ns mptcp_lib_endpoint_ops change $ns $id $flags

---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 107 +------------
 .../testing/selftests/net/mptcp/mptcp_lib.sh  | 148 ++++++++++++++++++
 2 files changed, 155 insertions(+), 100 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +7 -100
index 431233e25abc..8e35f875147b 100755
@@ -603,132 +603,39 @@ kill_events_pids()
 	evts_ns2_pid=0
 }
 
-pm_nl_limits()
-{
-	local ns=$1
-	local addrs=$2
-	local subflows=$3
-
-	if mptcp_lib_is_ip_mptcp; then
-		local limits="limits"
-
-		if [ -n "$addrs" ] && [ -n "$subflows" ]; then
-			limits+=" set add_addr_accepted $addrs subflows $subflows"
-		fi
-		ip -n $ns mptcp $limits
-	else
-		ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
-	fi
-}
-
 pm_nl_set_limits()
 {
-	pm_nl_limits "${@}"
+	mptcp_lib_endpoint_ops limits "${@}"
 }
 
 pm_nl_get_limits()
 {
-	pm_nl_limits "${@}"
+	mptcp_lib_endpoint_ops limits "${@}"
 }
 
 pm_nl_add_endpoint()
 {
-	local ns=$1
-	local addr=$2
-	local flags _flags
-	local port _port
-	local dev _dev
-	local id _id
-	local nr=2
-
-	local p
-	for p in "${@}"
-	do
-		if [ $p = "flags" ]; then
-			eval _flags=\$"$nr"
-			[ -n "$_flags" ]; flags="flags $_flags"
-		fi
-		if [ $p = "dev" ]; then
-			eval _dev=\$"$nr"
-			[ -n "$_dev" ]; dev="dev $_dev"
-		fi
-		if [ $p = "id" ]; then
-			eval _id=\$"$nr"
-			[ -n "$_id" ]; id="id $_id"
-		fi
-		if [ $p = "port" ]; then
-			eval _port=\$"$nr"
-			[ -n "$_port" ]; port="port $_port"
-		fi
-
-		nr=$((nr + 1))
-	done
-
-	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
-	else
-		ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
-	fi
+	mptcp_lib_endpoint_ops add "${@}"
 }
 
 pm_nl_del_endpoint()
 {
-	local ns=$1
-	local id=$2
-	local addr=$3
-
-	if mptcp_lib_is_ip_mptcp; then
-		[ $id -ne 0 ] && addr=''
-		ip -n $ns mptcp endpoint delete id $id $addr
-	else
-		ip netns exec $ns ./pm_nl_ctl del $id $addr
-	fi
+	mptcp_lib_endpoint_ops del "${@}"
 }
 
 pm_nl_flush_endpoint()
 {
-	local ns=$1
-
-	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint flush
-	else
-		ip netns exec $ns ./pm_nl_ctl flush
-	fi
+	mptcp_lib_endpoint_ops flush "${@}"
 }
 
 pm_nl_show_endpoints()
 {
-	local ns=$1
-	local id=$2
-
-	if mptcp_lib_is_ip_mptcp; then
-		local show="show"
-
-		[ -n "$id" ] && show+=" id $id"
-		ip -n $ns mptcp endpoint $show
-	else
-		local dump="dump"
-
-		[ -n "$id" ] && dump="get $id"
-		ip netns exec $ns ./pm_nl_ctl $dump
-	fi
+	mptcp_lib_endpoint_ops show "${@}"
 }
 
 pm_nl_change_endpoint()
 {
-	local ns=$1
-	local addr=$2
-	local flags=$3
-
-	if ! mptcp_lib_is_addr "$addr"; then
-		[ $addr -gt 0 ] && [ $addr -lt 256 ] && addr="id $addr"
-	fi
-
-	if mptcp_lib_is_ip_mptcp; then
-		ip -n $ns mptcp endpoint change $addr ${flags//","/" "}
-	else
-		ip netns exec $ns ./pm_nl_ctl set $addr flags $flags
-	fi
+	mptcp_lib_endpoint_ops change "${@}"
 }
 
 pm_nl_check_endpoint()
tools/testing/selftests/net/mptcp/mptcp_lib.sh +148 -0

151 lines not on this page · raw message

Signature · 1 line
2.40.1
maintainer
#13 lore raw

Re: [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper

Hi Geliang,

Quoted 19 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This patch moves six endpoint operation helpers with the pm_nl_ prefix:

	pm_nl_limits(),
	pm_nl_add_endpoint(),
	pm_nl_del_endpoint(),
	pm_nl_flush_endpoint(),
	pm_nl_show_endpoints() and
	pm_nl_change_endpoint()

from mptcp_join.sh into mptcp_lib.sh as public functions, and renamed each of them with a mptcp_lib_ prefix.

Add a new helper mptcp_lib_endpoint_ops() in mptcp_lib.sh as the API for all endpoint operation helpers, which invokes each of mptcp_lib_ prefix helpers according to the first argument of it is "limits", "add", "del", "flush", "show" or "change".

Quoted 7 lines

Usage:
mptcp_lib_endpoint_ops limits $ns $addrs $subflows mptcp_lib_endpoint_ops add $ns $addr mptcp_lib_endpoint_ops del $ns $id $addr mptcp_lib_endpoint_ops flush $ns mptcp_lib_endpoint_ops show $ns mptcp_lib_endpoint_ops change $ns $id $flags

I'm not sure to understand why you called this helper "endpoint". With "pm_nl", it means it is linked to the Path Manager, the Netlink interface. Maybe best to use 'mptcp_lib_pm_nl_ops'?

(...)

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 527

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -0
index c465f1d59419..d395692fac0d 100644
@@ -523,3 +523,151 @@ mptcp_lib_is_ip_mptcp() {
 
 	[ ${mptcp_lib_ip_mptcp} -eq 1 ]
 }
+
+mptcp_lib_limits() {

Same here for the prefix, "limits" is too vague:

mptcp_lib_pm_nl_limits()

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 538

Quoted 11 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +11 -0
+	local ns=${1}
+	local addrs=${2}
+	local subflows=${3}
+
+	if mptcp_lib_is_ip_mptcp; then
+		local limits="limits"
+
+		if [ -n "${addrs}" ] && [ -n "${subflows}" ]; then
+			limits+=" set add_addr_accepted ${addrs} subflows ${subflows}"
+		fi
+		# shellcheck disable=SC2086

Please *always* *always* justify why you ignore a rule, e.g.

  # shellcheck disable=SCXXXX  ## <reason>

or

# <long description>
# <on multiple lines>

  # shellcheck disable=SCXXXX

(I guess you don't need to ignore that if you look at my comment on patch 2/10, same below)

Quoted 31 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +31 -0
+		ip -n "${ns}" mptcp ${limits}
+	else
+		# shellcheck disable=SC2086
+		ip netns exec "${ns}" ./pm_nl_ctl limits "${addrs}" ${subflows}
+	fi
+}
+
+mptcp_lib_add_endpoint() {
+	local ns=${1}
+	local addr=${2}
+	local flags _flags
+	local port _port
+	local dev _dev
+	local id _id
+	local nr=2
+
+	local p
+	for p in "${@}"
+	do
+		if [ "${p}" = "flags" ]; then
+			eval _flags=\$"${nr}"
+			[ -n "${_flags}" ]; flags="flags ${_flags}"
+		fi
+		if [ "${p}" = "dev" ]; then
+			eval _dev=\$"${nr}"
+			[ -n "${_dev}" ]; dev="dev ${_dev}"
+		fi
+		if [ "${p}" = "id" ]; then
+			eval _id=\$"${nr}"
+			[ -n "${_id}" ]; id="id ${_id}"
+		fi

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 579

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+		if [ "${p}" = "port" ]; then
+			eval _port=\$"${nr}"
+			[ -n "${_port}" ]; port="port ${_port}"
+		fi
+
+		nr=$((nr + 1))
+	done
+
+	if mptcp_lib_is_ip_mptcp; then
+		# shellcheck disable=SC2086

I wonder if you couldn't use arrays:

  dev=(dev "${_dev}")
  (...)
  ip (...) "${dev[@]}")
Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +6 -0
+		ip -n "${ns}" mptcp endpoint add "${addr}" ${_flags//","/" "} ${dev} ${id} ${port}
+	else
+		# shellcheck disable=SC2086
+		ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags} ${dev} ${id} ${port}
+	fi
+}

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 595

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+
+mptcp_lib_del_endpoint() {
+	local ns=${1}
+	local id=${2}
+	local addr=${3}
+
+	if mptcp_lib_is_ip_mptcp; then
+		[ "${id}" -ne 0 ] && addr=''
+		# shellcheck disable=SC2086
+		ip -n "${ns}" mptcp endpoint delete id "${id}" ${addr}

or something like that to avoid the disable:

  ${addr:+"${addr}"}
Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +6 -0
+	else
+		ip netns exec "${ns}" ./pm_nl_ctl del "${id}" "${addr}"
+	fi
+}
+
+mptcp_lib_flush_endpoint() {

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 611

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+	local ns=${1}
+
+	if mptcp_lib_is_ip_mptcp; then
+		ip -n "${ns}" mptcp endpoint flush
+	else
+		ip netns exec "${ns}" ./pm_nl_ctl flush
+	fi
+}
+
+mptcp_lib_show_endpoints() {

(I guess this one is only needed in pm_netlink.sh, no?)

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 620

Quoted 9 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +9 -0
+	local ns=${1}
+	local id=${2}
+
+	if mptcp_lib_is_ip_mptcp; then
+		local show="show"
+
+		[ -n "${id}" ] && show+=" id ${id}"
+		# shellcheck disable=SC2086
+		ip -n "${ns}" mptcp endpoint ${show}

Maybe this to avoid the disable:

  ip -n "${ns}" mptcp endpoint show ${id:+id "${id}"}

Same below

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 630

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+	else
+		local dump="dump"
+
+		[ -n "${id}" ] && dump="get ${id}"
+		# shellcheck disable=SC2086
+		ip netns exec "${ns}" ./pm_nl_ctl ${dump}
+	fi
+}
+
+mptcp_lib_change_endpoint() {

(I guess this one is only needed in pm_netlink.sh, no?)

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 636

Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +6 -0
+	local ns=${1}
+	local addr=${2}
+	local flags=${3}
+
+	if ! mptcp_lib_is_addr "${addr}"; then
+		[ "${addr}" -gt 0 ] && [ "${addr}" -lt 256 ] && addr="id ${addr}"

use an array?

  XX=("${addr}")
  XX=("id ${addr}")
  ${XX[@]}
Quoted 5 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -0
+	fi
+
+	if mptcp_lib_is_ip_mptcp; then
+		# shellcheck disable=SC2086
+		ip -n "${ns}" mptcp endpoint change ${addr} ${flags//","/" "}

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 651

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+	else
+		# shellcheck disable=SC2086
+		ip netns exec "${ns}" ./pm_nl_ctl set ${addr} flags "${flags}"
+	fi
+}
+
+mptcp_lib_endpoint_ops() {
+	[ "$#" -lt 2 ] && return 1
+
+	case "$1" in

(missing {} → ${1})

Quoted 12 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +12 -0
+	"limits")
+		mptcp_lib_limits "${@:2}"
+		;;
+	"add")
+		mptcp_lib_add_endpoint "${@:2}"
+		;;
+	"del")
+		mptcp_lib_del_endpoint "${@:2}"
+		;;
+	"flush")
+		mptcp_lib_flush_endpoint "${@:2}"
+		;;

tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_is_ip_mptcp() { · line 673

Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
+	"show")
+		mptcp_lib_show_endpoints "${@:2}"
+		;;
+	"change")
+		mptcp_lib_change_endpoint "${@:2}"
+		;;
+	*)
+		;;
+	esac
+}

I'm not sure to see the advantage of using mptcp_lib_endpoint_ops(), why not directly calling mptcp_lib_pm_nl_limits, etc.?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#14 lore raw

PATCH 8/10 selftests: mptcp: use mptcp_lib_endpoint_ops

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

This patch uses the newly added mptcp_lib_endpoint_ops() helper with "add", "del", "flush", "show" or "change" arguments to place 'pm_nl_ctl add/del/ flush/show/get/set' commands in scripts mptcp_join.sh, mptcp_sockopt.sh, pm_netlink.sh and simult_flows.sh.

ip netns exec $ns pm_nl_ctl add $addr flags $flags ->
mptcp_lib_endpoint_ops add $ns $addr flags $flags

ip netns exec $ns pm_nl_ctl del $id
->
mptcp_lib_endpoint_ops del $ns $id

ip netns exec $ns pm_nl_ctl flush
->
mptcp_lib_endpoint_ops flush $ns

ip netns exec $ns pm_nl_ctl set id $id flags $flags ->
mptcp_lib_endpoint_ops change $ns id $id $flags

ip netns exec $ns pm_nl_ctl set $addr flags $flags ->
mptcp_lib_endpoint_ops change $ns $addr $flags

---
 .../testing/selftests/net/mptcp/mptcp_join.sh |   3 +-
 .../selftests/net/mptcp/mptcp_sockopt.sh      |  12 +-
 .../testing/selftests/net/mptcp/pm_netlink.sh | 130 +++++++++---------
 .../selftests/net/mptcp/simult_flows.sh       |   6 +-
 4 files changed, 75 insertions(+), 76 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -2
index 8e35f875147b..1052b85d8170 100755
@@ -681,9 +681,9 @@ pm_nl_check_endpoint()
 		return
 	fi
 
+	line=$(mptcp_lib_endpoint_ops show "${ns}" "${_id}")
 	if mptcp_lib_is_ip_mptcp; then
 		# get line and trim trailing whitespace
-		line=$(ip -n $ns mptcp endpoint show $id)
 		line="${line% }"
 		# the dump order is: address id flags port dev
 		[ -n "$addr" ] && expected_line="$addr"
@@ -692,7 +692,6 @@ pm_nl_check_endpoint()
 		[ -n "$dev" ] && expected_line+=" $dev"
 		[ -n "$port" ] && expected_line+=" $port"
 	else
-		line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
 		# the dump order is: id flags dev address port
 		expected_line="$id"
 		[ -n "$flags" ] && expected_line+=" $flags"
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +6 -6
index e2d70c18786e..84cf00f8bb7f 100755
@@ -58,15 +58,15 @@ init()
 		# let $ns2 reach any $ns1 address from any interface
 		ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
 
-		ip netns exec $ns1 ./pm_nl_ctl add 10.0.$i.1 flags signal
-		ip netns exec $ns1 ./pm_nl_ctl add dead:beef:$i::1 flags signal
+		mptcp_lib_endpoint_ops add "${ns1}" "10.0.${i}.1" flags signal
+		mptcp_lib_endpoint_ops add "${ns1}" "dead:beef:${i}::1" flags signal
 
-		ip netns exec $ns2 ./pm_nl_ctl add 10.0.$i.2 flags signal
-		ip netns exec $ns2 ./pm_nl_ctl add dead:beef:$i::2 flags signal
+		mptcp_lib_endpoint_ops add "${ns2}" "10.0.${i}.2" flags signal
+		mptcp_lib_endpoint_ops add "${ns2}" "dead:beef:${i}::2" flags signal
 	done
 
-	ip netns exec $ns1 ./pm_nl_ctl limits 8 8
-	ip netns exec $ns2 ./pm_nl_ctl limits 8 8
+	mptcp_lib_endpoint_ops limits "${ns1}" 8 8
+	mptcp_lib_endpoint_ops limits "${ns2}" 8 8
 
 	add_mark_rules $ns1 1
 	add_mark_rules $ns2 2
tools/testing/selftests/net/mptcp/pm_netlink.sh +65 -65

204 lines not on this page · raw message

tools/testing/selftests/net/mptcp/simult_flows.sh +3 -3
index 68ee92eccccb..2cacd3ed9955 100755
@@ -85,8 +85,8 @@ setup()
 	ip -net "$ns1" route add default via 10.0.2.2 metric 101
 	ip -net "$ns1" route add default via dead:beef:2::2 metric 101
 
-	ip netns exec "$ns1" ./pm_nl_ctl limits 1 1
-	ip netns exec "$ns1" ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags subflow
+	mptcp_lib_endpoint_ops limits "${ns1}" 1 1
+	mptcp_lib_endpoint_ops add "${ns1}" 10.0.2.1 dev ns1eth2 flags subflow
 
 	ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
 	ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
@@ -108,7 +108,7 @@ setup()
 	ip -net "$ns3" route add default via 10.0.3.2
 	ip -net "$ns3" route add default via dead:beef:3::2
 
-	ip netns exec "$ns3" ./pm_nl_ctl limits 1 1
+	mptcp_lib_endpoint_ops limits "${ns3}" 1 1
 
 	# debug build can slow down measurably the test program
 	# we use quite tight time limit on the run-time, to ensure
Signature · 1 line
2.40.1
author reviewer
#15 lore raw

PATCH 9/10 selftests: mptcp: add ip_mptcp option for more scripts

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

This patch adds '-i' option for mptcp_sockopt.sh, pm_netlink.sh, and simult_flows.sh, to use 'ip mptcp' command in the tests instead of 'pm_nl_ctl'. Update usage() correspondingly.

---
 .../selftests/net/mptcp/mptcp_sockopt.sh      | 22 +++++++++++++++++++
 .../testing/selftests/net/mptcp/pm_netlink.sh |  9 ++++++--
 .../selftests/net/mptcp/simult_flows.sh       |  8 +++++--
 3 files changed, 35 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +22 -0
index 84cf00f8bb7f..bc315e04b267 100755
@@ -22,6 +22,28 @@ ns1=""
 ns2=""
 ns_sbox=""
 
+usage() {
+	echo "Usage: $0 [ -i ] [ -h ]"
+	echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
+	echo -e "\t-h: help"
+}
+
+while getopts "hi" option;do
+	case "$option" in
+	"h")
+		usage "$0"
+		exit ${KSFT_PASS}
+		;;
+	"i")
+		mptcp_lib_set_ip_mptcp
+		;;
+	"?")
+		usage "$0"
+		exit ${KSFT_FAIL}
+		;;
+	esac
+done
+
 add_mark_rules()
 {
 	local ns=$1
tools/testing/selftests/net/mptcp/pm_netlink.sh +7 -2
index 183146e58ec2..5cffc748ee2f 100755
@@ -11,16 +11,21 @@
 ret=0
 
 usage() {
-	echo "Usage: $0 [ -h ]"
+	echo "Usage: $0 [ -i ] [ -h ]"
+	echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
+	echo -e "\t-h: help"
 }
 
-optstring=h
+optstring=hi
 while getopts "$optstring" option;do
 	case "$option" in
 	"h")
 		usage $0
 		exit ${KSFT_PASS}
 		;;
+	"i")
+		mptcp_lib_set_ip_mptcp
+		;;
 	"?")
 		usage $0
 		exit ${KSFT_FAIL}
tools/testing/selftests/net/mptcp/simult_flows.sh +6 -2
index 2cacd3ed9955..d2c38b183b7f 100755
@@ -27,10 +27,11 @@ capout=""
 size=0
 
 usage() {
-	echo "Usage: $0 [ -b ] [ -c ] [ -d ]"
+	echo "Usage: $0 [ -b ] [ -c ] [ -d ] [ -i]"
 	echo -e "\t-b: bail out after first error, otherwise runs al testcases"
 	echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
 	echo -e "\t-d: debug this script"
+	echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
 }
 
 # This function is used in the cleanup trap
@@ -259,7 +260,7 @@ run_test()
 	fi
 }
 
-while getopts "bcdh" option;do
+while getopts "bcdhi" option;do
 	case "$option" in
 	"h")
 		usage $0
@@ -274,6 +275,9 @@ while getopts "bcdh" option;do
 	"d")
 		set -x
 		;;
+	"i")
+		mptcp_lib_set_ip_mptcp
+		;;
 	"?")
 		usage $0
 		exit ${KSFT_FAIL}
Signature · 1 line
2.40.1
author reviewer
#16 lore raw

PATCH 10/10 selftests: mptcp: netlink: drop disable=SC2086

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Now there are only a few of variables are not using double quotes. Modifying them, then "shellcheck disable=SC2086" can be dropped.

---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
tools/testing/selftests/net/mptcp/pm_netlink.sh +3 -8
index 5cffc748ee2f..ad9c63af3f7d 100755
@@ -1,11 +1,6 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-# Double quotes to prevent globbing and word splitting is recommended in new
-# code but we accept it, especially because there were too many before having
-# address all other issues detected by shellcheck.
-#shellcheck disable=SC2086
-
 . "$(dirname "${0}")/mptcp_lib.sh"
 
 ret=0
@@ -20,14 +15,14 @@ optstring=hi
 while getopts "$optstring" option;do
 	case "$option" in
 	"h")
-		usage $0
+		usage "$0"
 		exit ${KSFT_PASS}
 		;;
 	"i")
 		mptcp_lib_set_ip_mptcp
 		;;
 	"?")
-		usage $0
+		usage "$0"
 		exit ${KSFT_FAIL}
 		;;
 	esac
@@ -40,7 +35,7 @@ err=$(mktemp)
 #shellcheck disable=SC2317
 cleanup()
 {
-	rm -f $err
+	rm -f "${err}"
 	mptcp_lib_ns_exit "${ns1}"
 }
 
Signature · 1 line
2.40.1
#17 lore raw

Re: selftests: mptcp: netlink: drop disable=SC2086: Build Failure

Hi Geliang,

Thank you for your modifications, that's great!

But sadly, our CI spotted some issues with it when trying to build it.

You can find more details there:

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8226639605

Status: success
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ebeb11fa857d

Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

#18 lore raw

Re: selftests: mptcp: netlink: drop disable=SC2086: Tests Results

In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Unstable: 1 failed test(s): selftest_simult_flows 🔴
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8226639608

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ebeb11fa857d

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

#19 lore raw

Re: [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086

In reply to Geliang Tang

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Unstable: 1 failed test(s): selftest_mptcp_join 🔴
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8266515899

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/aece08f21837
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=834175

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

maintainer
#20 lore raw
In reply to Geliang Tang

Hi Geliang,

Quoted 4 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This is the last part for "add helpers and vars in mptcp_lib.sh" series, add endpoint operation helpers into mptcp_lib.sh.

Thank you for looking at that!

I just did a review, see my different replies.

In general, I think we should only add tests if they validate new code path on the kernel side, e.g. new feature. Having more tests means more code to maintain, a longer time to execute them, etc. Best to only add "valuable" ones.

Quoted 10 lines

Geliang Tang (10):
selftests: mptcp: export ip_mptcp to mptcp_lib
selftests: mptcp: get support for limits
selftests: mptcp: id support for show_endpoints
selftests: mptcp: addr support for change_endpoint
selftests: mptcp: netlink: fix positions of newline
selftests: mptcp: netlink: add outputs for ip_mptcp
selftests: mptcp: add endpoint_ops API helper
selftests: mptcp: use mptcp_lib_endpoint_ops
selftests: mptcp: add ip_mptcp option for more scripts

I hope some people are going to validate that. I don't think our CI should always run these tests with and without this new '-i' option.

Maybe once in a while, to validate the interface with 'ip mptcp' is still OK? Do you plan to do this check periodically? e.g. before a new version of 'iproute2'?

Quoted 9 lines

selftests: mptcp: netlink: drop disable=SC2086

 .../testing/selftests/net/mptcp/mptcp_join.sh | 108 ++-----
 .../testing/selftests/net/mptcp/mptcp_lib.sh  | 166 ++++++++++
 .../selftests/net/mptcp/mptcp_sockopt.sh      |  34 ++-
 .../testing/selftests/net/mptcp/pm_netlink.sh | 288 +++++++++++-------
 .../selftests/net/mptcp/simult_flows.sh       |  14 +-
 5 files changed, 401 insertions(+), 209 deletions(-)

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author reviewer
#21 lore raw

Hi Matt,

Quoted 11 lines · Matthieu Baerts

Hi Geliang,

Quoted 4 lines · Geliang Tang

From: Geliang Tang <[email protected]>

This is the last part for "add helpers and vars in mptcp_lib.sh" series, add endpoint operation helpers into mptcp_lib.sh.

Thank you for looking at that!

I just did a review, see my different replies.

Thanks for your review. It's very useful. I just sent a v2, addressed all your comments.

Quoted 5 lines

In general, I think we should only add tests if they validate new code path on the kernel side, e.g. new feature. Having more tests means more code to maintain, a longer time to execute them, etc. Best to only add "valuable" ones.

I dropped them in v2.

Quoted 12 lines
Quoted 11 lines

Geliang Tang (10):
selftests: mptcp: export ip_mptcp to mptcp_lib
selftests: mptcp: get support for limits
selftests: mptcp: id support for show_endpoints
selftests: mptcp: addr support for change_endpoint
selftests: mptcp: netlink: fix positions of newline
selftests: mptcp: netlink: add outputs for ip_mptcp
selftests: mptcp: add endpoint_ops API helper
selftests: mptcp: use mptcp_lib_endpoint_ops
selftests: mptcp: add ip_mptcp option for more scripts

Quoted 6 lines

I hope some people are going to validate that. I don't think our CI should always run these tests with and without this new '-i' option.

Maybe once in a while, to validate the interface with 'ip mptcp' is still OK? Do you plan to do this check periodically? e.g. before a new version of 'iproute2'?

Sure, I can check them in the future.

Thanks,
-Geliang

Quoted 16 lines
Quoted 11 lines

selftests: mptcp: netlink: drop disable=SC2086

 .../testing/selftests/net/mptcp/mptcp_join.sh | 108 ++-----
 .../testing/selftests/net/mptcp/mptcp_lib.sh  | 166 ++++++++++
 .../selftests/net/mptcp/mptcp_sockopt.sh      |  34 ++-
 .../testing/selftests/net/mptcp/pm_netlink.sh | 288 +++++++++++-------
 .../selftests/net/mptcp/simult_flows.sh       |  14 +-
 5 files changed, 401 insertions(+), 209 deletions(-)

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.