Merge branch 'tcp-fix-dsack-bug-with-non-contiguous-ranges'

Eric Dumazet says:

====================
tcp: fix DSACK bug with non contiguous ranges

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

Link: https://patch.msgid.link/20250626123420.1933835-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2025-06-27 15:35:08 -07:00
commit 2f5a411759
2 changed files with 47 additions and 1 deletions

View File

@ -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);

View File

@ -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>