Re: [PATCH net] tcp: keep the route window metric when SO_RCVBUF is set before connect

From: Eric Dumazet

Date: Sun Oct 11 2026 - 04:15:34 EST


Le dim. 11 oct. 2026 à 07:26, shashank Jain <jain.sm@xxxxxxxxx> a écrit :
>
> The issue was found by manual code inspection assisted by an LLM
> (Claude Code, Claude Opus), while reviewing the networking changes that
> set window_clamp on unconnected sockets, and then confirmed with a
> reproducer before posting. The patch carries an "Assisted-by: LLM" tag
> for that reason.
>
> Reproducer: mainline a5ebb76233b7 built for x86_64 and booted in qemu,
> two network namespaces joined by a veth pair, with
> "ip route replace 10.0.0.0/24 dev <veth> window 4096" on both sides. A
> small program sets SO_RCVBUF before connect()/listen() and reads
> TCP_WINDOW_CLAMP and tcp_info, and the SYN/SYN-ACK is captured with
> tcpdump.
>
> Without SO_RCVBUF the route's window metric is applied
> (TCP_WINDOW_CLAMP=4096, rcv_wscale=0, SYN "win 2920, wscale 0"). With
> SO_RCVBUF set before connect, mainline reports TCP_WINDOW_CLAMP ~1 MB
> and rcv_wscale=5, i.e. the route metric is ignored. Reverting
> b025461303d8 ("tcp: update window_clamp when SO_RCVBUF is set") or
> applying this patch restores TCP_WINDOW_CLAMP=4096 and the scaled-down
> SYN window; with no route metric configured, mainline, the revert and
> the patch behave identically in all four combinations.
>
> Thanks,
> Shashank

Note that we ask to not top post on netdev@ mailing list.

A few remarks on the changelog:

1) "TCP_WINDOW_CLAMP 4096" only holds until the first data segment.
Since a2cbb1603943 ("tcp: Update window clamping condition"),
tcp_measure_rcv_mss() overwrites window_clamp from sk_rcvbuf as soon
as scaling_ratio changes, with or without your patch. What the patch
really restores is the SYN/SYN-ACK window and the window scale.
Please say so.

2) "no window scaling" is not accurate: we still send the option,
with a shift of 0.

3) This also fixes TCP_WINDOW_CLAMP being overwritten by a later
SO_RCVBUF on a not yet connected socket or a listener. This is
probably more common than the route metric and worth mentioning.

A packetdrill test covering the SYN window and wscale would be nice.

It seems to be a net-next candidate, since WINDOW_CLAMP is not well
documented / defined / implemented / tested.

pw-bot: cr

Thanks.


>
> On Sun, Oct 11, 2026 at 10:54 AM <netdev-bot+sinfo@xxxxxxxxxx> wrote:
> >
> > Hi!
> >
> > This is an automated message. This series looks like a fix, but its
> > commit messages seem to be missing some information:
> >
> > - How the issue was discovered, e.g. hit in production, hit during
> > development, syzbot report, manual code inspection, LLM or static
> > analysis tool scan.
> >
> > Please do not repost the series just to address the above. Instead,
> > reply to this email with the missing information, so that reviewers
> > can take it into account. If the series needs another revision for
> > other reasons, please include the information in the commit messages
> > then.
> >
> > The evaluation is done by an LLM so it may be wrong, if you think
> > that is the case please reply and explain.