netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/5] mptcp: fix signal endpoint readd
@ 2024-07-27  9:03 Matthieu Baerts (NGI0)
  2024-07-27  9:03 ` [PATCH net 1/5] mptcp: fix user-space PM announced address accounting Matthieu Baerts (NGI0)
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:03 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable, Liu Jing

Issue #501 [1] showed that the Netlink PM currently doesn't correctly
support removal and re-add of signal endpoints.

Patches 1 and 2 address the issue: the first one in the userspace path-
manager, introduced in v5.19 ; and the second one in the in-kernel path-
manager, introduced in v5.7.

Patch 3 introduces a related selftest. There is no 'Fixes' tag, because
it might be hard to backport it automatically, as missing helpers in
Bash will not be caught when compiling the kernel or the selftests.

The last two patches address two small issues in the MPTCP selftests,
one introduced in v6.6., and the other one in v5.17.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/501 [1]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Liu Jing (1):
      selftests: mptcp: always close input's FD if opened

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 ++++++++++++++------
 tools/testing/selftests/net/mptcp/mptcp_connect.c |  8 +++---
 tools/testing/selftests/net/mptcp/mptcp_join.sh   | 31 ++++++++++++++++++++++-
 3 files changed, 53 insertions(+), 13 deletions(-)
---
base-commit: 301927d2d2eb8e541357ba850bc7a1a74dbbd670
change-id: 20240726-upstream-net-20240726-mptcp-fix-signal-readd-f3c72bbcbceb

Best regards,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net 1/5] mptcp: fix user-space PM announced address accounting
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
@ 2024-07-27  9:03 ` Matthieu Baerts (NGI0)
  2024-07-27  9:04 ` [PATCH net 2/5] mptcp: fix NL " Matthieu Baerts (NGI0)
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:03 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable

From: Paolo Abeni <pabeni@redhat.com>

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")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_netlink.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index ea9e5817b9e9..b399f2b7a369 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -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);
 	}

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 2/5] mptcp: fix NL PM announced address accounting
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
  2024-07-27  9:03 ` [PATCH net 1/5] mptcp: fix user-space PM announced address accounting Matthieu Baerts (NGI0)
@ 2024-07-27  9:04 ` Matthieu Baerts (NGI0)
  2024-07-27  9:04 ` [PATCH net 3/5] selftests: mptcp: add explicit test case for remove/readd Matthieu Baerts (NGI0)
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:04 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable

From: Paolo Abeni <pabeni@redhat.com>

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")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_netlink.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index b399f2b7a369..f65831de5c1a 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -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);
 	}

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 3/5] selftests: mptcp: add explicit test case for remove/readd
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
  2024-07-27  9:03 ` [PATCH net 1/5] mptcp: fix user-space PM announced address accounting Matthieu Baerts (NGI0)
  2024-07-27  9:04 ` [PATCH net 2/5] mptcp: fix NL " Matthieu Baerts (NGI0)
@ 2024-07-27  9:04 ` Matthieu Baerts (NGI0)
  2024-07-27  9:04 ` [PATCH net 4/5] selftests: mptcp: fix error path Matthieu Baerts (NGI0)
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:04 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0)

From: Paolo Abeni <pabeni@redhat.com>

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

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 108aeeb84ef1..9c091fc267c4 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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]

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 4/5] selftests: mptcp: fix error path
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
                   ` (2 preceding siblings ...)
  2024-07-27  9:04 ` [PATCH net 3/5] selftests: mptcp: add explicit test case for remove/readd Matthieu Baerts (NGI0)
