public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2
@ 2026-04-27 19:54 Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk Matthieu Baerts (NGI0)
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-04-27 19:54 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Gang Yan,
	stable, Sashiko, Lance Tuller

Here are various unrelated fixes:

- Patches 1-2: set timestamp flags on 'ssk', not 'sk' (typo); Plus do
  that with sleepable lock_sock/release_sock. A fix for v5.14.

- Patch 3: respect SO_LINGER(1, 0) by sending MP_FASTCLOSE at close time
  as expected. A fix for v6.1.

- Patch 4: reset fullmesh counter after a flush. A fix for v6.19.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Gang Yan (2):
      mptcp: sockopt: set timestamp flags on subflow socket, not msk
      mptcp: fix scheduling with atomic in timestamp sockopt

Matthieu Baerts (NGI0) (2):
      mptcp: fastclose msk when linger time is 0
      mptcp: pm: kernel: reset fullmesh counter after flush

 net/mptcp/pm_kernel.c |  1 +
 net/mptcp/protocol.c  |  3 ++-
 net/mptcp/sockopt.c   | 12 ++++++------
 3 files changed, 9 insertions(+), 7 deletions(-)
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260427-net-mptcp-misc-fixes-7-1-rc2-17de477cd8c1

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


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

* [PATCH net 1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk
  2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
@ 2026-04-27 19:54 ` Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 2/4] mptcp: fix scheduling with atomic in timestamp sockopt Matthieu Baerts (NGI0)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-04-27 19:54 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Gang Yan,
	stable

From: Gang Yan <yangang@kylinos.cn>

Both mptcp_setsockopt_sol_socket_tstamp() and
mptcp_setsockopt_sol_socket_timestamping() iterate over subflows,
acquire the subflow socket lock, but then erroneously pass the MPTCP
msk socket to sock_set_timestamp() / sock_set_timestamping() instead
of the subflow ssk. As a result, the timestamp flags are set on the
wrong socket and have no effect on the actual subflows.

Pass ssk instead of sk to both helpers.

Fixes: 9061f24bf82e ("mptcp: sockopt: propagate timestamp request to subflows")
Cc: stable@vger.kernel.org
Assisted-by: GLM:5.1
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/sockopt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index de90a2897d2d..79db15903e7a 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -161,7 +161,7 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		bool slow = lock_sock_fast(ssk);
 
-		sock_set_timestamp(sk, optname, !!val);
+		sock_set_timestamp(ssk, optname, !!val);
 		unlock_sock_fast(ssk, slow);
 	}
 
@@ -237,7 +237,7 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
 		bool slow = lock_sock_fast(ssk);
 
-		sock_set_timestamping(sk, optname, timestamping);
+		sock_set_timestamping(ssk, optname, timestamping);
 		unlock_sock_fast(ssk, slow);
 	}
 

-- 
2.53.0


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

* [PATCH net 2/4] mptcp: fix scheduling with atomic in timestamp sockopt
  2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk Matthieu Baerts (NGI0)
@ 2026-04-27 19:54 ` Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 3/4] mptcp: fastclose msk when linger time is 0 Matthieu Baerts (NGI0)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-04-27 19:54 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Gang Yan,
	stable, Sashiko

From: Gang Yan <yangang@kylinos.cn>

Using lock_sock_fast() (atomic context) around sock_set_timestamp()
and sock_set_timestamping() is unsafe, as both helpers can sleep.

Replace lock_sock_fast() with sleepable lock_sock()/release_sock()
to avoid scheduling while atomic panic.

Fixes: 9061f24bf82e ("mptcp: sockopt: propagate timestamp request to subflows")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260420093343.16443-1-gang.yan@linux.dev
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/sockopt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 79db15903e7a..0efe40be2fde 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -159,10 +159,10 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam
 	lock_sock(sk);
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
-		bool slow = lock_sock_fast(ssk);
 
+		lock_sock(ssk);
 		sock_set_timestamp(ssk, optname, !!val);
-		unlock_sock_fast(ssk, slow);
+		release_sock(ssk);
 	}
 
 	release_sock(sk);
@@ -235,10 +235,10 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
 
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
-		bool slow = lock_sock_fast(ssk);
 
+		lock_sock(ssk);
 		sock_set_timestamping(ssk, optname, timestamping);
-		unlock_sock_fast(ssk, slow);
+		release_sock(ssk);
 	}
 
 	release_sock(sk);

-- 
2.53.0


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

* [PATCH net 3/4] mptcp: fastclose msk when linger time is 0
  2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 2/4] mptcp: fix scheduling with atomic in timestamp sockopt Matthieu Baerts (NGI0)
@ 2026-04-27 19:54 ` Matthieu Baerts (NGI0)
  2026-04-27 19:54 ` [PATCH net 4/4] mptcp: pm: kernel: reset fullmesh counter after flush Matthieu Baerts (NGI0)
  2026-04-29  1:50 ` [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-04-27 19:54 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable,
	Lance Tuller

The SO_LINGER socket option has been supported for a while with MPTCP
sockets [1], but it didn't cause the equivalent of a TCP reset as
expected when enabled and its time was set to 0. This was causing some
behavioural differences with TCP where some connections were not
promptly stopped as expected.

To fix that, an extra condition is checked at close() time before
sending an MP_FASTCLOSE, the MPTCP equivalent of a TCP reset.

Note that backporting up to [1] will be difficult as more changes are
needed to be able to send MP_FASTCLOSE. It seems better to stop at [2],
which was supposed to already imitate TCP.

Validated with MPTCP packetdrill tests [3].

Fixes: 268b12387460 ("mptcp: setsockopt: support SO_LINGER") [1]
Fixes: d21f83485518 ("mptcp: use fastclose on more edge scenarios") [2]
Cc: stable@vger.kernel.org
Reported-by: Lance Tuller <lance@lance0.com>
Closes: https://github.com/lance0/xfr/pull/67
Link: https://github.com/multipath-tcp/packetdrill/pull/196 [3]
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 718e910ff23f..4546a8b09884 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3302,7 +3302,8 @@ bool __mptcp_close(struct sock *sk, long timeout)
 		goto cleanup;
 	}
 
-	if (mptcp_data_avail(msk) || timeout < 0) {
+	if (mptcp_data_avail(msk) || timeout < 0 ||
+	    (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime)) {
 		/* If the msk has read data, or the caller explicitly ask it,
 		 * do the MPTCP equivalent of TCP reset, aka MPTCP fastclose
 		 */

-- 
2.53.0


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

* [PATCH net 4/4] mptcp: pm: kernel: reset fullmesh counter after flush
  2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
                   ` (2 preceding siblings ...)
  2026-04-27 19:54 ` [PATCH net 3/4] mptcp: fastclose msk when linger time is 0 Matthieu Baerts (NGI0)
@ 2026-04-27 19:54 ` Matthieu Baerts (NGI0)
  2026-04-29  1:50 ` [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-04-27 19:54 UTC (permalink / raw)
  To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Florian Westphal
  Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), stable,
	Sashiko

This variable counts how many MPTCP endpoints have a 'fullmesh' flag
set. After having flushed all MPTCP endpoints, it is then needed to
reset this counter.

Without this reset, this counter exposed to the userspace is wrong, but
also non-fullmesh endpoints added after the flush will not be taken into
account to create subflows in reaction to ADD_ADDRs.

Fixes: f88191c7f361 ("mptcp: pm: in-kernel: record fullmesh endp nb")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260422-mptcp-inc-limits-v6-0-903181771530%40kernel.org?part=15
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_kernel.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 0ebf43be9939..c9f1e5af3cd3 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -1278,6 +1278,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
 	WRITE_ONCE(pernet->endp_signal_max, 0);
 	WRITE_ONCE(pernet->endp_subflow_max, 0);
 	WRITE_ONCE(pernet->endp_laminar_max, 0);
+	WRITE_ONCE(pernet->endp_fullmesh_max, 0);
 	pernet->endpoints = 0;
 }
 

-- 
2.53.0


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

* Re: [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2
  2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
                   ` (3 preceding siblings ...)
  2026-04-27 19:54 ` [PATCH net 4/4] mptcp: pm: kernel: reset fullmesh counter after flush Matthieu Baerts (NGI0)
@ 2026-04-29  1:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-29  1:50 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: martineau, geliang, davem, edumazet, kuba, pabeni, horms, fw,
	netdev, mptcp, linux-kernel, yangang, stable, sashiko-bot, lance

Hello:

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

On Mon, 27 Apr 2026 21:54:32 +0200 you wrote:
> Here are various unrelated fixes:
> 
> - Patches 1-2: set timestamp flags on 'ssk', not 'sk' (typo); Plus do
>   that with sleepable lock_sock/release_sock. A fix for v5.14.
> 
> - Patch 3: respect SO_LINGER(1, 0) by sending MP_FASTCLOSE at close time
>   as expected. A fix for v6.1.
> 
> [...]

Here is the summary with links:
  - [net,1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk
    https://git.kernel.org/netdev/net/c/5f95c21fc23a
  - [net,2/4] mptcp: fix scheduling with atomic in timestamp sockopt
    https://git.kernel.org/netdev/net/c/b5c52908d52c
  - [net,3/4] mptcp: fastclose msk when linger time is 0
    https://git.kernel.org/netdev/net/c/f14d6e9c3678
  - [net,4/4] mptcp: pm: kernel: reset fullmesh counter after flush
    https://git.kernel.org/netdev/net/c/1774d3cf3cf1

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

end of thread, other threads:[~2026-04-29  1:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 19:54 [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 Matthieu Baerts (NGI0)
2026-04-27 19:54 ` [PATCH net 1/4] mptcp: sockopt: set timestamp flags on subflow socket, not msk Matthieu Baerts (NGI0)
2026-04-27 19:54 ` [PATCH net 2/4] mptcp: fix scheduling with atomic in timestamp sockopt Matthieu Baerts (NGI0)
2026-04-27 19:54 ` [PATCH net 3/4] mptcp: fastclose msk when linger time is 0 Matthieu Baerts (NGI0)
2026-04-27 19:54 ` [PATCH net 4/4] mptcp: pm: kernel: reset fullmesh counter after flush Matthieu Baerts (NGI0)
2026-04-29  1:50 ` [PATCH net 0/4] mptcp: misc fixes for v7.1-rc2 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