2024-03-01 19:03:55

by Matthieu Baerts (NGI0)

[permalink] [raw]
Subject: [PATCH net-next 00/15] mptcp: userspace pm: 'dump addrs' and 'get addr'

This series from Geliang adds two new Netlink commands to the userspace
PM:

- one to dump all addresses of a specific MPTCP connection:
- feature added in patches 3 to 5
- test added in patches 7, 8 and 10

- and one to get a specific address for an MPTCP connection:
- feature added in patches 11 to 13
- test added in patches 14 and 15

These new Netlink commands can be useful if an MPTCP daemon lost track
of the different connections, e.g. after having been restarted.

The other patches are some clean-ups and small improvements added while
working on the new features.

Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
Geliang Tang (15):
mptcp: make pm_remove_addrs_and_subflows static
mptcp: export mptcp_genl_family & mptcp_nl_fill_addr
mptcp: implement mptcp_userspace_pm_dump_addr
mptcp: add token for get-addr in yaml
mptcp: dump addrs in userspace pm list
mptcp: check userspace pm flags
selftests: mptcp: add userspace pm subflow flag
selftests: mptcp: add token for dump_addr
selftests: mptcp: add mptcp_lib_check_output helper
selftests: mptcp: dump userspace addrs list
mptcp: add userspace_pm_lookup_addr_by_id helper
mptcp: implement mptcp_userspace_pm_get_addr
mptcp: get addr in userspace pm list
selftests: mptcp: add token for get_addr
selftests: mptcp: userspace pm get addr tests

Documentation/netlink/specs/mptcp_pm.yaml | 3 +-
net/mptcp/mptcp_pm_gen.c | 7 +-
net/mptcp/mptcp_pm_gen.h | 2 +-
net/mptcp/pm.c | 16 +++
net/mptcp/pm_netlink.c | 30 ++--
net/mptcp/pm_userspace.c | 180 +++++++++++++++++++++---
net/mptcp/protocol.h | 15 +-
tools/testing/selftests/net/mptcp/mptcp_join.sh | 91 ++++++++++++
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 23 +++
tools/testing/selftests/net/mptcp/pm_netlink.sh | 18 +--
tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 39 ++++-
11 files changed, 374 insertions(+), 50 deletions(-)
---
base-commit: e960825709330cb199d209740326cec37e8c419d
change-id: 20240301-upstream-net-next-20240301-mptcp-userspace-pm-dump-addr-221f169ac144

Best regards,
--
Matthieu Baerts (NGI0) <[email protected]>



2024-03-01 19:07:30

by Matthieu Baerts (NGI0)

[permalink] [raw]
Subject: [PATCH net-next 10/15] selftests: mptcp: dump userspace addrs list

From: Geliang Tang <[email protected]>

This patch adds a new helper userspace_pm_dump() to dump addresses
for the userspace PM. Use this helper to check whether an ID 0 subflow
is listed in the output of dump command after creating an ID 0 subflow
in "userspace pm create id 0 subflow" test. Dump userspace PM addresses
list in "userspace pm add & remove address" test and in "userspace pm
create destroy subflow" test.

Signed-off-by: Geliang Tang <[email protected]>
Reviewed-by: Matthieu Baerts (NGI0) <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 61 +++++++++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 1267d5708e13..8b6430642706 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -21,6 +21,7 @@ cinfail=""
cinsent=""
tmpfile=""
cout=""
+err=""
capout=""
ns1=""
ns2=""
@@ -189,6 +190,7 @@ init() {
cin=$(mktemp)
cinsent=$(mktemp)
cout=$(mktemp)
+ err=$(mktemp)
evts_ns1=$(mktemp)
evts_ns2=$(mktemp)

@@ -204,6 +206,7 @@ cleanup()
rm -f "$sin" "$sout" "$cinsent" "$cinfail"
rm -f "$tmpfile"
rm -rf $evts_ns1 $evts_ns2
+ rm -f "$err"
cleanup_partial
}

@@ -3356,6 +3359,50 @@ userspace_pm_rm_sf()
wait_rm_sf $1 "${cnt}"
}

