From: Eric Dumazet <edumazet@kernel.org>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Neal Cardwell <ncardwell@google.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
Simon Horman <horms@kernel.org>,
Flavius-Romeo Mazilu <flavius.mazilu@stud.acs.upb.ro>,
Michael Tuexen <tuexen@fh-muenster.de>,
netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net-next 2/2] selftests/net: packetdrill: add tests for ACK of ISS
Date: Wed, 18 Nov 2026 18:26:54 +0100 [thread overview]
Message-ID: <20261118172654.1267071-3-edumazet@kernel.org> (raw)
In-Reply-To: <20261118172654.1267071-1-edumazet@kernel.org>
Once a connection is established, a segment with SEG.ACK == ISS
acknowledges bytes we never sent. It must be dropped and a challenge
ACK sent back (RFC 5961 Section 5.2), regardless of which side
opened the connection.
Add four tests covering the ways a socket can be established:
- tcp_rfc5961_ack-iss-server.pkt: passive open
- tcp_rfc5961_ack-iss-client.pkt: active open
- tcp_rfc5961_ack-iss-fastopen-client.pkt: active open, data in SYN
- tcp_rfc5961_ack-iss-simultaneous-open.pkt: crossed SYNs
Each test also checks that SEG.ACK == ISS + 1 is still silently
accepted as a genuine old ACK.
Only the passive open test passes without the previous patch.
Link: https://mailarchive.ietf.org/arch/msg/tcpm/ym6lb-UkrW2298LRnTLxCysoo0g/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
.../tcp_rfc5961_ack-iss-client.pkt | 46 +++++++++++++++++++
.../tcp_rfc5961_ack-iss-fastopen-client.pkt | 40 ++++++++++++++++
.../tcp_rfc5961_ack-iss-server.pkt | 45 ++++++++++++++++++
.../tcp_rfc5961_ack-iss-simultaneous-open.pkt | 42 +++++++++++++++++
4 files changed, 173 insertions(+)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-client.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-fastopen-client.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-server.pkt
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-simultaneous-open.pkt
diff --git a/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-client.pkt b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-client.pkt
new file mode 100644
index 0000000000000000000000000000000000000000..50c0638a5219d8389ab433765f9f65fa0f0a8ffc
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-client.pkt
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Active open: once the connection is established, SND.UNA is at least
+// ISS + 1. A segment with SEG.ACK = ISS acknowledges nothing we ever
+// sent past the SYN, and the SYN itself can not be acked "again" as a
+// stale duplicate: no ACK carrying ISS was ever valid on this
+// connection. It must be treated like any other ACK for bytes we never
+// sent (RFC 5961 Section 5.2): dropped, and a challenge ACK sent back.
+//
+// The SYN consumes one sequence number but is not a payload byte, so it
+// must not widen the range of acceptable old ACKs.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_invalid_ratelimit=0
+`
+
+ 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+ +0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
+ +0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+ +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
+ +0 > S 0:0(0) <...>
++.01 < S. 0:0(0) ack 1 win 10000 <mss 1000,nop,nop,sackOK,nop,wscale 0>
+ +0 > . 1:1(0) ack 1
+
+// SND.UNA = SND.NXT = ISS + 1, no payload acked yet.
+// SEG.ACK = ISS must trigger a challenge ACK.
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1:1(0) ack 1
+
+// Get 1000 bytes of payload acked.
+ +0 write(3, ..., 1000) = 1000
+ +0 > P. 1:1001(1000) ack 1
++.01 < . 1:1(0) ack 1001 win 10000
+
+// SND.UNA = ISS + 1001. Old ACKs in [ISS + 1, ISS + 1001] are valid
+// duplicates, but SEG.ACK = ISS is still below anything the peer could
+// have legitimately sent.
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1001:1001(0) ack 1
+
+// SEG.ACK = ISS + 1 is a genuine old ACK: silently accepted, no
+// challenge ACK. The next packet on the wire must be our new data.
++.01 < . 1:1(0) ack 1 win 10000
++.01 write(3, ..., 1000) = 1000
+ +0 > P. 1001:2001(1000) ack 1
++.01 < . 1:1(0) ack 2001 win 10000
diff --git a/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-fastopen-client.pkt b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-fastopen-client.pkt
new file mode 100644
index 0000000000000000000000000000000000000000..5e8c7f8ee7ddb812761dd5dbc72e2f01ff46c644
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-fastopen-client.pkt
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Fast Open variant of tcp_rfc5961_ack-iss-client.pkt.
+//
+// The SYN carries data, and the SYN-ACK acks both the SYN and its
+// payload. SEG.ACK = ISS must still trigger a challenge ACK, while
+// SEG.ACK = ISS + 1 (SYN acked, payload not yet) is a valid old ACK.
+
+`./defaults.sh
+ ./set_sysctls.py /proc/sys/net/ipv4/tcp_timestamps=0 \
+ /proc/sys/net/ipv4/tcp_invalid_ratelimit=0`
+
+// Cache warmup: send a Fast Open cookie request
+ 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
+ +0 sendto(3, ..., 0, MSG_FASTOPEN, ..., ...) = -1 EINPROGRESS (Operation is now in progress)
+ +0 > S 0:0(0) <mss 1460,nop,nop,sackOK,nop,wscale 8,FO,nop,nop>
+ +0 < S. 123:123(0) ack 1 win 14600 <mss 1460,nop,nop,sackOK,nop,wscale 6,FO abcd1234,nop,nop>
+ +0 > . 1:1(0) ack 1
+ +0 close(3) = 0
+ +0 > F. 1:1(0) ack 1
+ +0 < F. 1:1(0) ack 2 win 92
+ +0 > . 2:2(0) ack 2
+
+// SYN + 500 bytes of payload, all acked by the SYN-ACK.
+ +0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 4
+ +0 sendto(4, ..., 500, MSG_FASTOPEN, ..., ...) = 500
+ +0 > S 0:500(500) <mss 1460,nop,nop,sackOK,nop,wscale 8,FO abcd1234,nop,nop>
+ +.01 < S. 0:0(0) ack 501 win 14600 <mss 1460,nop,nop,sackOK,nop,wscale 6>
+ +0 > . 501:501(0) ack 1
+
+// SND.UNA = ISS + 501. SEG.ACK = ISS must trigger a challenge ACK.
+ +.01 < . 1:1(0) ack 0 win 1000
+ +0 > . 501:501(0) ack 1
+
+// SEG.ACK = ISS + 1 is a genuine old ACK: silently accepted, no
+// challenge ACK. The next packet on the wire must be our new data.
+ +.01 < . 1:1(0) ack 1 win 1000
+ +.01 write(4, ..., 100) = 100
+ +0 > P. 501:601(100) ack 1
+ +.01 < . 1:1(0) ack 601 win 1000
diff --git a/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-server.pkt b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-server.pkt
new file mode 100644
index 0000000000000000000000000000000000000000..508380ff1e72d2a31b13471989f0cb0f5377011a
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-server.pkt
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Passive open counterpart of tcp_rfc5961_ack-iss-client.pkt.
+//
+// Once the connection is established, a segment with SEG.ACK = ISS
+// acknowledges bytes we never sent. It must be dropped and a challenge
+// ACK sent back (RFC 5961 Section 5.2), whatever amount of payload was
+// acked so far.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_invalid_ratelimit=0
+`
+
+ 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 10000 <mss 1000,nop,nop,sackOK,nop,wscale 0>
+ +0 > S. 0:0(0) ack 1 <...>
++.01 < . 1:1(0) ack 1 win 10000
+ +0 accept(3, ..., ...) = 4
+
+// SND.UNA = SND.NXT = ISS + 1, no payload acked yet.
+// SEG.ACK = ISS must trigger a challenge ACK.
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1:1(0) ack 1
+
+// Get 1000 bytes of payload acked.
+ +0 write(4, ..., 1000) = 1000
+ +0 > P. 1:1001(1000) ack 1
++.01 < . 1:1(0) ack 1001 win 10000
+
+// SND.UNA = ISS + 1001. Old ACKs in [ISS + 1, ISS + 1001] are valid
+// duplicates, but SEG.ACK = ISS is still below anything the peer could
+// have legitimately sent.
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1001:1001(0) ack 1
+
+// SEG.ACK = ISS + 1 is a genuine old ACK: silently accepted, no
+// challenge ACK. The next packet on the wire must be our new data.
++.01 < . 1:1(0) ack 1 win 10000
++.01 write(4, ..., 1000) = 1000
+ +0 > P. 1001:2001(1000) ack 1
++.01 < . 1:1(0) ack 2001 win 10000
diff --git a/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-simultaneous-open.pkt b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-simultaneous-open.pkt
new file mode 100644
index 0000000000000000000000000000000000000000..17a545712a929760332a0cbceabb00ef1a38f234
--- /dev/null
+++ b/tools/testing/selftests/net/packetdrill/tcp_rfc5961_ack-iss-simultaneous-open.pkt
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Simultaneous open variant of tcp_rfc5961_ack-iss-client.pkt.
+//
+// Our SYN is acked by the SYN-ACK of the peer while we are in SYN-RECV
+// state. Once established, SEG.ACK = ISS must trigger a challenge ACK.
+
+`./defaults.sh
+sysctl -q net.ipv4.tcp_invalid_ratelimit=0
+`
+
+ 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3
+ +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
+ +0 > S 0:0(0) <...>
+
+// Crossed SYN.
++.01 < S 0:0(0) win 10000 <mss 1000,nop,nop,sackOK,nop,wscale 0>
+ +0 > S. 0:0(0) ack 1 <...>
++.01 < S. 0:0(0) ack 1 win 10000 <mss 1000,nop,nop,sackOK,nop,wscale 0>
+// The SYN part of this SYN-ACK is a duplicate, and is DSACKed.
+ +0 > . 1:1(0) ack 1 <nop,nop,sack 0:1>
+ +0 %{ assert tcpi_state == TCP_ESTABLISHED, tcpi_state }%
+
+// SND.UNA = SND.NXT = ISS + 1, no payload acked yet.
+// SEG.ACK = ISS must trigger a challenge ACK.
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1:1(0) ack 1
+
+// Get 1000 bytes of payload acked.
+ +0 write(3, ..., 1000) = 1000
+ +0 > P. 1:1001(1000) ack 1
++.01 < . 1:1(0) ack 1001 win 10000
+
++.01 < . 1:1(0) ack 0 win 10000
+ +0 > . 1001:1001(0) ack 1
+
+// SEG.ACK = ISS + 1 is a genuine old ACK: silently accepted, no
+// challenge ACK. The next packet on the wire must be our new data.
++.01 < . 1:1(0) ack 1 win 10000
++.01 write(3, ..., 1000) = 1000
+ +0 > P. 1001:2001(1000) ack 1
++.01 < . 1:1(0) ack 2001 win 10000
--
2.53.0
next prev parent reply other threads:[~2026-11-18 17:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 17:26 [PATCH net-next 0/2] tcp: do not accept ACK of our ISS on active opens Eric Dumazet
2026-11-18 17:26 ` [PATCH net-next 1/2] " Eric Dumazet
2026-11-18 17:26 ` Eric Dumazet [this message]
2026-11-21 1:20 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118172654.1267071-3-edumazet@kernel.org \
--to=edumazet@kernel.org \
--cc=davem@davemloft.net \
--cc=flavius.mazilu@stud.acs.upb.ro \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tuexen@fh-muenster.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.