Skip to contentSkip to conversation

userspace pm remove id 0 subflow & address

PATCH Superseded Geliang Tang 2 participants 6 messages Aug 8, 2023

Subsystems (3)

v1 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

cover userspace pm remove id 0 subflow & address

This patchset addresses #379 and #391, add the abilities to remove id 0 subflow and address for userspace PM. And a selftest.

Geliang Tang (4):
mptcp: allow creating id 0 subflow
mptcp: remove id 0 subflow & address
selftests: mptcp: add id argument for dsf
selftests: mptcp: remove id 0 subflow & address

 net/mptcp/pm_userspace.c                      | 41 +++++++++++++++----
 .../testing/selftests/net/mptcp/mptcp_join.sh | 24 +++++++++++
 tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 33 ++++++++++++++-
 3 files changed, 90 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/4 mptcp: allow creating id 0 subflow

This patch drops id 0 limitation in mptcp_nl_cmd_sf_create() to allow creating additional subflows with the local addr ID 0.

Fixes 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
---
 net/mptcp/pm_userspace.c | 6 ------
 1 file changed, 6 deletions(-)
net/mptcp/pm_userspace.c +0 -6
index b5a8aa4c1ebd..d042d32beb4d 100644
@@ -307,12 +307,6 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
 		goto create_err;
 	}
 
-	if (addr_l.id == 0) {
-		NL_SET_ERR_MSG_ATTR(info->extack, laddr, "missing local addr id");
-		err = -EINVAL;
-		goto create_err;
-	}
-
 	err = mptcp_pm_parse_addr(raddr, info, &addr_r);
 	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr");
Signature · 1 line
2.35.3
#2 lore raw

PATCH 2/4 mptcp: remove id 0 subflow & address

In reply to Geliang Tang

This patch adds the ability to send RM_ADDR for local ID 0 and the ability to remove id 0 subflow.

Put id 0 into a removing list, pass it to mptcp_pm_remove_addr() to remve id 0 address and pass it to mptcp_pm_nl_rm_subflow_received() to remove id 0 subflow.

---
 net/mptcp/pm_userspace.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
net/mptcp/pm_userspace.c +34 -1
index d042d32beb4d..90472cd62342 100644
@@ -241,6 +241,19 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
 
 	lock_sock((struct sock *)msk);
 
+	if (id_val == 0) {
+		struct mptcp_rm_list list = { .nr = 0 };
+
+		list.ids[list.nr++] = 0;
+
+		spin_lock_bh(&msk->pm.lock);
+		mptcp_pm_remove_addr(msk, &list);
+		spin_unlock_bh(&msk->pm.lock);
+		release_sock((struct sock *)msk);
+		err = 0;
+		goto remove_err;
+	}
+
 	list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
 		if (entry->addr.id == id_val) {
 			match = entry;
@@ -399,14 +412,16 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 	struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
 	struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
 	struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR];
+	struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
 	struct mptcp_addr_info addr_l;
 	struct mptcp_addr_info addr_r;
 	struct mptcp_sock *msk;
 	struct sock *sk, *ssk;
 	int err = -EINVAL;
 	u32 token_val;
+	u8 id_val;
 
-	if (!laddr || !raddr || !token) {
+	if (((!laddr || !raddr) && !id) || !token) {
 		GENL_SET_ERR_MSG(info, "missing required inputs");
 		return err;
 	}
@@ -424,6 +439,24 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
 		goto destroy_err;
 	}
 
