Skip to contentSkip to conversation

mptcp: fix signal endpoint readd

PATCH In review Paolo Abeni 3 participants 8 messages Jul 5, 2024 – Jul 9, 2024

Subsystems (3)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH v2 1/4 mptcp: fix user-space PM announced address accounting

In reply to Paolo Abeni

Currently the per-connection announced address counter is never decreased. When the user-space PM is in use, this just affect the information exposed via diag/sockopt, but it could still foul the PM to wrong decision.

Add the missing accounting for the user-space PM's sake.

Fixes 8b1c94da1e48 ("mptcp: only send RM_ADDR in nl_cmd_remove")
---
 net/mptcp/pm_netlink.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +13 -4
index ea9e5817b9e9..b399f2b7a369 100644
@@ -1534,16 +1534,25 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
 {
 	struct mptcp_rm_list alist = { .nr = 0 };
 	struct mptcp_pm_addr_entry *entry;
+	int anno_nr = 0;
 
 	list_for_each_entry(entry, rm_list, list) {
-		if ((remove_anno_list_by_saddr(msk, &entry->addr) ||
-		     lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) &&
-		    alist.nr < MPTCP_RM_IDS_MAX)
-			alist.ids[alist.nr++] = entry->addr.id;
+		if (alist.nr >= MPTCP_RM_IDS_MAX)
+			break;
+
+		/* only delete if either announced or matching a subflow */
+		if (remove_anno_list_by_saddr(msk, &entry->addr))
+			anno_nr++;
+		else if (!lookup_subflow_by_saddr(&msk->conn_list,
+						  &entry->addr))
+			continue;
+
+		alist.ids[alist.nr++] = entry->addr.id;
 	}
 
 	if (alist.nr) {
 		spin_lock_bh(&msk->pm.lock);
+		msk->pm.add_addr_signaled -= anno_nr;
 		mptcp_pm_remove_addr(msk, &alist);
 		spin_unlock_bh(&msk->pm.lock);
 	}
Signature · 1 line
2.45.2

Paolo Abeni

author maintainer
#0 lore raw

v2 cover mptcp: fix signal endpoint readd

Issues/501 showed that the NL PM currently don't add corectly removal and re-add of signal endpoint.

Patches 1 and 2 addresses the issue, patch 3/4 introduce a related self-test, and the last patch address a pre-existing buglet in the self-test infra.

v1 -> v2:
- splitted the first 2 patches
- fixed accounting in mptcp_pm_remove_anno_addr
- self-tests depends on subflow_rebuild_header

Paolo Abeni (4):
mptcp: fix user-space PM announced address accounting
mptcp: fix NL PM announced address accounting
selftests: mptcp: add explicit test case for remove/readd
selftests: mptcp: fix error path

 net/mptcp/pm_netlink.c                        | 27 +++++++++++-----
 .../testing/selftests/net/mptcp/mptcp_join.sh | 31 ++++++++++++++++++-
 2 files changed, 49 insertions(+), 9 deletions(-)
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH v2 2/4 mptcp: fix NL PM announced address accounting

Currently the per connection announced address counter is never decreased. As a consequence, after connection establishment, if the NL PM deletes an endpoint and adds a new/different one, no additional subflow is created for the new endpoint even if the current limits allow that.

Address the issue properly updating the signaled address counter every time the NL PM removes such addresses.

Fixes 01cacb00b35c ("mptcp: add netlink-based PM")

---
v1 -> v2:
- fix accounting in mptcp_pm_remove_anno_addr()
- split NL PM bits

---
 net/mptcp/pm_netlink.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +6 -4
index b399f2b7a369..f65831de5c1a 100644
@@ -1401,6 +1401,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
 	ret = remove_anno_list_by_saddr(msk, addr);
 	if (ret || force) {
 		spin_lock_bh(&msk->pm.lock);
+		msk->pm.add_addr_signaled -= ret;
 		mptcp_pm_remove_addr(msk, &list);
 		spin_unlock_bh(&msk->pm.lock);
 	}
@@ -1565,17 +1566,18 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
 	struct mptcp_pm_addr_entry *entry;
 
 	list_for_each_entry(entry, rm_list, list) {
-		if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) &&
-		    slist.nr < MPTCP_RM_IDS_MAX)
+		if (slist.nr < MPTCP_RM_IDS_MAX &&
+		    lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
 			slist.ids[slist.nr++] = entry->addr.id;
 
-		if (remove_anno_list_by_saddr(msk, &entry->addr) &&
-		    alist.nr < MPTCP_RM_IDS_MAX)
+		if (alist.nr < MPTCP_RM_IDS_MAX &&
+		    remove_anno_list_by_saddr(msk, &entry->addr))
 			alist.ids[alist.nr++] = entry->addr.id;
 	}
 
 	if (alist.nr) {
 		spin_lock_bh(&msk->pm.lock);
+		msk->pm.add_addr_signaled -= alist.nr;
 		mptcp_pm_remove_addr(msk, &alist);
 		spin_unlock_bh(&msk->pm.lock);
 	}
