On 3/17/26 7:51 AM, Wesley Atwell wrote:
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index
> 35c3b0ab5a0cb714155d5720fe56888f71aecced..bd3a43148a87e891bc632a47ffb5b82c475e8f6f
> 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -3375,13 +3375,19 @@ u32 __tcp_select_window(struct sock *sk)
> * scaled window will not line up with the MSS boundary anyway.
> */
> if (tp->rx_opt.rcv_wscale) {
> - window = free_space;
> + u32 gran = 1U << tp->rx_opt.rcv_wscale;
>
> - /* Advertise enough space so that it won't get scaled away.
> - * Import case: prevent zero window announcement if
> - * 1<<rcv_wscale > mss.
> + /* Keep tp->rcv_wnd representable in scaled units so later
> + * no-shrink decisions reason about the same right edge we
> + * can advertise on the wire. Preserve only a small non-zero
> + * offer that would otherwise get scaled away to zero.
> */
> - window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale));
> + if (free_space >= gran)
> + window = round_down(free_space, gran);
The receive window already has a similar rounding in the `free_space <
(full_space >> 1)` case. This is basically excluding only:
gran > free_space >= (full_space >> 1)
which IDK if is a realistic situation, perhaps just do the scale down
unconditionally?
Also minor nit, prefer 'granularity' over 'gran'
/P