Subject: Re: TCP OOM drops with the stricter rcvbuf checking

From: Jakub Kicinski <[email-masked]>
Date: Wed, 25 Feb 2026 13:44:28 -0800

On Wed, 25 Feb 2026 12:23:55 -0800 Jakub Kicinski wrote:
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 326b58ff1118..9f7ed76a97aa 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -3383,7 +3383,8 @@ u32 __tcp_select_window(struct sock *sk)
>                  * Import case: prevent zero window announcement if
>                  * 1<<rcv_wscale > mss.
>                  */
> -               window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale));
> +               if (window < (1 << tp->rx_opt.rcv_wscale))
> +                       window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale));
>         } else {
>                 window = tp->rcv_wnd;
>                 /* Get the largest window that is a nice multiple of mss.

Hm, reading thru __tcp_select_window() more carefully I guess there's
already an attempt to solve this:

	if (free_space < (full_space >> 1)) {
		...
		/* free_space might become our new window, make sure we don't
		 * increase it due to wscale.
		 */
		free_space = round_down(free_space, 1 << tp->rx_opt.rcv_wscale);

the problem is that over loopback we can receive rather large skbs,
so we don't hit this round_down(). The drops I see have < 64k inq,
and the incoming skb is > 64k.

Perhaps this condition should check if free_space < gro_ipv*_max_size
as well (modulo gro_*_max_size vs tso_max_size on loopback)?