🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Eric Dumazet Wed, 18 Nov 2026 17:26
[PATCH net-next 0/2] tcp: do not accept ACK of our ISS on active opens
#18656
Author: Eric Dumazet
Date: Wed, 18 Nov 2026 17:26
42 lines
9501 bytes
Michael Tuexen asked on the tcpm list whether, after a completed
handshake, a segment with SEG.ACK == ISS is a duplicate ACK or a ghost
ACK [1]. Flavius-Romeo Mazilu noted that Linux gives a different answer
on each side of the connection [2]: passive opens send a challenge ACK,
active opens silently accept the segment.

The first patch makes active opens (including Fast Open and
simultaneous opens) behave like passive ones, without changing
the value of tcpi_bytes_acked seen by user space and BPF.

The second patch adds packetdrill tests for the four ways
a socket can be established.

This closes one extra acceptable ACK value on active opens,
so this is targeting net-next.

[1] https://mailarchive.ietf.org/arch/msg/tcpm/ZbjDTFQSHeKSVHAToyAnKBr3TpU/
[2] https://mailarchive.ietf.org/arch/msg/tcpm/ym6lb-UkrW2298LRnTLxCysoo0g/

Eric Dumazet (2):
  tcp: do not accept ACK of our ISS on active opens
  selftests/net: packetdrill: add tests for ACK of ISS

 .../networking/net_cachelines/tcp_sock.rst    |  1 +
 include/linux/tcp.h                           |  3 +-
 net/ipv4/tcp.c                                |  1 +
 net/ipv4/tcp_input.c                          | 10 +++-
 .../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 +++++++++++++++++
 8 files changed, 185 insertions(+), 3 deletions(-)
 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


base-commit: d6816d9a93b66a12bf01e10037e377f3333ad6cc
-- 
2.53.0
[PATCH net-next 2/2] selftests/net: packetdrill: add tests for ACK of ISS
#18657
Author: Eric Dumazet
Date: Wed, 18 Nov 2026 17:26
230 lines
17461 bytes
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
Re: [PATCH net-next 0/2] tcp: do not accept ACK of our ISS on active opens
#20060
Author: patchwork-bot+netdevbpf
Date: Sat, 21 Nov 2026 01:20
29 lines
8962 bytes
Hello:

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

On Wed, 18 Nov 2026 18:26:52 +0100 you wrote:
> Michael Tuexen asked on the tcpm list whether, after a completed
> handshake, a segment with SEG.ACK == ISS is a duplicate ACK or a ghost
> ACK [1]. Flavius-Romeo Mazilu noted that Linux gives a different answer
> on each side of the connection [2]: passive opens send a challenge ACK,
> active opens silently accept the segment.
> 
> The first patch makes active opens (including Fast Open and
> simultaneous opens) behave like passive ones, without changing
> the value of tcpi_bytes_acked seen by user space and BPF.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] tcp: do not accept ACK of our ISS on active opens
    https://git.kernel.org/netdev/net-next/c/a25df726c715
  - [net-next,2/2] selftests/net: packetdrill: add tests for ACK of ISS
    https://git.kernel.org/netdev/net-next/c/5fa71aea9d59

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads