From nobody Sun Apr 5 16:27:59 2026 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 606AE3ACA73 for ; Tue, 24 Mar 2026 06:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774332270; cv=none; b=ofjk0R1O0KqQR/BCyxJFli1rAhwxjgQjI/ZeTOPSgZjIxDul1O1qe6+MZ+tsoKN4bKgCUUFNoUhUKGiKBzSdWmMBsw4g8heBnr8zBoMU/5Ty6n/iMOpKenGmew1rIpw1qGNUoV3aD2qkhi0a2tJQ2oAe4+3t4TCFucaxWNJWxOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774332270; c=relaxed/simple; bh=vDPZKHBUYge/g17hzmq5toRf4WT7oxJcyJZTa2pK1Pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N3mt0L342IK7jx0fRWh8f+80ndwJUt60A15I2gxTnal6fyMNsl+epDC8MbiNF6x5FyN5j1O9eTVq8s+IIFgchTVWrW4jyYNbA8cmfw1ZH/L1KoCQS4g+O+yqMPt/3/dtlI3Q1yaevZq5p68dDe0D2hAZxMFvqRIgsmfg4s+m9gA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hcpDzhpv; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hcpDzhpv" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7d7eb85fb81so1006728a34.0 for ; Mon, 23 Mar 2026 23:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774332266; x=1774937066; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VdUAuQeuJDXiY6t8B3u7gtUDmCHorI1qmUGWnWOYpWU=; b=hcpDzhpvPmhdFAl6MmhNCFrPgkhxrY1TUjfNMCVwhdI5v0o2XjqDHLuWXWhSux81T5 phGLX1MQMrM4L3NDqBFcvfJds1JrpdWystuOuA0EQXaa2MSzUcdy/m7//32QJns2Ih1/ 7MJZ9ZS+YugO2rk4fFM+oHn/kc3xwqBy7Q5jyfBNvpUDnhGPsU/631hFoPsfBBK0c8Jb m97U2c8hmQw/Q7XNF+Dr7EoI9UF4Bp23LLKxiWDXt3/vK+WKUCoGbyEARIomzAo4iSei 7OPCk+mYMINIO94vnpa8K7HBOEdl4TyzX8SgsOQxUYYB1MlCAD0QGtHz8st8NiIo+lt0 ek2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774332266; x=1774937066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VdUAuQeuJDXiY6t8B3u7gtUDmCHorI1qmUGWnWOYpWU=; b=NGWKpwgoo2ehNZOD76n0WMm2atePbjI3xas8aT6mcrI/KVTLeuy8+E4MAGypFfhD2l njWI7XjoeL1AjVNq5IjKm5Al8fqf70g69c2vbksQn4DTAiyqdmMJDoit9vaBfkWFN3F1 8PiUBCFytAdlc2tHfgPx+rfu8io1TBNw7V3wRB200Yr+HubStbVkTRJK2o2d2IlHgEAj f+hoAC4/zp9Xw2sUjKqw+Oi2HtYb5stARN0o3bw9bLgAYWFXAnQR3II+xmEXVDmKshdD K8IkhcZOqrpIRckSVdInFWv5yXojOQ4DRWSursUk7occHfOQt5OcaWiIfQPrESLj4u9S lb1A== X-Forwarded-Encrypted: i=1; AJvYcCX0VqkJSVfiJZWwz4Q6MgOogTlPGkUEhCqWUMkOCllZkcF4cwJSo4nuNfLvhKor/rlwL/717w8PzH0NshQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxhEgmPagDQJymO3Ixm796Xuh1wqSfQxKpzShcxJm26iEB/LtpV WKYhCeG+R9VbC5t2fwh4FpC1jS5ShGjcKqtrC66pQBEtl141wmDOLuQd X-Gm-Gg: ATEYQzzZ7n4yxBKASQrE29duke+rFBDfy6Ocg7DpibieEsqpj1zhrtj5Iu1JdbOtTOa KttUln/DVAAgObP+XFY5/7HewkQRac0H/TWwhXIEDB+G8lye1FqdR/8WKt30sCyp5u6IifTfQc9 D9WE/ZVZF3dWULi/VUfeyD017ngQMo49nyuNL/0fmGWwHtVRaXRTXAY7HQ5dwp4Nz+VV9me/tsF AsSBjsXe/fQ+ODP0pfcrlLjr29OySJbkMqFLinATHAro70qpbnhHPp5I5MzzWcxMQvzW0/NWZAy txih5DxcXHQefYcSoCzaTfsTYuYbdWub8NOzk9ehVERD98lW7T1eeyJNzKHykaPt/X1VCLEPdir t8W2ynKxZqWTjk9rtNy6oGbJXr7y6Oqyu7lYctnOkeu6CRFSuwcW9m+qY9hKHp39P8MmXv9ATpk m2Dg0MvZQ2rFKiI+KHDtskSFUrugA7Hi3feVs7iW5Vy8D2EDkORzIegiK0ujjfsX9Z8SKOelkrx ygZWOlhASysnZuboKfBawGtqKucU7LxjMmdKKv7Zw== X-Received: by 2002:a05:6830:82e6:b0:7d9:b0d7:ffda with SMTP id 46e09a7af769-7d9b0d80e91mr5744843a34.11.1774332265864; Mon, 23 Mar 2026 23:04:25 -0700 (PDT) Received: from Atwell-Laptop.. (108-212-132-20.lightspeed.irvnca.sbcglobal.net. [108.212.132.20]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d7eadcb757sm11429957a34.15.2026.03.23.23.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 23:04:25 -0700 (PDT) From: Wesley Atwell To: netdev@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@google.com, ncardwell@google.com, kuniyu@google.com, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, gmbnomis@gmail.com, Wesley Atwell Subject: [PATCH net-next v2 2/3] tcp: keep scaled no-shrink window representable Date: Tue, 24 Mar 2026 00:04:09 -0600 Message-ID: <20260324060410.1137199-3-atwellwea@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260324060410.1137199-1-atwellwea@gmail.com> References: <20260324060410.1137199-1-atwellwea@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the scaled no-shrink path, __tcp_select_window() currently rounds the raw free-space value up to the receive-window scale quantum. When raw backed free_space sits just below the next quantum, that can expose fresh sender-visible credit beyond the currently backed receive space. Fix this by keeping tp->rcv_wnd representable in scaled units: round larger windows down to the scale quantum and preserve only the small non-zero case that would otherwise scale away to zero. This series intentionally leaves that smaller longstanding non-zero case unchanged. The proven bug and the new reproducer are both in the larger-window path where free_space is at least one scale quantum, so changing 0 < free_space < granularity into zero would be a separate behavior change. That representability matters across ACK transitions too, not only on the immediate raw-free_space-limited ACK. tcp_select_window() preserves the currently offered window when shrinking is disallowed, so if an earlier ACK stores a rounded-up value in tp->rcv_wnd, a later raw-free_space-limited ACK can keep inheriting that extra unit. Keeping tp->rcv_wnd representable throughout the scaled no-shrink path prevents that carry-forward and makes later no-shrink decisions reason from a right edge the peer could actually have seen on the wire. This removes the larger-window quantization slack while preserving the small non-zero case needed to avoid scaling away to zero. Signed-off-by: Wesley Atwell --- v2: - rename gran to granularity - clarify why representable tp->rcv_wnd state is required across later no-shrink transitions - clarify that this series still intentionally leaves the smaller longstanding non-zero case unchanged net/ipv4/tcp_output.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 35c3b0ab5a0c..e5c4c09101be 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 =3D free_space; + u32 granularity =3D 1U << tp->rx_opt.rcv_wscale; =20 - /* Advertise enough space so that it won't get scaled away. - * Import case: prevent zero window announcement if - * 1< 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 =3D ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); + if (free_space >=3D granularity) + window =3D round_down(free_space, granularity); + else if (free_space > 0) + window =3D granularity; + else + window =3D 0; } else { window =3D tp->rcv_wnd; /* Get the largest window that is a nice multiple of mss. --=20 2.43.0