[PATCH net-next 0/2] tcp: keep the route window on the SYN when SO_RCVBUF is set before connect

From: Shashank Mohan Jain

Date: Sun Oct 11 2026 - 07:16:25 EST


v1 was a single [PATCH net] with only the fix. Eric Dumazet pointed out
that the changelog overstated the effect (TCP_WINDOW_CLAMP does not
persist past the first data segments), that "no window scaling" was
inaccurate (the option is still sent, with a shift of 0), and asked for
a packetdrill test and for the series to target net-next. This v2
rewrites the changelog accordingly, leads with the common
SO_RCVBUF-before-connect / listener case, adds a packetdrill test, and
is based on net-next.

Patch 1 is the fix: setsockopt(SO_RCVBUF) must not write tp->window_clamp
while the socket is in TCP_CLOSE or TCP_LISTEN, so that
tcp_connect_init() and tcp_openreq_init_rwin() still apply the route
window metric (RTAX_WINDOW) and the defaults to the SYN / SYN-ACK window
and window scale.

Patch 2 adds a packetdrill test: with "window 4096" on the route to the
peer and SO_RCVBUF set before connect(), the SYN must advertise the
route-clamped window and window scale 0. On an unpatched net-next kernel
the SYN carries win 65535, wscale 5; with patch 1 it carries win 2920,
wscale 0.

Changes since v1 (single [PATCH net]):
- changelog: say the patch restores the SYN/SYN-ACK window and window
scale, not a persistent clamp; note that since a2cbb1603943
tcp_measure_rcv_mss() recomputes window_clamp from sk_rcvbuf anyway.
- changelog: "wscale 0 (option still sent, shift 0)" instead of "no
window scaling"; lead with the SO_RCVBUF-before-connect / listener
case.
- add the packetdrill selftest (patch 2).
- retarget from net to net-next.

Shashank Mohan Jain (2):
tcp: don't set window_clamp from SO_RCVBUF before the socket is
connected
selftests/net/packetdrill: test SO_RCVBUF before connect keeps route
window

net/ipv4/tcp.c | 8 ++++++
.../tcp_rcvbuf_before_connect_window.pkt | 27 +++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rcvbuf_before_connect_window.pkt


base-commit: d8674294aefef02266c4d47ad10131f1bffbe534
--
2.43.0