Netdev List
 help / color / mirror / Atom feed
* [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3
@ 2026-05-05 15:00 Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0 Matthieu Baerts (NGI0)
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable,
	Shuah Khan, linux-kselftest

Here are various fixes, mainly related to ADD_ADDRs:

- Patch 1: save ADD_ADDR for rtx with ID0 when needed. A fix for v6.1.

- Patch 2: remove unneeded exception for ID 0. A fix for v5.10.

- Patches 3-5: fix potential data-race and leaks during ADD_ADDR rtx. A
  fix for v5.10.

- Patch 6: resched blocked ADD_ADDR rtx after a more appropriated
  timeout, not after 15 seconds. A fix for v5.10.

- Patch 7: skip inactive subflows when when looking at the max RTO. A
  fix for v6.18.

- Patch 8: avoid iterating over all subflows when there is no need to. A
  fix for v6.18.

- Patch 9: skip closed subflows when looking at sending MP_PRIO. A fix
  for v5.17.

- Patch 10: properly catch errors when using check_output() in the
  selftests. A fix for v6.9.

- Patch 11: skip the 'unknown' flag test when 'ip mptcp' is used. A fix
  for v6.10.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Matthieu Baerts (NGI0) (11):
      mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0
      mptcp: pm: ADD_ADDR rtx: allow ID 0
      mptcp: pm: ADD_ADDR rtx: fix potential data-race
      mptcp: pm: ADD_ADDR rtx: always decrease sk refcount
      mptcp: pm: ADD_ADDR rtx: free sk if last
      mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker
      mptcp: pm: ADD_ADDR rtx: skip inactive subflows
      mptcp: pm: ADD_ADDR rtx: return early if no retrans
      mptcp: pm: prio: skip closed subflows
      selftests: mptcp: check output: catch cmd errors
      selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl

 net/mptcp/pm.c                                  | 62 +++++++++++++++++--------
 net/mptcp/pm_kernel.c                           | 13 ++++--
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  | 16 ++++---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 20 +++++---
 4 files changed, 73 insertions(+), 38 deletions(-)
---
base-commit: 07d99587396024932e02474c3a5bede71d108454
change-id: 20260504-net-mptcp-pm-fixes-7-1-rc3-e4d81787300e

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


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

* [PATCH net 01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 02/11] mptcp: pm: ADD_ADDR rtx: allow " Matthieu Baerts (NGI0)
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When adding the ADD_ADDR to the list, the address including the IP, port
and ID are copied. On the other hand, when the endpoint corresponds to
the one from the initial subflow, the ID is set to 0, as specified by
the MPTCP protocol.

The issue is that the ID was reset after having copied the ID in the
ADD_ADDR entry. So the retransmission was done, but using a different ID
than the initial one.

Fixes: 8b8ed1b429f8 ("mptcp: pm: reuse ID 0 after delete and re-add")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_kernel.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index c9f1e5af3cd3..fc818b63752e 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -347,6 +347,8 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 
 	/* check first for announce */
 	if (msk->pm.add_addr_signaled < endp_signal_max) {
+		u8 endp_id;
+
 		/* due to racing events on both ends we can reach here while
 		 * previous add address is still running: if we invoke now
 		 * mptcp_pm_announce_addr(), that will fail and the
@@ -360,19 +362,20 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 		if (!select_signal_address(pernet, msk, &local))
 			goto subflow;
 
+		/* Special case for ID0: set the correct ID */
+		endp_id = local.addr.id;
+		if (endp_id == msk->mpc_endpoint_id)
+			local.addr.id = 0;
+
 		/* If the alloc fails, we are on memory pressure, not worth
 		 * continuing, and trying to create subflows.
 		 */
 		if (!mptcp_pm_alloc_anno_list(msk, &local.addr))
 			return;
 
-		__clear_bit(local.addr.id, msk->pm.id_avail_bitmap);
+		__clear_bit(endp_id, msk->pm.id_avail_bitmap);
 		msk->pm.add_addr_signaled++;
 
-		/* Special case for ID0: set the correct ID */
-		if (local.addr.id == msk->mpc_endpoint_id)
-			local.addr.id = 0;
-
 		mptcp_pm_announce_addr(msk, &local.addr, false);
 		mptcp_pm_addr_send_ack(msk);
 

-- 
2.53.0


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

* [PATCH net 02/11] mptcp: pm: ADD_ADDR rtx: allow ID 0
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0 Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 03/11] mptcp: pm: ADD_ADDR rtx: fix potential data-race Matthieu Baerts (NGI0)
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

ADD_ADDR can be sent for the ID 0, which corresponds to the local
address and port linked to the initial subflow.

Indeed, this address could be removed, and re-added later on, e.g. what
is done in the "delete re-add signal" MPTCP Join selftests. So no reason
to ignore it.

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 57a456690406..5056eb8db24e 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -337,9 +337,6 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 	if (inet_sk_state_load(sk) == TCP_CLOSE)
 		return;
 
-	if (!entry->addr.id)
-		return;
-
 	if (mptcp_pm_should_add_signal_addr(msk)) {
 		sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8);
 		goto out;

-- 
2.53.0


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

* [PATCH net 03/11] mptcp: pm: ADD_ADDR rtx: fix potential data-race
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0 Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 02/11] mptcp: pm: ADD_ADDR rtx: allow " Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 04/11] mptcp: pm: ADD_ADDR rtx: always decrease sk refcount Matthieu Baerts (NGI0)
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

This mptcp_pm_add_timer() helper is executed as a timer callback in
softirq context. To avoid any data races, the socket lock needs to be
held with bh_lock_sock().

If the socket is in use, retry again soon after, similar to what is done
with the keepalive timer.

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 5056eb8db24e..3912128d9b86 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -337,6 +337,13 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 	if (inet_sk_state_load(sk) == TCP_CLOSE)
 		return;
 
+	bh_lock_sock(sk);
+	if (sock_owned_by_user(sk)) {
+		/* Try again later. */
+		sk_reset_timer(sk, timer, jiffies + HZ / 20);
+		goto out;
+	}
+
 	if (mptcp_pm_should_add_signal_addr(msk)) {
 		sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8);
 		goto out;
@@ -365,6 +372,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 		mptcp_pm_subflow_established(msk);
 
 out:
+	bh_unlock_sock(sk);
 	__sock_put(sk);
 }
 

-- 
2.53.0


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

* [PATCH net 04/11] mptcp: pm: ADD_ADDR rtx: always decrease sk refcount
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (2 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 03/11] mptcp: pm: ADD_ADDR rtx: fix potential data-race Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 05/11] mptcp: pm: ADD_ADDR rtx: free sk if last Matthieu Baerts (NGI0)
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When an ADD_ADDR is retransmitted, the sk is held in sk_reset_timer().
It should then be released in all cases at the end.

Some (unlikely) checks were returning directly instead of calling
sock_put() to decrease the refcount. Jump to a new 'exit' label to call
__sock_put() (which will become sock_put() in the next commit) to fix
this potential leak.

While at it, drop the '!msk' check which cannot happen because it is
never reset, and explicitly mark the remaining one as "unlikely".

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 3912128d9b86..2a01bf1b5bfd 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -331,11 +331,8 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 
 	pr_debug("msk=%p\n", msk);
 
-	if (!msk)
-		return;
-
-	if (inet_sk_state_load(sk) == TCP_CLOSE)
-		return;
+	if (unlikely(inet_sk_state_load(sk) == TCP_CLOSE))
+		goto exit;
 
 	bh_lock_sock(sk);
 	if (sock_owned_by_user(sk)) {
@@ -373,6 +370,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 
 out:
 	bh_unlock_sock(sk);
+exit:
 	__sock_put(sk);
 }
 

-- 
2.53.0


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

* [PATCH net 05/11] mptcp: pm: ADD_ADDR rtx: free sk if last
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (3 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 04/11] mptcp: pm: ADD_ADDR rtx: always decrease sk refcount Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 06/11] mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker Matthieu Baerts (NGI0)
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When an ADD_ADDR is retransmitted, the sk is held in sk_reset_timer(),
and released at the end.

If at that moment, it was the last reference being held, the sk would
not be freed. sock_put() should then be called instead of __sock_put().

But that's not enough: if it is the last reference, sock_put() will call
sk_free(), which will end up calling sk_stop_timer_sync() on the same
timer, and waiting indefinitely to finish. So it is needed to mark that
the timer is done at the end of the timer handler when it has not been
rescheduled, not to call sk_stop_timer_sync() on "itself".

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 2a01bf1b5bfd..8899327e59a1 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -16,6 +16,7 @@ struct mptcp_pm_add_entry {
 	struct list_head	list;
 	struct mptcp_addr_info	addr;
 	u8			retrans_times;
+	bool			timer_done;
 	struct timer_list	add_timer;
 	struct mptcp_sock	*sock;
 	struct rcu_head		rcu;
@@ -327,22 +328,22 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 							      add_timer);
 	struct mptcp_sock *msk = entry->sock;
 	struct sock *sk = (struct sock *)msk;
