Skip to contentSkip to conversation

remove id 0 address

PATCH Superseded Geliang Tang 2 participants 7 messages Mar 2, 2021 – Mar 3, 2021

Subsystems (3)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

v3 cover remove id 0 address

v3:
- print subflow ids in patch 1;
- add the initial subflow's ids check in patch 2;
- update the test in patch 3;
- tag: export/20210226T185626.

v2:
- drop __mptcp_wr_shutdown in v1.

Geliang Tang (3):
mptcp: unify RM_ADDR and RM_SUBFLOW receiving
mptcp: check the removing initial subflow
DO-NOT-MERGE: mptcp: remove id 0 test

 net/mptcp/pm_netlink.c                        | 99 +++++++++----------
 .../testing/selftests/net/mptcp/mptcp_join.sh | 10 +-
 2 files changed, 52 insertions(+), 57 deletions(-)
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH v3 1/3 mptcp: unify RM_ADDR and RM_SUBFLOW receiving

There are some duplicate code in mptcp_pm_nl_rm_addr_received and mptcp_pm_nl_rm_subflow_received. This patch unifies them into a new function named mptcp_pm_nl_rm_addr_or_subflow. In it, use the input parameter type to identify it's now removing an address or a subflow.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 90 +++++++++++++++++++-----------------------
 1 file changed, 40 insertions(+), 50 deletions(-)
net/mptcp/pm_netlink.c +40 -50
index 328fdcc35bfd..eaac9824f444 100644
@@ -594,47 +594,77 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
 	return -EINVAL;
 }
 
-static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+enum rm_type {
+	RM_ADDR,
+	RM_SUBFLOW,
+};
+
+static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
+					   struct mptcp_rm_list rm_list,
+					   enum rm_type type)
 {
 	struct mptcp_subflow_context *subflow, *tmp;
 	struct sock *sk = (struct sock *)msk;
 	u8 i;
 
-	pr_debug("address rm_list_nr %d", msk->pm.rm_list_rx.nr);
+	pr_debug("%s rm_list_nr %d", type == RM_ADDR ? "address" : "subflow", rm_list.nr);
 
 	msk_owned_by_me(msk);
 
-	if (!msk->pm.rm_list_rx.nr)
+	if (!rm_list.nr)
 		return;
 
 	if (list_empty(&msk->conn_list))
 		return;
 
-	for (i = 0; i < msk->pm.rm_list_rx.nr; i++) {
+	for (i = 0; i < rm_list.nr; i++) {
 		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
 			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
+			u8 id = subflow->local_id;
+
+			if (type == RM_ADDR)
+				id = subflow->remote_id;
 
-			if (msk->pm.rm_list_rx.ids[i] != subflow->remote_id)
+			if (rm_list.ids[i] != id)
 				continue;
 
-			pr_debug(" -> address rm_list_ids[%d]=%u", i, msk->pm.rm_list_rx.ids[i]);
+			pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
+				 type == RM_ADDR ? "address" : "subflow", i, rm_list.ids[i],
+				 subflow->local_id, subflow->remote_id);
 			spin_unlock_bh(&msk->pm.lock);
 			mptcp_subflow_shutdown(sk, ssk, how);
 			mptcp_close_ssk(sk, ssk, subflow);
 			spin_lock_bh(&msk->pm.lock);
 
-			msk->pm.add_addr_accepted--;
-			msk->pm.subflows--;
-			WRITE_ONCE(msk->pm.accept_addr, true);
+			if (type == RM_ADDR) {
+				msk->pm.add_addr_accepted--;
+				msk->pm.subflows--;
+				WRITE_ONCE(msk->pm.accept_addr, true);
 
-			__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);
+				__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR);
+			} else if (type == RM_SUBFLOW) {
+				msk->pm.local_addr_used--;
+				msk->pm.subflows--;
+
+				__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);
+			}
 
 			break;
 		}
 	}
 }
 
+static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
+{
+	mptcp_pm_nl_rm_addr_or_subflow(msk, msk->pm.rm_list_rx, RM_ADDR);
+}
+
+void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, struct mptcp_rm_list rm_list)
+{
+	mptcp_pm_nl_rm_addr_or_subflow(msk, rm_list, RM_SUBFLOW);
+}
+
 void mptcp_pm_nl_work(struct mptcp_sock *msk)
 {
 	struct mptcp_pm_data *pm = &msk->pm;
@@ -668,46 +698,6 @@ void mptcp_pm_nl_work(struct mptcp_sock *msk)
 	spin_unlock_bh(&msk->pm.lock);
 }
 
-void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, struct mptcp_rm_list rm_list)
-{
-	struct mptcp_subflow_context *subflow, *tmp;
-	struct sock *sk = (struct sock *)msk;
-	u8 i;
-
-	pr_debug("subflow rm_list_nr %d", rm_list.nr);
-
-	msk_owned_by_me(msk);
-
-	if (!rm_list.nr)
-		return;
-
-	if (list_empty(&msk->conn_list))
-		return;
-
-	for (i = 0; i < rm_list.nr; i++) {
-		list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) {
-			struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
-			int how = RCV_SHUTDOWN | SEND_SHUTDOWN;
-
-			if (rm_list.ids[i] != subflow->local_id)
-				continue;
-
-			pr_debug(" -> subflow rm_list_ids[%d]=%u", i, rm_list.ids[i]);
-			spin_unlock_bh(&msk->pm.lock);
-			mptcp_subflow_shutdown(sk, ssk, how);
-			mptcp_close_ssk(sk, ssk, subflow);
-			spin_lock_bh(&msk->pm.lock);
-
-			msk->pm.local_addr_used--;
-			msk->pm.subflows--;
-
-			__MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW);
-
-			break;
-		}
-	}
-}
-
 static bool address_use_port(struct mptcp_pm_addr_entry *entry)
 {
 	return (entry->addr.flags &
Signature · 1 line
2.29.2
author
#2 lore raw

PATCH v3 2/3 mptcp: check the removing initial subflow

If the removing address id is 0, the initial subflow needs to be removed. Since the initial subflow's both local_id and remote_id are all zeros, this patch checks them to make sure it's now removing the right subflow.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c | 5 +++++
 1 file changed, 5 insertions(+)
net/mptcp/pm_netlink.c +5 -0
index eaac9824f444..439c9ee57566 100644
@@ -629,6 +629,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
 			if (rm_list.ids[i] != id)
 				continue;
 
+			if (!rm_list.ids[i]) {
+				if (subflow->local_id || subflow->remote_id)
+					continue;
+			}
+
 			pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
 				 type == RM_ADDR ? "address" : "subflow", i, rm_list.ids[i],
 				 subflow->local_id, subflow->remote_id);
Signature · 1 line
2.29.2
author
#3 lore raw

PATCH v3 3/3 DO-NOT-MERGE: mptcp: remove id 0 test

Just for test.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 net/mptcp/pm_netlink.c                          |  4 ++--
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +2 -2
index 439c9ee57566..bc0ccc325f4b 100644
@@ -1100,7 +1100,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
 	struct mptcp_rm_list list = { .nr = 0 };
 	bool ret;
 
-	list.ids[list.nr++] = addr->id;
+	list.ids[list.nr++] = 0;
 
 	ret = remove_anno_list_by_saddr(msk, addr);
 	if (ret || force) {
@@ -1120,7 +1120,7 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net,
 
 	pr_debug("remove_id=%d", addr->id);
 
-	list.ids[list.nr++] = addr->id;
+	list.ids[list.nr++] = 0;
 
 	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
 		struct sock *sk = (struct sock *)msk;
tools/testing/selftests/net/mptcp/mptcp_join.sh +5 -5
index 96379ede5925..38603236dfa3 100755
@@ -911,7 +911,7 @@ remove_tests()
 	ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow
 	run_tests $ns1 $ns2 10.0.1.1 0 0 -2 slow
 	chk_join_nr "remove multiple subflows" 2 2 2
-	chk_rm_nr 2 2
+	chk_rm_nr 1 1
 
 	# single address, remove
 	reset
@@ -932,7 +932,7 @@ remove_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -1 -1 slow
 	chk_join_nr "remove subflow and signal" 2 2 2
 	chk_add_nr 1 1
-	chk_rm_nr 1 1
+	chk_rm_nr 0 0
 
 	# subflows and signal, remove
 	reset
@@ -944,7 +944,7 @@ remove_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -1 -2 slow
 	chk_join_nr "remove subflows and signal" 3 3 3
 	chk_add_nr 1 1
-	chk_rm_nr 2 2
+	chk_rm_nr 0 0
 
 	# addresses remove
 	reset
@@ -956,7 +956,7 @@ remove_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
 	chk_join_nr "remove addresses" 3 3 3
 	chk_add_nr 3 3
-	chk_rm_nr 3 3 invert
+	chk_rm_nr 1 1 invert
 
 	# invalid addresses remove
 	reset
@@ -968,7 +968,7 @@ remove_tests()
 	run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
 	chk_join_nr "remove invalid addresses" 1 1 1
 	chk_add_nr 3 3
-	chk_rm_nr 3 1 invert
+	chk_rm_nr 1 0 invert
 
 	# subflows and signal, flush
 	reset
Signature · 1 line
2.29.2
#4 lore raw

[MPTCP] Re: [MPTCP][PATCH v3 mptcp-next 2/3] mptcp: check the removing initial subflow

In reply to Geliang Tang
Quoted 14 lines · Geliang Tang

If the removing address id is 0, the initial subflow needs to be removed. Since the initial subflow's both local_id and remote_id are all zeros, this patch checks them to make sure it's now removing the right subflow.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>

---
net/mptcp/pm_netlink.c | 5 +++++

1 file changed, 5 insertions(+)
net/mptcp/pm_netlink.c +0 -0
index eaac9824f444..439c9ee57566 100644

net/mptcp/pm_netlink.c static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, · line 636

Quoted 8 lines
net/mptcp/pm_netlink.c +5 -0
@@ -629,6 +629,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
 			if (rm_list.ids[i] != id)
 				continue;
 
+			if (!rm_list.ids[i]) {
+				if (subflow->local_id || subflow->remote_id)
+					continue;
+			}
+

In my reply to v2, I commented that I did not see the initial subflow closed. But that does not mean that RM_ADDR 0 should only affect the initial subflow. There may be other subflows involving that address id that need to be closed.

Without this commit, do some self tests fail only because all of the subflows got closed? <--- (I am interested in the answer to this and having a discussion before making more code changes)

If peer A sends RM_ADDR 0 and all of the subflows are using local_id 0 on peer A's side, then it seems like it is expected that all of the subflows will close. We would want to test RM_ADDR 0 when there are subflows that will stay open because they do not use ID 0 on the side that is sending RM_ADDR. Is this what is going on with the tests or is there a different issue that is solved by the added code in this patch?

Thanks,

Mat

Quoted 9 lines
net/mptcp/pm_netlink.c +0 -0
 			pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
 				 type == RM_ADDR ? "address" : "subflow", i, rm_list.ids[i],
 				 subflow->local_id, subflow->remote_id);
Signature · 4 lines
2.29.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

author
#5 lore raw

[MPTCP] Re: [MPTCP][PATCH v3 mptcp-next 2/3] mptcp: check the removing initial subflow

Hi Mat,

Quoted 31 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2021年3月3日周三 上午9:44写道:
Quoted 14 lines · Geliang Tang

If the removing address id is 0, the initial subflow needs to be removed. Since the initial subflow's both local_id and remote_id are all zeros, this patch checks them to make sure it's now removing the right subflow.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>

---
net/mptcp/pm_netlink.c | 5 +++++

1 file changed, 5 insertions(+)
net/mptcp/pm_netlink.c +0 -0
index eaac9824f444..439c9ee57566 100644

net/mptcp/pm_netlink.c static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, · line 636

Quoted 8 lines
net/mptcp/pm_netlink.c +5 -0
@@ -629,6 +629,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
                      if (rm_list.ids[i] != id)
                              continue;
 
+                     if (!rm_list.ids[i]) {
+                             if (subflow->local_id || subflow->remote_id)
+                                     continue;
+                     }
+

In my reply to v2, I commented that I did not see the initial subflow closed. But that does not mean that RM_ADDR 0 should only affect the initial subflow. There may be other subflows involving that address id that need to be closed.

Quoted 3 lines

Without this commit, do some self tests fail only because all of the subflows got closed? <--- (I am interested in the answer to this and having a discussion before making more code changes)

When I ran the test in v2, some self tests got the poll timeout failures since all of the subflows got closed. When I ran the test in v3, without this commit, no self test fail.

The original removing code can deal with id 0 address well, only the "break" in mptcp_pm_nl_rm_addr_or_subflow needs to be dropped. Since this "break" prevents the iteration to the next subflow involving that address. I fixed this in v4.

Quoted 7 lines

If peer A sends RM_ADDR 0 and all of the subflows are using local_id 0 on peer A's side, then it seems like it is expected that all of the subflows will close. We would want to test RM_ADDR 0 when there are subflows that will stay open because they do not use ID 0 on the side that is sending RM_ADDR. Is this what is going on with the tests or is there a different issue that is solved by the added code in this patch?

I thought that removing id 0 was just removing the initial subflow, so I added this patch. As mentioned above, all the subflows involving the id 0 address need to be removed. So this patch need to be dropped.

Thanks.

-Geliang

Quoted 19 lines

Thanks,

Mat

Quoted 9 lines
net/mptcp/pm_netlink.c +0 -1
                      pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
                               type == RM_ADDR ? "address" : "subflow", i, rm_list.ids[i],
                               subflow->local_id, subflow->remote_id);
