Skip to content

Commit cf94b3c

Browse files
mrprekuba-moo
authored andcommitted
selftests/net: packetdrill: cover RFC 5961 5.2 challenge ACK on both edges
RFC 5961 Section 5.2 / RFC 793 Section 3.9 require a challenge ACK whenever an incoming SEG.ACK falls outside [SND.UNA - MAX.SND.WND, SND.NXT]. There is currently no packetdrill coverage for either edge. Add tcp_rfc5961_ack-out-of-window.pkt, which in a single passive-open connection exercises: - Upper edge (SEG.ACK > SND.NXT): peer ACKs data that was never sent before the server has transmitted anything. - Lower edge (SEG.ACK < SND.UNA - MAX.SND.WND): after the server has sent 2000 bytes (the peer-advertised rwnd forces two 1000-byte segments, both acknowledged), peer sends an ACK that is older than the acceptable window. Both cases must elicit a challenge ACK <SEQ = SND.NXT, ACK = RCV.NXT, CTL = ACK>. The per-socket RFC 5961 Section 7 rate limit is disabled for the duration of the test so that both challenge ACKs can fire back-to-back. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260422123605.320000-3-jiayuan.chen@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 42726ec commit cf94b3c

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
//
3+
// RFC 5961 Section 5.2 / RFC 793 Section 3.9: an incoming segment's
4+
// ACK value must lie in [SND.UNA - MAX.SND.WND, SND.NXT]; otherwise
5+
// the receiver MUST discard the segment and send a challenge ACK
6+
// back. Exercise both edges of that window in a single connection.
7+
8+
`./defaults.sh
9+
sysctl -q net.ipv4.tcp_invalid_ratelimit=0
10+
`
11+
12+
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
13+
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
14+
+0 bind(3, ..., ...) = 0
15+
+0 listen(3, 1) = 0
16+
17+
// Three-way handshake. Peer advertises rwnd = 1000 (no wscale), so
18+
// MAX.SND.WND is tracked as 1000.
19+
+0 < S 0:0(0) win 1000 <mss 1000,sackOK,nop,nop,nop,wscale 0>
20+
+0 > S. 0:0(0) ack 1 <...>
21+
+.1 < . 1:1(0) ack 1 win 1000
22+
+0 accept(3, ..., ...) = 4
23+
24+
// ---- Upper edge: SEG.ACK > SND.NXT --------------------------------
25+
// Server has sent nothing yet, so SND.UNA = SND.NXT = 1.
26+
// Peer sends a pure ACK with SEG.ACK = 2, beyond SND.NXT.
27+
+0 < . 1:1(0) ack 2 win 1000
28+
// Expect a challenge ACK: <SEQ = SND.NXT = 1, ACK = RCV.NXT = 1>.
29+
+0 > . 1:1(0) ack 1
30+
31+
// Advance SND.UNA past MAX.SND.WND so that the lower edge becomes
32+
// reachable. Issue two 1-MSS writes so each skb is exactly one MSS
33+
// and PSH is set by tcp_push() at the end of each sendmsg, keeping
34+
// the setup independent of the TSO / tcp_fragment split path.
35+
+0 write(4, ..., 1000) = 1000
36+
+0 > P. 1:1001(1000) ack 1
37+
+.01 < . 1:1(0) ack 1001 win 1000
38+
+0 write(4, ..., 1000) = 1000
39+
+0 > P. 1001:2001(1000) ack 1
40+
+.01 < . 1:1(0) ack 2001 win 1000
41+
// Now SND.UNA = SND.NXT = 2001, MAX.SND.WND = 1000, bytes_acked = 2000.
42+
43+
// ---- Lower edge: SEG.ACK < SND.UNA - MAX.SND.WND ------------------
44+
// SND.UNA - MAX.SND.WND = 2001 - 1000 = 1001, so SEG.ACK = 1000 falls
45+
// below the acceptable range.
46+
+0 < . 1:1(0) ack 1000 win 1000
47+
// Expect a challenge ACK: <SEQ = SND.NXT = 2001, ACK = RCV.NXT = 1>.
48+
+0 > . 2001:2001(0) ack 1

0 commit comments

Comments
 (0)