+	if (id) {
+		id_val = nla_get_u8(id);
+		if (id_val == 0) {
+			struct mptcp_rm_list list = { .nr = 0 };
+
+			list.ids[list.nr++] = 0;
+
+			sk = (struct sock *)msk;
+			lock_sock(sk);
+			spin_lock_bh(&msk->pm.lock);
+			mptcp_pm_nl_rm_subflow_received(msk, &list);
+			spin_unlock_bh(&msk->pm.lock);
+			release_sock(sk);
+			err = 0;
+			goto destroy_err;
+		}
+	}
+
 	err = mptcp_pm_parse_addr(laddr, info, &addr_l);
 	if (err < 0) {
 		NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr");
Signature · 1 line
2.35.3
#3 lore raw

PATCH 3/4 selftests: mptcp: add id argument for dsf

In reply to Geliang Tang

This patch adds a id argument for userspace PM subflow removing function dsf(), to remove id 0 subflow.

./pm_nl_ctl dsf token $tk id 0

---
 tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 33 ++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/pm_nl_ctl.c +32 -1
index 49369c4a5f26..6e078854f440 100644
@@ -358,9 +358,40 @@ int dsf(int fd, int pm_family, int argc, char *argv[])
 	off = init_genl_req(data, pm_family, MPTCP_PM_CMD_SUBFLOW_DESTROY,
 			    MPTCP_PM_VER);
 
-	if (argc < 12)
+	if (argc < 6)
 		syntax(argv);
 
+	if (argc < 12) {
+		u_int8_t id;
+
+		for (arg = 2; arg < argc; arg++) {
+			if (!strcmp(argv[arg], "id")) {
+				if (++arg >= argc)
+					error(1, 0, " missing id value");
+
+				id = atoi(argv[arg]);
+				rta = (void *)(data + off);
+				rta->rta_type = MPTCP_PM_ATTR_LOC_ID;
+				rta->rta_len = RTA_LENGTH(1);
+				memcpy(RTA_DATA(rta), &id, 1);
+				off += NLMSG_ALIGN(rta->rta_len);
+			} else if (!strcmp(argv[arg], "token")) {
+				if (++arg >= argc)
+					error(1, 0, " missing token value");
+
+				token = strtoul(argv[arg], NULL, 10);
+				rta = (void *)(data + off);
+				rta->rta_type = MPTCP_PM_ATTR_TOKEN;
+				rta->rta_len = RTA_LENGTH(4);
+				memcpy(RTA_DATA(rta), &token, 4);
+				off += NLMSG_ALIGN(rta->rta_len);
+			} else
+				error(1, 0, "unknown keyword %s", argv[arg]);
+		}
+		do_nl_req(fd, nh, off, 0);
+		return 0;
+	}
+
 	/* Params recorded in this order:
 	 * <local-ip>, <local-port>, <remote-ip>, <remote-port>, <token>
 	 */
Signature · 1 line
2.35.3
#4 lore raw

PATCH 4/4 selftests: mptcp: remove id 0 subflow & address

In reply to Geliang Tang

This patch adds a selftest for userpsace PM to remove id 0 subflow and id 0 address.

---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +24 -0
index ee1f89a872b3..9bcfacaa4124 100755
@@ -3434,6 +3434,30 @@ userspace_tests()
 		kill_events_pids
 		wait $tests_pid
 	fi
+
+	# userspace pm remove id 0 subflow & address
+	if reset_with_events "userspace pm remove id 0 subflow & address" &&
+	   continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
+		local tk
+
+		set_userspace_pm $ns2
+		pm_nl_set_limits $ns1 0 2
+		speed=10 \
+			run_tests $ns1 $ns2 10.0.1.1 &
+		local tests_pid=$!
+		wait_mpj $ns2
+		userspace_pm_add_sf 10.0.1.2 0
+		userspace_pm_add_sf 10.0.3.2 20
+		chk_join_nr 2 2 2
+		chk_mptcp_info subflows 2 subflows 2
+		tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
+		ip netns exec $ns2 ./pm_nl_ctl rem token $tk id 0
+		ip netns exec $ns2 ./pm_nl_ctl dsf token $tk id 0
+		chk_rm_nr 2 2
+		chk_mptcp_info subflows 1 subflows 1
+		kill_events_pids
+		wait $tests_pid
+	fi
 }
 
 endpoint_tests()
Signature · 1 line
2.35.3
#5 lore raw

Re: selftests: mptcp: remove id 0 subflow & address: Tests Results

Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5332343926292480
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5332343926292480/summary/summary.txt

- KVM Validation: normal (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/6458243833135104
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6458243833135104/summary/summary.txt

- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5050868949581824
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5050868949581824/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/6176768856424448
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6176768856424448/summary/summary.txt

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

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-debug

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 (Tessares)