--

2.29.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

#6 lore raw

[MPTCP] Re: [MPTCP][PATCH v3 mptcp-next 2/3] mptcp: check the removing initial subflow

Quoted 38 lines · Geliang Tang

Hi Mat,

Quoted 31 lines · Mat Martineau <mathew.j.martineau(a)linux.intel.com> 于2021年3月3日周三 上午9:44写道:
Quoted 14 lines · Geliang Tang

If the removing address id is 0, the initial subflow needs to be removed. Since the initial subflow's both local_id and remote_id are all zeros, this patch checks them to make sure it's now removing the right subflow.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>

---
net/mptcp/pm_netlink.c | 5 +++++

1 file changed, 5 insertions(+)
net/mptcp/pm_netlink.c +0 -0
index eaac9824f444..439c9ee57566 100644

net/mptcp/pm_netlink.c static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk, · line 636

Quoted 8 lines
net/mptcp/pm_netlink.c +5 -0
@@ -629,6 +629,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
                      if (rm_list.ids[i] != id)
                              continue;
 
+                     if (!rm_list.ids[i]) {
+                             if (subflow->local_id || subflow->remote_id)
+                                     continue;
+                     }
+

In my reply to v2, I commented that I did not see the initial subflow closed. But that does not mean that RM_ADDR 0 should only affect the initial subflow. There may be other subflows involving that address id that need to be closed.

Quoted 3 lines

Without this commit, do some self tests fail only because all of the subflows got closed? <--- (I am interested in the answer to this and having a discussion before making more code changes)

Quoted 8 lines

When I ran the test in v2, some self tests got the poll timeout failures since all of the subflows got closed. When I ran the test in v3, without this commit, no self test fail.

The original removing code can deal with id 0 address well, only the "break" in mptcp_pm_nl_rm_addr_or_subflow needs to be dropped. Since this "break" prevents the iteration to the next subflow involving that address. I fixed this in v4.

Ok, thanks for this information!

Mat

Quoted 9 lines
Quoted 8 lines

If peer A sends RM_ADDR 0 and all of the subflows are using local_id 0 on peer A's side, then it seems like it is expected that all of the subflows will close. We would want to test RM_ADDR 0 when there are subflows that will stay open because they do not use ID 0 on the side that is sending RM_ADDR. Is this what is going on with the tests or is there a different issue that is solved by the added code in this patch?

Quoted 28 lines

I thought that removing id 0 was just removing the initial subflow, so I added this patch. As mentioned above, all the subflows involving the id 0 address need to be removed. So this patch need to be dropped.

Thanks.

-Geliang

Quoted 19 lines

Thanks,

Mat

Quoted 9 lines
net/mptcp/pm_netlink.c +0 -1
                      pr_debug(" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u",
                               type == RM_ADDR ? "address" : "subflow", i, rm_list.ids[i],
                               subflow->local_id, subflow->remote_id);
--

2.29.2
_______________________________________________
mptcp mailing list -- mptcp(a)lists.01.org
To unsubscribe send an email to mptcp-leave(a)lists.01.org

--
Mat Martineau
Intel

--
Mat Martineau
Intel