Signature · 1 line
2.45.2
author maintainer
#4 lore raw

PATCH v2 4/4 selftests: mptcp: fix error path

In reply to Paolo Abeni

pm_nl_check_endpoint() currently calls an not existing helper to mark the test as failed. Fix the wrong call.

Fixes 03668c65d153 ("selftests: mptcp: join: rework detailed report")
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
index 9c091fc267c4..55d84a1bde15 100755
@@ -661,7 +661,7 @@ pm_nl_check_endpoint()
 	done
 
 	if [ -z "${id}" ]; then
-		test_fail "bad test - missing endpoint id"
+		fail_test "bad test - missing endpoint id"
 		return
 	fi
 
Signature · 1 line
2.45.2
author maintainer
#3 lore raw

PATCH v2 3/4 selftests: mptcp: add explicit test case for remove/readd

In reply to Paolo Abeni

Delete and re-create a signal endpoint and ensure that the PM actually deletes and re-create the subflow.

---
v1 -> v2:
- depends on subflow_rebuild_header

---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +29 -0
index 108aeeb84ef1..9c091fc267c4 100755
@@ -3526,6 +3526,35 @@ endpoint_tests()
 		chk_mptcp_info subflows 1 subflows 1
 		mptcp_lib_kill_wait $tests_pid
 	fi
+
+	# remove and re-add
+	if reset "delete re-add signal" &&
+	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+		pm_nl_set_limits $ns1 1 1
+		pm_nl_set_limits $ns2 1 1
+		pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal
+		test_linkfail=4 speed=20 \
+			run_tests $ns1 $ns2 10.0.1.1 &
+		local tests_pid=$!
+
+		wait_mpj $ns2
+		pm_nl_check_endpoint "creation" \
+			$ns1 10.0.2.1 id 1 flags signal
+		chk_subflow_nr "before delete" 2
+		chk_mptcp_info subflows 1 subflows 1
+
+		pm_nl_del_endpoint $ns1 1 10.0.2.1
+		sleep 0.5
+		chk_subflow_nr "after delete" 1
+		chk_mptcp_info subflows 0 subflows 0
+
+		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
+		wait_mpj $ns2
+		chk_subflow_nr "after re-add" 2
+		chk_mptcp_info subflows 1 subflows 1
+		mptcp_lib_kill_wait $tests_pid
+	fi
+
 }
 
 # [$1: error message]
Signature · 1 line
2.45.2
#5 lore raw
In reply to Paolo Abeni

Hi Paolo,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

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

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

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

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

For more details:

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

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

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

maintainer Reviewed-by on the v2 series
#6 lore raw
In reply to Paolo Abeni

Hi Paolo,

Quoted 11 lines · Paolo Abeni

Issues/501 showed that the NL PM currently don't add corectly removal and re-add of signal endpoint.

Patches 1 and 2 addresses the issue, patch 3/4 introduce a related self-test, and the last patch address a pre-existing buglet in the self-test infra.

v1 -> v2:
- splitted the first 2 patches
- fixed accounting in mptcp_pm_remove_anno_addr
- self-tests depends on subflow_rebuild_header

Thank you for the v2, it looks good to me:

I will do a follow-up regarding the re-use of the same ID (if needed -- but I guess yes, because we never mark the ID as available again when we remove a signal endpoint).

For the issue with Packetdrill, reported by the CI, I think it should be fixed by this PR:

https://github.com/multipath-tcp/packetdrill/pull/151

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#7 lore raw
In reply to Paolo Abeni

Hi Paolo,

Quoted 2 lines · Paolo Abeni

Issues/501 showed that the NL PM currently don't add corectly removal and re-add of signal endpoint.

(I didn't close it, I didn't check if it is fully fixed yet)

Quoted 3 lines

Patches 1 and 2 addresses the issue, patch 3/4 introduce a related self-test, and the last patch address a pre-existing buglet in the self-test infra.

Now in our tree:

New patches for t/upstream-net and t/upstream:
- a973aebd56ba: mptcp: fix user-space PM announced address accounting
- ed70cf97ff31: mptcp: fix NL PM announced address accounting
- dc47c6d60de4: selftests: mptcp: add explicit test case for remove/readd
- 538cf9db944b: selftests: mptcp: fix error path
- Results: 8db44fbab258..e21a2574f711 (export-net)
- Results: 91e30f779125..a1f720d3a383 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/93dd443c35874ff0a74cb51f747c08a9e0d1a5aa/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/52d4e14b827f1d4694bbb23dc513351ef0ac00fb/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.