* [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final
@ 2024-03-11 1:48 Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
` (10 more replies)
0 siblings, 11 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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(-)
--
2.40.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits Geliang Tang
` (9 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
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(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 5e9211e89825..7fd32f645650 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index d529b4b37af8..d84f2f4986a7 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -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 ]
+}
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints Geliang Tang
` (8 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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().
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 7fd32f645650..8eb5cf54ea42 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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 &
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint Geliang Tang
` (7 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 8eb5cf54ea42..e33a136aef8e 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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=$!
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (2 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:48 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 05/10] selftests: mptcp: netlink: fix positions of newline Geliang Tang
` (6 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
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(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index e33a136aef8e..431233e25abc 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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=$!
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index d84f2f4986a7..c465f1d59419 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -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}"
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 05/10] selftests: mptcp: netlink: fix positions of newline
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (3 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp Geliang Tang
` (5 subsequent siblings)
10 siblings, 0 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../testing/selftests/net/mptcp/pm_netlink.sh | 101 ++++++++++--------
1 file changed, 56 insertions(+), 45 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 6ab8c5d36340..00949f73153a 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -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})"
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (4 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 05/10] selftests: mptcp: netlink: fix positions of newline Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:49 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper Geliang Tang
` (4 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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().
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../testing/selftests/net/mptcp/pm_netlink.sh | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 00949f73153a..2096c52b3a4b 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -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
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (5 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-13 18:50 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 08/10] selftests: mptcp: use mptcp_lib_endpoint_ops Geliang Tang
` (3 subsequent siblings)
10 siblings, 1 reply; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../testing/selftests/net/mptcp/mptcp_join.sh | 107 +------------
.../testing/selftests/net/mptcp/mptcp_lib.sh | 148 ++++++++++++++++++
2 files changed, 155 insertions(+), 100 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 431233e25abc..8e35f875147b 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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()
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index c465f1d59419..d395692fac0d 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -523,3 +523,151 @@ mptcp_lib_is_ip_mptcp() {
[ ${mptcp_lib_ip_mptcp} -eq 1 ]
}
+
+mptcp_lib_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
+ # shellcheck disable=SC2086
+ 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
+ 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
+ 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
+}
+
+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}
+ else
+ ip netns exec "${ns}" ./pm_nl_ctl del "${id}" "${addr}"
+ fi
+}
+
+mptcp_lib_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_show_endpoints() {
+ 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}
+ 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() {
+ 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
+ # shellcheck disable=SC2086
+ ip -n "${ns}" mptcp endpoint change ${addr} ${flags//","/" "}
+ 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
+ "limits")
+ mptcp_lib_limits "${@:2}"
+ ;;
+ "add")
+ mptcp_lib_add_endpoint "${@:2}"
+ ;;
+ "del")
+ mptcp_lib_del_endpoint "${@:2}"
+ ;;
+ "flush")
+ mptcp_lib_flush_endpoint "${@:2}"
+ ;;
+ "show")
+ mptcp_lib_show_endpoints "${@:2}"
+ ;;
+ "change")
+ mptcp_lib_change_endpoint "${@:2}"
+ ;;
+ *)
+ ;;
+ esac
+}
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 08/10] selftests: mptcp: use mptcp_lib_endpoint_ops
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (6 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 09/10] selftests: mptcp: add ip_mptcp option for more scripts Geliang Tang
` (2 subsequent siblings)
10 siblings, 0 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../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(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 8e35f875147b..1052b85d8170 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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"
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index e2d70c18786e..84cf00f8bb7f 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -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
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 2096c52b3a4b..183146e58ec2 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -67,21 +67,21 @@ check()
fi
}
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
+check "mptcp_lib_endpoint_ops show ${ns1}" "" "defaults addr list"
-default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)"
+default_limits="$(mptcp_lib_endpoint_ops limits "${ns1}")"
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"
+ check "mptcp_lib_endpoint_ops limits ${ns1}" "${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
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.1
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.2 flags subflow dev lo
+mptcp_lib_endpoint_ops add "${ns1}" 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"
+check "mptcp_lib_endpoint_ops show ${ns1} 1" "${endpoint}" "simple add/get addr"
dump="$(printf '%s\n' \
"id 1 flags 10.0.1.1" \
@@ -92,36 +92,36 @@ 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" \
+check "mptcp_lib_endpoint_ops show ${ns1}" \
"${dump}" "dump addrs"
-ip netns exec $ns1 ./pm_nl_ctl del 2
+mptcp_lib_endpoint_ops del "${ns1}" 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" \
+check "mptcp_lib_endpoint_ops show ${ns1} 2" "" "simple del addr"
+check "mptcp_lib_endpoint_ops show ${ns1}" \
"${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"
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.3 2>/dev/null
+check "mptcp_lib_endpoint_ops show ${ns1} 4" "" "duplicate addr"
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal
+mptcp_lib_endpoint_ops add "${ns1}" 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"
+check "mptcp_lib_endpoint_ops show ${ns1} 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
+ mptcp_lib_endpoint_ops add "${ns1}" "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"
+check "mptcp_lib_endpoint_ops show ${ns1} 9" "${endpoint}" "hard addr limit"
+check "mptcp_lib_endpoint_ops show ${ns1} 10" "" "above hard addr limit"
-ip netns exec $ns1 ./pm_nl_ctl del 9
+mptcp_lib_endpoint_ops del "${ns1}" 9
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
+ mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.9 id "${i}"
+ mptcp_lib_endpoint_ops del "${ns1}" "${i}"
done
dump="$(printf '%s\n' \
"id 1 flags 10.0.1.1" \
@@ -140,31 +140,31 @@ dump="$(printf '%s\n' \
"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"
+check "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" "id limit"
-ip netns exec $ns1 ./pm_nl_ctl flush
-check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs"
+mptcp_lib_endpoint_ops flush "${ns1}"
+check "mptcp_lib_endpoint_ops show ${ns1}" "" "flush addrs"
-ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null
-check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "rcv addrs above hard limit"
+mptcp_lib_endpoint_ops limits "${ns1}" 9 1 2>/dev/null
+check "mptcp_lib_endpoint_ops limits ${ns1}" "${default_limits}" "rcv addrs above hard limit"
-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"
+mptcp_lib_endpoint_ops limits "${ns1}" 1 9 2>/dev/null
+check "mptcp_lib_endpoint_ops limits ${ns1}" "${default_limits}" "subflows above hard limit"
-ip netns exec $ns1 ./pm_nl_ctl limits 8 8
+mptcp_lib_endpoint_ops limits "${ns1}" 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
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 id 100
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4
-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 "mptcp_lib_endpoint_ops limits ${ns1}" "${limits}" "set limits"
+
+mptcp_lib_endpoint_ops flush "${ns1}"
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.1
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.2
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.3 id 100
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.4
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.5 id 254
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.6
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.7
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.8
dump="$(printf '%s\n' \
"id 1 flags 10.0.1.1" \
"id 2 flags 10.0.1.2" \
@@ -184,17 +184,17 @@ dump="$(printf '%s\n' \
"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
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.2 id 254
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.3
-ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.4
-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 "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" "set ids"
+
+mptcp_lib_endpoint_ops flush "${ns1}"
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.1
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.2 id 254
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.3
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.4
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.5 id 253
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.6
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.7
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.0.8
dump="$(printf '%s\n' \
"id 1 flags 10.0.0.1" \
"id 2 flags 10.0.0.4" \
@@ -214,34 +214,34 @@ dump="$(printf '%s\n' \
"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"
+check "mptcp_lib_endpoint_ops show ${ns1}" "${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
+mptcp_lib_endpoint_ops flush "${ns1}"
+mptcp_lib_endpoint_ops add "${ns1}" 10.0.1.1 flags subflow
+mptcp_lib_endpoint_ops change "${ns1}" 10.0.1.1 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
+check "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" "set flags (backup)"
+mptcp_lib_endpoint_ops change "${ns1}" 10.0.1.1 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)"
+check "mptcp_lib_endpoint_ops show ${ns1}" "${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_endpoint_ops change "${ns1}" 1 fullmesh 2>/dev/null
+if mptcp_lib_endpoint_ops show "${ns1}" | 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
+ check "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" " (fullmesh)"
+ mptcp_lib_endpoint_ops change "${ns1}" 1 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
+ check "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" " (nofullmesh)"
+ mptcp_lib_endpoint_ops change "${ns1}" 1 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)"
+ check "mptcp_lib_endpoint_ops show ${ns1}" "${dump}" " (backup,fullmesh)"
else
for st in fullmesh nofullmesh backup,fullmesh; do
st=" (${st})"
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 68ee92eccccb..2cacd3ed9955 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -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
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 09/10] selftests: mptcp: add ip_mptcp option for more scripts
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (7 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 08/10] selftests: mptcp: use mptcp_lib_endpoint_ops Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
2024-03-13 18:46 ` [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Matthieu Baerts
10 siblings, 0 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
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.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
.../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(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 84cf00f8bb7f..bc315e04b267 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -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
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 183146e58ec2..5cffc748ee2f 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -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}
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 2cacd3ed9955..d2c38b183b7f 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -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}
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (8 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 09/10] selftests: mptcp: add ip_mptcp option for more scripts Geliang Tang
@ 2024-03-11 1:48 ` Geliang Tang
2024-03-11 2:06 ` selftests: mptcp: netlink: drop disable=SC2086: Build Failure MPTCP CI
` (2 more replies)
2024-03-13 18:46 ` [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Matthieu Baerts
10 siblings, 3 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-11 1:48 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Now there are only a few of variables are not using double quotes.
Modifying them, then "shellcheck disable=SC2086" can be dropped.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/pm_netlink.sh | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 5cffc748ee2f..ad9c63af3f7d 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -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}"
}
--
2.40.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: selftests: mptcp: netlink: drop disable=SC2086: Build Failure
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
@ 2024-03-11 2:06 ` MPTCP CI
2024-03-11 2:44 ` selftests: mptcp: netlink: drop disable=SC2086: Tests Results MPTCP CI
2024-03-13 15:18 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 MPTCP CI
2 siblings, 0 replies; 22+ messages in thread
From: MPTCP CI @ 2024-03-11 2:06 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
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)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: selftests: mptcp: netlink: drop disable=SC2086: Tests Results
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
2024-03-11 2:06 ` selftests: mptcp: netlink: drop disable=SC2086: Build Failure MPTCP CI
@ 2024-03-11 2:44 ` MPTCP CI
2024-03-13 15:18 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 MPTCP CI
2 siblings, 0 replies; 22+ messages in thread
From: MPTCP CI @ 2024-03-11 2:44 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
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)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
2024-03-11 2:06 ` selftests: mptcp: netlink: drop disable=SC2086: Build Failure MPTCP CI
2024-03-11 2:44 ` selftests: mptcp: netlink: drop disable=SC2086: Tests Results MPTCP CI
@ 2024-03-13 15:18 ` MPTCP CI
2 siblings, 0 replies; 22+ messages in thread
From: MPTCP CI @ 2024-03-13 15:18 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
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)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
` (9 preceding siblings ...)
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
@ 2024-03-13 18:46 ` Matthieu Baerts
2024-03-16 3:56 ` Geliang Tang
10 siblings, 1 reply; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:46 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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.
> 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'?
> 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
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib
2024-03-11 1:48 ` [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
@ 2024-03-13 18:47 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:47 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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.
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index d529b4b37af8..d84f2f4986a7 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -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.
> # 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")
> + mptcp_lib_ip_mptcp=1
> +}
> +
> +mptcp_lib_is_ip_mptcp() {
> + : "${mptcp_lib_ip_mptcp:?}"
Same here, not needed I think.
> +
> + [ ${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.
> +}
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits
2024-03-11 1:48 ` [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits Geliang Tang
@ 2024-03-13 18:47 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:47 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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().
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> .../testing/selftests/net/mptcp/mptcp_join.sh | 23 +++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 7fd32f645650..8eb5cf54ea42 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -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 "${@}"
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
}
> +}
> +
> 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?)
> + 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?
> pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
> speed=slow \
> run_tests $ns1 $ns2 10.0.1.1 &
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints
2024-03-11 1:48 ` [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints Geliang Tang
@ 2024-03-13 18:47 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:47 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 8eb5cf54ea42..e33a136aef8e 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -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}"
Same here, that's already validated in pm_netlink.sh, no need to
duplicate the test validating the same kernel code path. WDYT?
> speed=slow \
> run_tests $ns1 $ns2 10.0.1.1 &
> local tests_pid=$!
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint
2024-03-11 1:48 ` [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint Geliang Tang
@ 2024-03-13 18:48 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:48 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, 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 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
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> 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(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index e33a136aef8e..431233e25abc 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -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}"
I feel like here as well, that's something already validated in
pm_netlink.sh, and this will not check anything new, no?
> speed=slow \
> run_tests $ns1 $ns2 10.0.1.1 &
> local tests_pid=$!
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp
2024-03-11 1:48 ` [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp Geliang Tang
@ 2024-03-13 18:49 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:49 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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().
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> .../testing/selftests/net/mptcp/pm_netlink.sh | 45 +++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
> index 00949f73153a..2096c52b3a4b 100755
> --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
> +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
> @@ -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?
> check "ip netns exec $ns1 ./pm_nl_ctl limits" "${limits}" "defaults limits"
> fi
(...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper
2024-03-11 1:48 ` [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper Geliang Tang
@ 2024-03-13 18:50 ` Matthieu Baerts
0 siblings, 0 replies; 22+ messages in thread
From: Matthieu Baerts @ 2024-03-13 18:50 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 11/03/2024 02:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> 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
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'?
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index c465f1d59419..d395692fac0d 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -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()
> + 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)
> + 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
> + 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[@]}")
> + 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
> +}
> +
> +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}"}
> + else
> + ip netns exec "${ns}" ./pm_nl_ctl del "${id}" "${addr}"
> + fi
> +}
> +
> +mptcp_lib_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_show_endpoints() {
(I guess this one is only needed in pm_netlink.sh, no?)
> + 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
> + 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?)
> + 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[@]}
> + fi
> +
> + if mptcp_lib_is_ip_mptcp; then
> + # shellcheck disable=SC2086
> + ip -n "${ns}" mptcp endpoint change ${addr} ${flags//","/" "}
> + 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})
> + "limits")
> + mptcp_lib_limits "${@:2}"
> + ;;
> + "add")
> + mptcp_lib_add_endpoint "${@:2}"
> + ;;
> + "del")
> + mptcp_lib_del_endpoint "${@:2}"
> + ;;
> + "flush")
> + mptcp_lib_flush_endpoint "${@:2}"
> + ;;
> + "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
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final
2024-03-13 18:46 ` [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Matthieu Baerts
@ 2024-03-16 3:56 ` Geliang Tang
0 siblings, 0 replies; 22+ messages in thread
From: Geliang Tang @ 2024-03-16 3:56 UTC (permalink / raw)
To: Matthieu Baerts; +Cc: mptcp
Hi Matt,
On Wed, Mar 13, 2024 at 07:46:41PM +0100, Matthieu Baerts wrote:
> Hi Geliang,
>
> On 11/03/2024 02:48, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> >
> > 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.
>
> 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.
>
> > 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'?
Sure, I can check them in the future.
Thanks,
-Geliang
>
>
> > 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
> --
> Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2024-03-16 3:57 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-11 1:48 [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 01/10] selftests: mptcp: export ip_mptcp to mptcp_lib Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 02/10] selftests: mptcp: get support for limits Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 03/10] selftests: mptcp: id support for show_endpoints Geliang Tang
2024-03-13 18:47 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 04/10] selftests: mptcp: addr support for change_endpoint Geliang Tang
2024-03-13 18:48 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 05/10] selftests: mptcp: netlink: fix positions of newline Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 06/10] selftests: mptcp: netlink: add outputs for ip_mptcp Geliang Tang
2024-03-13 18:49 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 07/10] selftests: mptcp: add endpoint_ops API helper Geliang Tang
2024-03-13 18:50 ` Matthieu Baerts
2024-03-11 1:48 ` [PATCH mptcp-next 08/10] selftests: mptcp: use mptcp_lib_endpoint_ops Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 09/10] selftests: mptcp: add ip_mptcp option for more scripts Geliang Tang
2024-03-11 1:48 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 Geliang Tang
2024-03-11 2:06 ` selftests: mptcp: netlink: drop disable=SC2086: Build Failure MPTCP CI
2024-03-11 2:44 ` selftests: mptcp: netlink: drop disable=SC2086: Tests Results MPTCP CI
2024-03-13 15:18 ` [PATCH mptcp-next 10/10] selftests: mptcp: netlink: drop disable=SC2086 MPTCP CI
2024-03-13 18:46 ` [PATCH mptcp-next 00/10] add helpers and vars in mptcp_lib.sh, final Matthieu Baerts
2024-03-16 3:56 ` Geliang Tang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox