netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/2] tcp: a couple of fixes
@ 2025-07-21 17:20 Paolo Abeni
  2025-07-21 17:20 ` [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer Paolo Abeni
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Paolo Abeni @ 2025-07-21 17:20 UTC (permalink / raw)
  To: netdev
  Cc: Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima, David S. Miller,
	David Ahern, Jakub Kicinski, Simon Horman, Matthieu Baerts

This series includes a couple of follow-up for the recent tcp receiver
changes, addressing issues outlined by the nipa CI and the mptcp
self-tests.

Note that despite the affected self-tests where MPTCP ones, the issues
are really in the TCP code, see patch 1 for the details.

v1 -> v2:
  - rework patch 1/2
v1: https://lore.kernel.org/netdev/cover.1752859383.git.pabeni@redhat.com

Paolo Abeni (2):
  tcp: do not set a zero size receive buffer
  tcp: do not increment BeyondWindow MIB for old seq

 net/ipv4/tcp_input.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.50.0


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

* [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer
  2025-07-21 17:20 [PATCH v2 net-next 0/2] tcp: a couple of fixes Paolo Abeni
@ 2025-07-21 17:20 ` Paolo Abeni
  2025-07-21 18:21   ` Eric Dumazet
  2025-07-21 17:20 ` [PATCH v2 net-next 2/2] tcp: do not increment BeyondWindow MIB for old seq Paolo Abeni
  2025-07-23  1:30 ` [PATCH v2 net-next 0/2] tcp: a couple of fixes patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2025-07-21 17:20 UTC (permalink / raw)
  To: netdev
  Cc: Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima, David S. Miller,
	David Ahern, Jakub Kicinski, Simon Horman, Matthieu Baerts

The nipa CI is reporting frequent failures in the mptcp_connect
self-tests.

In the failing scenarios (TCP -> MPTCP) the involved sockets are
actually plain TCP ones, as fallback for passive socket at 2whs
time cause the MPTCP listener to actually create a TCP socket.

The transfer is stuck due to the receiver buffer being zero.
With the stronger check in place, tcp_clamp_window() can be invoked
while the TCP socket has sk_rmem_alloc == 0, and the receive buffer
will be zeroed, too.

Check for the critical condition in tcp_prune_queue() and just
drop the packet without shrinking the receiver buffer.

Fixes: 1d2fbaad7cd8 ("tcp: stronger sk_rcvbuf checks")
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
v1 -> v2:
  - do not account for truesize, check for 0 rmem instead
---
 net/ipv4/tcp_input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 672cbfbdcec1..81b6d3770812 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5549,6 +5549,10 @@ static int tcp_prune_queue(struct sock *sk, const struct sk_buff *in_skb)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 
+	/* Do nothing if our queues are empty. */
+	if (!atomic_read(&sk->sk_rmem_alloc))
+		return -1;
+
 	NET_INC_STATS(sock_net(sk), LINUX_MIB_PRUNECALLED);
 
 	if (!tcp_can_ingest(sk, in_skb))
-- 
2.50.0


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

* [PATCH v2 net-next 2/2] tcp: do not increment BeyondWindow MIB for old seq
  2025-07-21 17:20 [PATCH v2 net-next 0/2] tcp: a couple of fixes Paolo Abeni
  2025-07-21 17:20 ` [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer Paolo Abeni
@ 2025-07-21 17:20 ` Paolo Abeni
  2025-07-23  1:30 ` [PATCH v2 net-next 0/2] tcp: a couple of fixes patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2025-07-21 17:20 UTC (permalink / raw)
  To: netdev
  Cc: Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima, David S. Miller,
	David Ahern, Jakub Kicinski, Simon Horman, Matthieu Baerts

The mentioned MIB is currently incremented even when a packet
with an old sequence number (i.e. a zero window probe) is received,
which is IMHO misleading.

Explicitly restrict such MIB increment at the relevant events.

Fixes: 6c758062c64d ("tcp: add LINUX_MIB_BEYOND_WINDOW")
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv4/tcp_input.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 81b6d3770812..71b76e98371a 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5915,7 +5915,11 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
 		if (!th->rst) {
 			if (th->syn)
 				goto syn_challenge;
-			NET_INC_STATS(sock_net(sk), LINUX_MIB_BEYOND_WINDOW);
+
+			if (reason == SKB_DROP_REASON_TCP_INVALID_SEQUENCE ||
+			    reason == SKB_DROP_REASON_TCP_INVALID_END_SEQUENCE)
+				NET_INC_STATS(sock_net(sk),
+					      LINUX_MIB_BEYOND_WINDOW);
 			if (!tcp_oow_rate_limited(sock_net(sk), skb,
 						  LINUX_MIB_TCPACKSKIPPEDSEQ,
 						  &tp->last_oow_ack_time))
-- 
2.50.0


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

* Re: [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer
  2025-07-21 17:20 ` [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer Paolo Abeni
@ 2025-07-21 18:21   ` Eric Dumazet
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2025-07-21 18:21 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: netdev, Neal Cardwell, Kuniyuki Iwashima, David S. Miller,
	David Ahern, Jakub Kicinski, Simon Horman, Matthieu Baerts

On Mon, Jul 21, 2025 at 10:21 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> The nipa CI is reporting frequent failures in the mptcp_connect
> self-tests.
>
> In the failing scenarios (TCP -> MPTCP) the involved sockets are
> actually plain TCP ones, as fallback for passive socket at 2whs
> time cause the MPTCP listener to actually create a TCP socket.
>
> The transfer is stuck due to the receiver buffer being zero.
> With the stronger check in place, tcp_clamp_window() can be invoked
> while the TCP socket has sk_rmem_alloc == 0, and the receive buffer
> will be zeroed, too.
>
> Check for the critical condition in tcp_prune_queue() and just
> drop the packet without shrinking the receiver buffer.
>
> Fixes: 1d2fbaad7cd8 ("tcp: stronger sk_rcvbuf checks")
> Suggested-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks a lot !

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

* Re: [PATCH v2 net-next 0/2] tcp: a couple of fixes
  2025-07-21 17:20 [PATCH v2 net-next 0/2] tcp: a couple of fixes Paolo Abeni
  2025-07-21 17:20 ` [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer Paolo Abeni
  2025-07-21 17:20 ` [PATCH v2 net-next 2/2] tcp: do not increment BeyondWindow MIB for old seq Paolo Abeni
@ 2025-07-23  1:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-23  1:30 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: netdev, edumazet, ncardwell, kuniyu, davem, dsahern, kuba, horms,
	matttbe

Hello:

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

On Mon, 21 Jul 2025 19:20:20 +0200 you wrote:
> This series includes a couple of follow-up for the recent tcp receiver
> changes, addressing issues outlined by the nipa CI and the mptcp
> self-tests.
> 
> Note that despite the affected self-tests where MPTCP ones, the issues
> are really in the TCP code, see patch 1 for the details.
> 
> [...]

Here is the summary with links:
  - [v2,net-next,1/2] tcp: do not set a zero size receive buffer
    https://git.kernel.org/netdev/net-next/c/972ca7a3bc9a
  - [v2,net-next,2/2] tcp: do not increment BeyondWindow MIB for old seq
    https://git.kernel.org/netdev/net-next/c/b115c7758802

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

end of thread, other threads:[~2025-07-23  1:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 17:20 [PATCH v2 net-next 0/2] tcp: a couple of fixes Paolo Abeni
2025-07-21 17:20 ` [PATCH v2 net-next 1/2] tcp: do not set a zero size receive buffer Paolo Abeni
2025-07-21 18:21   ` Eric Dumazet
2025-07-21 17:20 ` [PATCH v2 net-next 2/2] tcp: do not increment BeyondWindow MIB for old seq Paolo Abeni
2025-07-23  1:30 ` [PATCH v2 net-next 0/2] tcp: a couple of fixes 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).