@ 2024-07-27  9:04 ` Matthieu Baerts (NGI0)
  2024-07-27  9:04 ` [PATCH net 5/5] selftests: mptcp: always close input's FD if opened Matthieu Baerts (NGI0)
  2024-07-29 12:40 ` [PATCH net 0/5] mptcp: fix signal endpoint readd patchwork-bot+netdevbpf
  5 siblings, 0 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:04 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	stable

From: Paolo Abeni <pabeni@redhat.com>

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")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 9c091fc267c4..55d84a1bde15 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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
 

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 5/5] selftests: mptcp: always close input's FD if opened
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
                   ` (3 preceding siblings ...)
  2024-07-27  9:04 ` [PATCH net 4/5] selftests: mptcp: fix error path Matthieu Baerts (NGI0)
@ 2024-07-27  9:04 ` Matthieu Baerts (NGI0)
  2024-07-29 12:40 ` [PATCH net 0/5] mptcp: fix signal endpoint readd patchwork-bot+netdevbpf
  5 siblings, 0 replies; 7+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-07-27  9:04 UTC (permalink / raw)
  To: mptcp, Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Matthieu Baerts (NGI0),
	Liu Jing, stable

From: Liu Jing <liujing@cmss.chinamobile.com>

In main_loop_s function, when the open(cfg_input, O_RDONLY) function is
run, the last fd is not closed if the "--cfg_repeat > 0" branch is not
taken.

Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests")
Cc: stable@vger.kernel.org
Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index d2043ec3bf6d..4209b9569039 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1115,11 +1115,11 @@ int main_loop_s(int listensock)
 		return 1;
 	}
 
-	if (--cfg_repeat > 0) {
-		if (cfg_input)
-			close(fd);
+	if (cfg_input)
+		close(fd);
+
+	if (--cfg_repeat > 0)
 		goto again;
-	}
 
 	return 0;
 }

-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net 0/5] mptcp: fix signal endpoint readd
  2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
                   ` (4 preceding siblings ...)
  2024-07-27  9:04 ` [PATCH net 5/5] selftests: mptcp: always close input's FD if opened Matthieu Baerts (NGI0)
@ 2024-07-29 12:40 ` patchwork-bot+netdevbpf
  5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-29 12:40 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: mptcp, martineau, geliang, davem, edumazet, kuba, pabeni, shuah,
	netdev, linux-kernel, linux-kselftest, stable, liujing

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Sat, 27 Jul 2024 11:03:58 +0200 you wrote:
> Issue #501 [1] showed that the Netlink PM currently doesn't correctly
> support removal and re-add of signal endpoints.
> 
> Patches 1 and 2 address the issue: the first one in the userspace path-
> manager, introduced in v5.19 ; and the second one in the in-kernel path-
> manager, introduced in v5.7.
> 
> [...]

Here is the summary with links:
  - [net,1/5] mptcp: fix user-space PM announced address accounting
    https://git.kernel.org/netdev/net/c/167b93258d1e
  - [net,2/5] mptcp: fix NL PM announced address accounting
    https://git.kernel.org/netdev/net/c/4b317e0eb287
  - [net,3/5] selftests: mptcp: add explicit test case for remove/readd
    https://git.kernel.org/netdev/net/c/b5e2fb832f48
  - [net,4/5] selftests: mptcp: fix error path
    https://git.kernel.org/netdev/net/c/4a2f48992ddf
  - [net,5/5] selftests: mptcp: always close input's FD if opened
    https://git.kernel.org/netdev/net/c/7c70bcc2a84c

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-29 12:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-27  9:03 [PATCH net 0/5] mptcp: fix signal endpoint readd Matthieu Baerts (NGI0)
2024-07-27  9:03 ` [PATCH net 1/5] mptcp: fix user-space PM announced address accounting Matthieu Baerts (NGI0)
2024-07-27  9:04 ` [PATCH net 2/5] mptcp: fix NL " Matthieu Baerts (NGI0)
2024-07-27  9:04 ` [PATCH net 3/5] selftests: mptcp: add explicit test case for remove/readd Matthieu Baerts (NGI0)
2024-07-27  9:04 ` [PATCH net 4/5] selftests: mptcp: fix error path Matthieu Baerts (NGI0)
2024-07-27  9:04 ` [PATCH net 5/5] selftests: mptcp: always close input's FD if opened Matthieu Baerts (NGI0)
2024-07-29 12:40 ` [PATCH net 0/5] mptcp: fix signal endpoint readd patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).