netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges
@ 2025-06-26 12:34 Eric Dumazet
  2025-06-26 12:34 ` [PATCH net-next 1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-06-26 12:34 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Simon Horman, Kuniyuki Iwashima, netdev, eric.dumazet,
	Eric Dumazet

This series combines a fix from xin.guo and a new packetdrill test.

Eric Dumazet (1):
  selftests/net: packetdrill: add tcp_dsack_mult.pkt

xin.guo (1):
  tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range

 net/ipv4/tcp_input.c                          |  3 +-
 .../net/packetdrill/tcp_dsack_mult.pkt        | 45 +++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_dsack_mult.pkt

-- 
2.50.0.727.gbf7dc18ff4-goog


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

* [PATCH net-next 1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range
  2025-06-26 12:34 [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges Eric Dumazet
@ 2025-06-26 12:34 ` Eric Dumazet
  2025-06-26 12:34 ` [PATCH net-next 2/2] selftests/net: packetdrill: add tcp_dsack_mult.pkt Eric Dumazet
  2025-06-27 22:50 ` [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-06-26 12:34 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Simon Horman, Kuniyuki Iwashima, netdev, eric.dumazet, xin.guo,
	Eric Dumazet

From: "xin.guo" <guoxin0309@gmail.com>

If the new coming segment covers more than one skbs in the ofo queue,
and which seq is equal to rcv_nxt, then the sequence range
that is duplicated will be sent as DUP SACK, the detail as below,
in step6, the {501,2001} range is clearly including too much
DUP SACK range, in violation of RFC 2883 rules.

1. client > server: Flags [.], seq 501:1001, ack 1325288529, win 20000, length 500
2. server > client: Flags [.], ack 1, [nop,nop,sack 1 {501:1001}], length 0
3. client > server: Flags [.], seq 1501:2001, ack 1325288529, win 20000, length 500
4. server > client: Flags [.], ack 1, [nop,nop,sack 2 {1501:2001} {501:1001}], length 0
5. client > server: Flags [.], seq 1:2001, ack 1325288529, win 20000, length 2000
6. server > client: Flags [.], ack 2001, [nop,nop,sack 1 {501:2001}], length 0

After this fix, the final ACK is as below:

6. server > client: Flags [.], ack 2001, options [nop,nop,sack 1 {501:1001}], length 0

[edumazet] added a new packetdrill test in the following patch.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: xin.guo <guoxin0309@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_input.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 19a1542883dfba7211e08dcb44c82b4564d76f04..79e3bfb0108fd4e21de2295e879fbd521daa62f9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4845,8 +4845,9 @@ static void tcp_ofo_queue(struct sock *sk)
 
 		if (before(TCP_SKB_CB(skb)->seq, dsack_high)) {
 			__u32 dsack = dsack_high;
+
 			if (before(TCP_SKB_CB(skb)->end_seq, dsack_high))
-				dsack_high = TCP_SKB_CB(skb)->end_seq;
+				dsack = TCP_SKB_CB(skb)->end_seq;
 			tcp_dsack_extend(sk, TCP_SKB_CB(skb)->seq, dsack);
 		}
 		p = rb_next(p);
-- 
2.50.0.727.gbf7dc18ff4-goog


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

* [PATCH net-next 2/2] selftests/net: packetdrill: add tcp_dsack_mult.pkt
  2025-06-26 12:34 [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges Eric Dumazet
  2025-06-26 12:34 ` [PATCH net-next 1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range Eric Dumazet
@ 2025-06-26 12:34 ` Eric Dumazet
  2025-06-27 22:50 ` [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-06-26 12:34 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni, Neal Cardwell
  Cc: Simon Horman, Kuniyuki Iwashima, netdev, eric.dumazet,
	Eric Dumazet, xin.guo

Test DSACK behavior with non contiguous ranges.

Without prior fix (tcp: fix tcp_ofo_queue() to avoid including
too much DUP SACK range) this would fail with:

tcp_dsack_mult.pkt:37: error handling packet: bad value outbound TCP option 5
script packet:  0.100682 . 1:1(0) ack 6001 <nop,nop,sack 1001:3001 7001:8001>
actual packet:  0.100679 . 1:1(0) ack 6001 win 1097 <nop,nop,sack 1001:6001 7001:8001>

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: xin.guo <guoxin0309@gmail.com>
---
 .../net/packetdrill/tcp_dsack_mult.pkt        | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_dsack_mult.pkt

diff --git a/tools/testing/selftests/net/packetdrill/tcp_dsack_mult.pkt b/tools/testing/selftests/net/packetdrill/tcp_dsack_mult.pkt
new file mode 100644
index 0000000000000000000000000000000000000000..c790d0af635eb471b12a3fde77f62885fed99342
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_dsack_mult.pkt
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+// Test various DSACK (RFC 2883) behaviors.
+
+--mss=1000
+
+`./defaults.sh`
+
+
+    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+   +0 bind(3, ..., ...) = 0
+   +0 listen(3, 1) = 0
+
+   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
+   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
+  +.1 < . 1:1(0) ack 1 win 1024
+   +0 accept(3, ..., ...) = 4
+
+// First SACK range.
+   +0 < P. 1001:2001(1000) ack 1 win 1024
+   +0 > . 1:1(0) ack 1 <nop, nop, sack 1001:2001>
+
+// Check SACK coalescing (contiguous sequence).
+   +0 < P. 2001:3001(1000) ack 1 win 1024
+   +0 > . 1:1(0) ack 1 <nop,nop,sack 1001:3001>
+
+// Check we have two SACK ranges for non contiguous sequences.
+   +0 < P. 4001:5001(1000) ack 1 win 1024
+   +0 > . 1:1(0) ack 1 <nop,nop,sack 4001:5001 1001:3001>
+
+// Three ranges.
+   +0 < P. 7001:8001(1000) ack 1 win 1024
+   +0 > . 1:1(0) ack 1 <nop,nop,sack 7001:8001 4001:5001 1001:3001>
+
+// DSACK (1001:3001) + SACK (6001:7001)
+   +0 < P. 1:6001(6000) ack 1 win 1024
+   +0 > . 1:1(0) ack 6001 <nop,nop,sack 1001:3001 7001:8001>
+
+// DSACK (7001:8001)
+   +0 < P. 6001:8001(2000) ack 1 win 1024
+   +0 > . 1:1(0) ack 8001 <nop,nop,sack 7001:8001>
+
+// DSACK for an older segment.
+   +0 < P. 1:1001(1000) ack 1 win 1024
+   +0 > . 1:1(0) ack 8001 <nop,nop,sack 1:1001>
-- 
2.50.0.727.gbf7dc18ff4-goog


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

* Re: [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges
  2025-06-26 12:34 [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges Eric Dumazet
  2025-06-26 12:34 ` [PATCH net-next 1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range Eric Dumazet
  2025-06-26 12:34 ` [PATCH net-next 2/2] selftests/net: packetdrill: add tcp_dsack_mult.pkt Eric Dumazet
@ 2025-06-27 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-27 22:50 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, ncardwell, horms, kuniyu, netdev,
	eric.dumazet

Hello:

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

On Thu, 26 Jun 2025 12:34:18 +0000 you wrote:
> This series combines a fix from xin.guo and a new packetdrill test.
> 
> Eric Dumazet (1):
>   selftests/net: packetdrill: add tcp_dsack_mult.pkt
> 
> xin.guo (1):
>   tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range
    https://git.kernel.org/netdev/net-next/c/a041f70e573e
  - [net-next,2/2] selftests/net: packetdrill: add tcp_dsack_mult.pkt
    https://git.kernel.org/netdev/net-next/c/8cc8d749dc7e

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

end of thread, other threads:[~2025-06-27 22:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 12:34 [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges Eric Dumazet
2025-06-26 12:34 ` [PATCH net-next 1/2] tcp: fix tcp_ofo_queue() to avoid including too much DUP SACK range Eric Dumazet
2025-06-26 12:34 ` [PATCH net-next 2/2] selftests/net: packetdrill: add tcp_dsack_mult.pkt Eric Dumazet
2025-06-27 22:50 ` [PATCH net-next 0/2] tcp: fix DSACK bug with non contiguous ranges 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).