-	unsigned int timeout;
+	unsigned int timeout = 0;
 
 	pr_debug("msk=%p\n", msk);
 
-	if (unlikely(inet_sk_state_load(sk) == TCP_CLOSE))
-		goto exit;
-
 	bh_lock_sock(sk);
+	if (unlikely(inet_sk_state_load(sk) == TCP_CLOSE))
+		goto out;
+
 	if (sock_owned_by_user(sk)) {
 		/* Try again later. */
-		sk_reset_timer(sk, timer, jiffies + HZ / 20);
+		timeout = HZ / 20;
 		goto out;
 	}
 
 	if (mptcp_pm_should_add_signal_addr(msk)) {
-		sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8);
+		timeout = TCP_RTO_MAX / 8;
 		goto out;
 	}
 
@@ -360,8 +361,9 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 	}
 
 	if (entry->retrans_times < ADD_ADDR_RETRANS_MAX)
-		sk_reset_timer(sk, timer,
-			       jiffies + (timeout << entry->retrans_times));
+		timeout <<= entry->retrans_times;
+	else
+		timeout = 0;
 
 	spin_unlock_bh(&msk->pm.lock);
 
@@ -369,9 +371,13 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 		mptcp_pm_subflow_established(msk);
 
 out:
+	if (timeout)
+		sk_reset_timer(sk, timer, jiffies + timeout);
+	else
+		/* if sock_put calls sk_free: avoid waiting for this timer */
+		entry->timer_done = true;
 	bh_unlock_sock(sk);
-exit:
-	__sock_put(sk);
+	sock_put(sk);
 }
 
 struct mptcp_pm_add_entry *
@@ -434,6 +440,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
 
 	timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0);
 reset_timer:
+	add_entry->timer_done = false;
 	timeout = mptcp_adjust_add_addr_timeout(msk);
 	if (timeout)
 		sk_reset_timer(sk, &add_entry->add_timer, jiffies + timeout);
@@ -454,7 +461,8 @@ static void mptcp_pm_free_anno_list(struct mptcp_sock *msk)
 	spin_unlock_bh(&msk->pm.lock);
 
 	list_for_each_entry_safe(entry, tmp, &free_list, list) {
-		sk_stop_timer_sync(sk, &entry->add_timer);
+		if (!entry->timer_done)
+			sk_stop_timer_sync(sk, &entry->add_timer);
 		kfree_rcu(entry, rcu);
 	}
 }

-- 
2.53.0


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

* [PATCH net 06/11] mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (4 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 05/11] mptcp: pm: ADD_ADDR rtx: free sk if last Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 07/11] mptcp: pm: ADD_ADDR rtx: skip inactive subflows Matthieu Baerts (NGI0)
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When an ADD_ADDR needs to be retransmitted and another one has already
been prepared -- e.g. multiple ADD_ADDRs have been sent in a row and
need to be retransmitted later -- this additional retransmission will
need to wait.

In this case, the timer was reset to TCP_RTO_MAX / 8, which is ~15
seconds. This delay is unnecessary long: it should just be rescheduled
at the next opportunity, e.g. after the retransmission timeout.

Without this modification, some issues can be seen from time to time in
the selftests when multiple ADD_ADDRs are sent, and the host takes time
to process them, e.g. the "signal addresses, ADD_ADDR timeout" MPTCP
Join selftest, especially with a debug kernel config.

Note that on older kernels, 'timeout' is not available. It should be
enough to replace it by one second (HZ).

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 8899327e59a1..29d1bb6a69cf 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -342,13 +342,8 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
 		goto out;
 	}
 
-	if (mptcp_pm_should_add_signal_addr(msk)) {
-		timeout = TCP_RTO_MAX / 8;
-		goto out;
-	}
-
 	timeout = mptcp_adjust_add_addr_timeout(msk);
-	if (!timeout)
+	if (!timeout || mptcp_pm_should_add_signal_addr(msk))
 		goto out;
 
 	spin_lock_bh(&msk->pm.lock);

-- 
2.53.0


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

* [PATCH net 07/11] mptcp: pm: ADD_ADDR rtx: skip inactive subflows
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (5 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 06/11] mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 08/11] mptcp: pm: ADD_ADDR rtx: return early if no retrans Matthieu Baerts (NGI0)
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When looking at the maximum RTO amongst the subflows, inactive subflows
were taken into account: that includes stale ones, and the initial one
if it has been already been closed.

Unusable subflows are now simply skipped. Stale ones are used as an
alternative: if there are only stale ones, to take their maximum RTO and
avoid to eventually fallback to net.mptcp.add_addr_timeout, which is set
to 2 minutes by default.

Fixes: 30549eebc4d8 ("mptcp: make ADD_ADDR retransmission timeout adaptive")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 29d1bb6a69cf..8a5dba7fe66e 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -306,18 +306,28 @@ static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk)
 	const struct net *net = sock_net((struct sock *)msk);
 	unsigned int rto = mptcp_get_add_addr_timeout(net);
 	struct mptcp_subflow_context *subflow;
-	unsigned int max = 0;
+	unsigned int max = 0, max_stale = 0;
 
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		struct inet_connection_sock *icsk = inet_csk(ssk);
 
-		if (icsk->icsk_rto > max)
+		if (!__mptcp_subflow_active(subflow))
+			continue;
+
+		if (unlikely(subflow->stale)) {
+			if (icsk->icsk_rto > max_stale)
+				max_stale = icsk->icsk_rto;
+		} else if (icsk->icsk_rto > max) {
 			max = icsk->icsk_rto;
+		}
 	}
 
-	if (max && max < rto)
-		rto = max;
+	if (max)
+		return min(max, rto);
+
+	if (max_stale)
+		return min(max_stale, rto);
 
 	return rto;
 }

-- 
2.53.0


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

* [PATCH net 08/11] mptcp: pm: ADD_ADDR rtx: return early if no retrans
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (6 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 07/11] mptcp: pm: ADD_ADDR rtx: skip inactive subflows Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 09/11] mptcp: pm: prio: skip closed subflows Matthieu Baerts (NGI0)
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

No need to iterate over all subflows if there is no retransmission
needed.

Exit early in this case then.

Fixes: 30549eebc4d8 ("mptcp: make ADD_ADDR retransmission timeout adaptive")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 8a5dba7fe66e..4a6e5ab30d80 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -308,6 +308,9 @@ static unsigned int mptcp_adjust_add_addr_timeout(struct mptcp_sock *msk)
 	struct mptcp_subflow_context *subflow;
 	unsigned int max = 0, max_stale = 0;
 
+	if (!rto)
+		return 0;
+
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		struct inet_connection_sock *icsk = inet_csk(ssk);

-- 
2.53.0


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

* [PATCH net 09/11] mptcp: pm: prio: skip closed subflows
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (7 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 08/11] mptcp: pm: ADD_ADDR rtx: return early if no retrans Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 10/11] selftests: mptcp: check output: catch cmd errors Matthieu Baerts (NGI0)
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable

When sending an MP_PRIO, closed subflows need to be skipped.

This fixes the case where the initial subflow got closed, re-opened
later, then an MP_PRIO is needed for the same local address.

Note that explicit MP_PRIO cannot be sent during the 3WHS, so it is fine
to use __mptcp_subflow_active().

Fixes: 067065422fcd ("mptcp: add the outgoing MP_PRIO support")
Cc: stable@vger.kernel.org
Fixes: b29fcfb54cd7 ("mptcp: full disconnect implementation")
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 4a6e5ab30d80..3c152bf66cd5 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -284,6 +284,9 @@ int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		struct mptcp_addr_info local, remote;
 
+		if (!__mptcp_subflow_active(subflow))
+			continue;
+
 		mptcp_local_address((struct sock_common *)ssk, &local);
 		if (!mptcp_addresses_equal(&local, addr, addr->port))
 			continue;

-- 
2.53.0


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

* [PATCH net 10/11] selftests: mptcp: check output: catch cmd errors
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (8 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 09/11] mptcp: pm: prio: skip closed subflows Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-05 15:00 ` [PATCH net 11/11] selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl Matthieu Baerts (NGI0)
  2026-05-07  1:30 ` [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable,
	Shuah Khan, linux-kselftest

Using '${?}' inside the if-statement to check the returned value from
the command that was evaluated as part of the if-statement is not
correct: here, '${?}' will be linked to the previous instruction, not
the one that is expected here (${cmd}).

Instead, simply mark the error, except if an error is expected. If
that's the case, 1 can be passed as the 4th argument of this helper.
Three checks from pm_netlink.sh expect an error.

While at it, improve the error message when the command unexpectedly
fails or succeeds.

Note that we could expect a specific returned value, but the checks
currently expecting an error can be used with 'ip mptcp' or 'pm_nl_ctl',
and these two tools don't return the same error code.

Fixes: 2d0c1d27ea4e ("selftests: mptcp: add mptcp_lib_check_output helper")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  | 16 ++++++++++------
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 10 ++++++----
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 5fea7e7df628..989a5975dcea 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -474,20 +474,24 @@ mptcp_lib_wait_local_port_listen() {
 	wait_local_port_listen "${@}" "tcp"
 }
 
+# $1: error file, $2: cmd, $3: expected msg, [$4: expected error]
 mptcp_lib_check_output() {
 	local err="${1}"
 	local cmd="${2}"
 	local expected="${3}"
+	local exp_error="${4:-0}"
 	local cmd_ret=0
 	local out
 
-	if ! out=$(${cmd} 2>"${err}"); then
-		cmd_ret=${?}
-	fi
+	out=$(${cmd} 2>"${err}") || cmd_ret=1
 
-	if [ ${cmd_ret} -ne 0 ]; then
-		mptcp_lib_pr_fail "command execution '${cmd}' stderr"
-		cat "${err}"
+	if [ "${cmd_ret}" != "${exp_error}" ]; then
+		mptcp_lib_pr_fail "unexpected returned code for '${cmd}', info:"
+		if [ "${exp_error}" = 0 ]; then
+			cat "${err}"
+		else
+			echo "${out}"
+		fi
 		return 2
 	elif [ "${out}" = "${expected}" ]; then
 		return 0
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 123d9d7a0278..b69f30fcb91e 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -122,10 +122,12 @@ check()
 	local cmd="$1"
 	local expected="$2"
 	local msg="$3"
+	local exp_error="$4"
 	local rc=0
 
 	mptcp_lib_print_title "$msg"
-	mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
+	mptcp_lib_check_output "${err}" "${cmd}" "${expected}" "${exp_error}" ||
+		rc=${?}
 	if [ ${rc} -eq 2 ]; then
 		mptcp_lib_result_fail "${msg} # error ${rc}"
 		ret=${KSFT_FAIL}
@@ -158,13 +160,13 @@ check "show_endpoints" \
 			    "3,10.0.1.3,signal backup")" "dump addrs"
 
 del_endpoint 2
-check "get_endpoint 2" "" "simple del addr"
+check "get_endpoint 2" "" "simple del addr" 1
 check "show_endpoints" \
 	"$(format_endpoints "1,10.0.1.1" \
 			    "3,10.0.1.3,signal backup")" "dump addrs after del"
 
 add_endpoint 10.0.1.3 2>/dev/null
-check "get_endpoint 4" "" "duplicate addr"
+check "get_endpoint 4" "" "duplicate addr" 1
 
 add_endpoint 10.0.1.4 flags signal
 check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment"
@@ -173,7 +175,7 @@ for i in $(seq 5 9); do
 	add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1
 done
 check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit"
-check "get_endpoint 10" "" "above hard addr limit"
+check "get_endpoint 10" "" "above hard addr limit" 1
 
 del_endpoint 9
 for i in $(seq 10 255); do

-- 
2.53.0


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

* [PATCH net 11/11] selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (9 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 10/11] selftests: mptcp: check output: catch cmd errors Matthieu Baerts (NGI0)
@ 2026-05-05 15:00 ` Matthieu Baerts (NGI0)
  2026-05-07  1:30 ` [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-05-05 15:00 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Christoph Paasch
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable,
	Shuah Khan, linux-kselftest

When pm_netlink.sh is executed with '-i', 'ip mptcp' is used instead of
'pm_nl_ctl'. IPRoute2 doesn't support the 'unknown' flag, which has only
been added to 'pm_nl_ctl' for this specific check: to ensure that the
kernel ignores such unsupported flag.

No reason to add this flag to 'ip mptcp'. Then, this check should be
skipped when 'ip mptcp' is used.

Fixes: 0cef6fcac24d ("selftests: mptcp: ip_mptcp option for more scripts")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/net/mptcp/pm_netlink.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index b69f30fcb91e..04594dfc22b1 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -194,9 +194,13 @@ check "show_endpoints" \
 flush_endpoint
 check "show_endpoints" "" "flush addrs"
 
-add_endpoint 10.0.1.1 flags unknown
-check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" "ignore unknown flags"
-flush_endpoint
+# "unknown" flag is only supported by pm_nl_ctl
+if ! mptcp_lib_is_ip_mptcp; then
+	add_endpoint 10.0.1.1 flags unknown
+	check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" \
+	      "ignore unknown flags"
+	flush_endpoint
+fi
 
 set_limits 9 1 2>/dev/null
 check "get_limits" "${default_limits}" "rcv addrs above hard limit"

-- 
2.53.0


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

* Re: [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3
  2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
                   ` (10 preceding siblings ...)
  2026-05-05 15:00 ` [PATCH net 11/11] selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl Matthieu Baerts (NGI0)
@ 2026-05-07  1:30 ` patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-07  1:30 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: martineau, geliang, davem, edumazet, kuba, pabeni, horms, cpaasch,
	netdev, mptcp, linux-kernel, stable, shuah, linux-kselftest

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 05 May 2026 17:00:48 +0200 you wrote:
> Here are various fixes, mainly related to ADD_ADDRs:
> 
> - Patch 1: save ADD_ADDR for rtx with ID0 when needed. A fix for v6.1.
> 
> - Patch 2: remove unneeded exception for ID 0. A fix for v5.10.
> 
> - Patches 3-5: fix potential data-race and leaks during ADD_ADDR rtx. A
>   fix for v5.10.
> 
> [...]

Here is the summary with links:
  - [net,01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0
    https://git.kernel.org/netdev/net/c/b12014d2d36e
  - [net,02/11] mptcp: pm: ADD_ADDR rtx: allow ID 0
    https://git.kernel.org/netdev/net/c/03f324f3f1f7
  - [net,03/11] mptcp: pm: ADD_ADDR rtx: fix potential data-race
    https://git.kernel.org/netdev/net/c/5cd6e0ad79d2
  - [net,04/11] mptcp: pm: ADD_ADDR rtx: always decrease sk refcount
    https://git.kernel.org/netdev/net/c/9634cb35af17
  - [net,05/11] mptcp: pm: ADD_ADDR rtx: free sk if last
    https://git.kernel.org/netdev/net/c/b7b9a4615697
  - [net,06/11] mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker
    https://git.kernel.org/netdev/net/c/3cf12492891c
  - [net,07/11] mptcp: pm: ADD_ADDR rtx: skip inactive subflows
    https://git.kernel.org/netdev/net/c/c6d395e2de13
  - [net,08/11] mptcp: pm: ADD_ADDR rtx: return early if no retrans
    https://git.kernel.org/netdev/net/c/62a9b19dce77
  - [net,09/11] mptcp: pm: prio: skip closed subflows
    https://git.kernel.org/netdev/net/c/166b78344031
  - [net,10/11] selftests: mptcp: check output: catch cmd errors
    https://git.kernel.org/netdev/net/c/65db7b27b90e
  - [net,11/11] selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl
    https://git.kernel.org/netdev/net/c/53705ddfa184

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] 13+ messages in thread

end of thread, other threads:[~2026-05-07  1:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 15:00 [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 01/11] mptcp: pm: kernel: correctly retransmit ADD_ADDR ID 0 Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 02/11] mptcp: pm: ADD_ADDR rtx: allow " Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 03/11] mptcp: pm: ADD_ADDR rtx: fix potential data-race Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 04/11] mptcp: pm: ADD_ADDR rtx: always decrease sk refcount Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 05/11] mptcp: pm: ADD_ADDR rtx: free sk if last Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 06/11] mptcp: pm: ADD_ADDR rtx: resched blocked ADD_ADDR quicker Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 07/11] mptcp: pm: ADD_ADDR rtx: skip inactive subflows Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 08/11] mptcp: pm: ADD_ADDR rtx: return early if no retrans Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 09/11] mptcp: pm: prio: skip closed subflows Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 10/11] selftests: mptcp: check output: catch cmd errors Matthieu Baerts (NGI0)
2026-05-05 15:00 ` [PATCH net 11/11] selftests: mptcp: pm: restrict 'unknown' check to pm_nl_ctl Matthieu Baerts (NGI0)
2026-05-07  1:30 ` [PATCH net 00/11] mptcp: pm: misc. fixes for v7.1-rc3 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