+check_output()
+{
+ local cmd="$1"
+ local expected="$2"
+ local msg="$3"
+ local rc=0
+
+ mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
+ if [ ${rc} -eq 2 ]; then
+ fail_test "fail to check output # error ${rc}"
+ elif [ ${rc} -eq 0 ]; then
+ print_ok
+ elif [ ${rc} -eq 1 ]; then
+ fail_test "fail to check output # different output"
+ fi
+}
+
+# $1: ns
+userspace_pm_dump()
+{
+ local evts=$evts_ns1
+ local tk
+
+ [ "$1" == "$ns2" ] && evts=$evts_ns2
+ tk=$(mptcp_lib_evts_get_info token "$evts")
+
+ ip netns exec $1 ./pm_nl_ctl dump token $tk
+}
+
+userspace_pm_chk_dump_addr()
+{
+ local ns="${1}"
+ local exp="${2}"
+ local check="${3}"
+
+ print_check "dump addrs ${check}"
+
+ if mptcp_lib_kallsyms_has "mptcp_userspace_pm_dump_addr$"; then
+ check_output "userspace_pm_dump ${ns}" "${exp}"
+ else
+ print_skip
+ fi
+}
+
userspace_tests()
{
# userspace pm type prevents add_addr
@@ -3447,10 +3494,16 @@ userspace_tests()
chk_mptcp_info subflows 2 subflows 2
chk_subflows_total 3 3
chk_mptcp_info add_addr_signal 2 add_addr_accepted 2
+ userspace_pm_chk_dump_addr "${ns1}" \
+ $'id 10 flags signal 10.0.2.1\nid 20 flags signal 10.0.3.1' \
+ "signal"
userspace_pm_rm_addr $ns1 10
userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED
+ userspace_pm_chk_dump_addr "${ns1}" \
+ "id 20 flags signal 10.0.3.1" "after rm_addr 10"
userspace_pm_rm_addr $ns1 20
userspace_pm_rm_sf $ns1 10.0.3.1 $SUB_ESTABLISHED
+ userspace_pm_chk_dump_addr "${ns1}" "" "after rm_addr 20"
chk_rm_nr 2 2 invert
chk_mptcp_info subflows 0 subflows 0
chk_subflows_total 1 1
@@ -3471,8 +3524,14 @@ userspace_tests()
chk_join_nr 1 1 1
chk_mptcp_info subflows 1 subflows 1
chk_subflows_total 2 2
+ userspace_pm_chk_dump_addr "${ns2}" \
+ "id 20 flags subflow 10.0.3.2" \
+ "subflow"
userspace_pm_rm_addr $ns2 20
userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED
+ userspace_pm_chk_dump_addr "${ns2}" \
+ "" \
+ "after rm_addr 20"
chk_rm_nr 1 1
chk_mptcp_info subflows 0 subflows 0
chk_subflows_total 1 1
@@ -3492,6 +3551,8 @@ userspace_tests()
chk_mptcp_info subflows 0 subflows 0
chk_subflows_total 1 1
userspace_pm_add_sf $ns2 10.0.3.2 0
+ userspace_pm_chk_dump_addr "${ns2}" \
+ "id 0 flags subflow 10.0.3.2" "id 0 subflow"
chk_join_nr 1 1 1
chk_mptcp_info subflows 1 subflows 1
chk_subflows_total 2 2

--
2.43.0


2024-03-01 19:09:08

by Matthieu Baerts (NGI0)

[permalink] [raw]
Subject: [PATCH net-next 15/15] selftests: mptcp: userspace pm get addr tests

From: Geliang Tang <[email protected]>

This patch adds a new helper userspace_pm_get_addr() in mptcp_join.sh.
In it, parse the token value from the output of 'pm_nl_ctl events', then
pass it to pm_nl_ctl get_addr command. Use this helper in userspace pm
dump tests.

Signed-off-by: Geliang Tang <[email protected]>
Reviewed-by: Matthieu Baerts (NGI0) <[email protected]>
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 30 +++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 8b6430642706..955ee651dcd5 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -3388,6 +3388,18 @@ userspace_pm_dump()
ip netns exec $1 ./pm_nl_ctl dump token $tk
}

+# $1: ns ; $2: id
+userspace_pm_get_addr()
+{
+ local evts=$evts_ns1
+ local tk
+
+ [ "$1" == "$ns2" ] && evts=$evts_ns2
+ tk=$(mptcp_lib_evts_get_info token "$evts")
+
+ ip netns exec $1 ./pm_nl_ctl get $2 token $tk
+}
+
userspace_pm_chk_dump_addr()
{
local ns="${1}"
@@ -3403,6 +3415,21 @@ userspace_pm_chk_dump_addr()
fi
}

+userspace_pm_chk_get_addr()
+{
+ local ns="${1}"
+ local id="${2}"
+ local exp="${3}"
+
+ print_check "get id ${id} addr"
+
+ if mptcp_lib_kallsyms_has "mptcp_userspace_pm_get_addr$"; then
+ check_output "userspace_pm_get_addr ${ns} ${id}" "${exp}"
+ else
+ print_skip
+ fi
+}
+
userspace_tests()
{
# userspace pm type prevents add_addr
@@ -3497,6 +3524,8 @@ userspace_tests()
userspace_pm_chk_dump_addr "${ns1}" \
$'id 10 flags signal 10.0.2.1\nid 20 flags signal 10.0.3.1' \
"signal"
+ userspace_pm_chk_get_addr "${ns1}" "10" "id 10 flags signal 10.0.2.1"
+ userspace_pm_chk_get_addr "${ns1}" "20" "id 20 flags signal 10.0.3.1"
userspace_pm_rm_addr $ns1 10
userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED
userspace_pm_chk_dump_addr "${ns1}" \
@@ -3527,6 +3556,7 @@ userspace_tests()
userspace_pm_chk_dump_addr "${ns2}" \
"id 20 flags subflow 10.0.3.2" \
"subflow"
+ userspace_pm_chk_get_addr "${ns2}" "20" "id 20 flags subflow 10.0.3.2"
userspace_pm_rm_addr $ns2 20
userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED
userspace_pm_chk_dump_addr "${ns2}" \

--
2.43.0


2024-03-04 13:12:35

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next 00/15] mptcp: userspace pm: 'dump addrs' and 'get addr'

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <[email protected]>:

On Fri, 01 Mar 2024 19:18:24 +0100 you wrote:
> This series from Geliang adds two new Netlink commands to the userspace
> PM:
>
> - one to dump all addresses of a specific MPTCP connection:
> - feature added in patches 3 to 5
> - test added in patches 7, 8 and 10
>
> [...]

Here is the summary with links:
- [net-next,01/15] mptcp: make pm_remove_addrs_and_subflows static
https://git.kernel.org/netdev/net-next/c/e38b117d7f3b
- [net-next,02/15] mptcp: export mptcp_genl_family & mptcp_nl_fill_addr
https://git.kernel.org/netdev/net-next/c/34ca91e15e69
- [net-next,03/15] mptcp: implement mptcp_userspace_pm_dump_addr
https://git.kernel.org/netdev/net-next/c/34e74a5cf3b7
- [net-next,04/15] mptcp: add token for get-addr in yaml
https://git.kernel.org/netdev/net-next/c/9e6c88e2f05b
- [net-next,05/15] mptcp: dump addrs in userspace pm list
https://git.kernel.org/netdev/net-next/c/9ae7846c4b6b
- [net-next,06/15] mptcp: check userspace pm flags
https://git.kernel.org/netdev/net-next/c/c19ee3c7e388
- [net-next,07/15] selftests: mptcp: add userspace pm subflow flag
https://git.kernel.org/netdev/net-next/c/9963b77e25c6
- [net-next,08/15] selftests: mptcp: add token for dump_addr
https://git.kernel.org/netdev/net-next/c/950c332125f6
- [net-next,09/15] selftests: mptcp: add mptcp_lib_check_output helper
https://git.kernel.org/netdev/net-next/c/2d0c1d27ea4e
- [net-next,10/15] selftests: mptcp: dump userspace addrs list
https://git.kernel.org/netdev/net-next/c/38f027fca1b7
- [net-next,11/15] mptcp: add userspace_pm_lookup_addr_by_id helper
https://git.kernel.org/netdev/net-next/c/06afe09091ee
- [net-next,12/15] mptcp: implement mptcp_userspace_pm_get_addr
https://git.kernel.org/netdev/net-next/c/d32c8fb1c881
- [net-next,13/15] mptcp: get addr in userspace pm list
https://git.kernel.org/netdev/net-next/c/564ae6794ec5
- [net-next,14/15] selftests: mptcp: add token for get_addr
https://git.kernel.org/netdev/net-next/c/b055671b3936
- [net-next,15/15] selftests: mptcp: userspace pm get addr tests
https://git.kernel.org/netdev/net-next/c/4cc5cc7ca052

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html