๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8345

Re: [PATCH net] tcp: bound snd_cwnd_clamp to TCP_MAX_SND_CWND

#8345
From: netdev-bot+sashiko
Date: Wed, 28 Oct 2026 19:08
120 lines
12027 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch sets TCP_MAX_SND_CWND to 1U << 24 (16,777,216).

--

tcp: bound snd_cwnd_clamp to TCP_MAX_SND_CWND

This patch changes the default snd_cwnd_clamp from ~0 to a finite
TCP_MAX_SND_CWND of 2^24 packets. It also caps the locked RTAX_CWND
metric, TCP_BPF_SNDCWND_CLAMP and TCP_BPF_IW at that value. The stated
goal is to stop congestion control u32 arithmetic from misbehaving when
cwnd gets very large.

> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index 0265c27a5fd77..be1609cd78840 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1553,6 +1553,12 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
>  
>  #define TCP_INFINITE_SSTHRESH	0x7fffffff
>  
> +/* Default and maximum snd_cwnd_clamp, in packets.
> + * Far above any usable BDP, but low enough that congestion control
> + * arithmetic such as 100 * cwnd in CUBIC cannot overflow a u32.
> + */
> +#define TCP_MAX_SND_CWND	(1U << 24)

[Severity: High]
Is 2^24 small enough for the claim in this comment? 100 * cwnd fits, but
CUBIC has larger u32 products on cwnd:

net/ipv4/tcp_cubic.c:cubictcp_recalc_ssthresh() {
    ...
	if (tcp_snd_cwnd(tp) < ca->last_max_cwnd && fast_convergence)
		ca->last_max_cwnd = (tcp_snd_cwnd(tp) * (BICTCP_BETA_SCALE + beta))
			/ (2 * BICTCP_BETA_SCALE);
    ...
	return max((tcp_snd_cwnd(tp) * beta) / BICTCP_BETA_SCALE, 2U);
}

With beta = 717:

  cwnd * 1741 wraps once cwnd is above about 2.47M.
  cwnd * 717 wraps once cwnd is above about 5.99M.

Both points are below 2^24.

At cwnd = 2^24, ssthresh comes out as 3,358,720 instead of 11,747,328.
last_max_cwnd comes out as 1,679,360 instead of about 14.3M.

Just above each wrap point the product is close to zero, so ssthresh
would drop to a few thousand or to the 2U floor. The wrong Wmax then
reaches bictcp_update(), and the comment there says that code is only
overflow-free for cwnd below 1 million packets.

Other in-tree modules have the same pattern:

  dctcp_ssthresh():          cwnd * dctcp_alpha (up to 1024, also the
                             default), wraps at 2^22
  bictcp_recalc_ssthresh():  cwnd * 1843 and cwnd * 819
  tcp_cdg_ssthresh():        cwnd * min(1024U, backoff_beta)
  tcpnv_recalc_ssthresh():   cwnd * nv_loss_dec_factor (default 819)
  tcp_roccet.c:              cwnd * beta and cwnd * (1024 + beta)

DCTCP at cwnd = 2^24 is the clearest case:

	return max(tcp_snd_cwnd(tp) - ((tcp_snd_cwnd(tp) * ca->dctcp_alpha) >> 11U), 2U);

Here 2^24 * 1024 wraps to 0. ssthresh then equals cwnd, so the ECN
window reduction never happens.

The inputs named in the commit message can still put cwnd at the clamp
directly. That skips any real growth in flight:

  tcp_init_cwnd() returns min_t(__u32, cwnd, tp->snd_cwnd_clamp)
  for RTAX_INITCWND
  TCP_BPF_IW now sets min_t(u32, val, tp->snd_cwnd_clamp)

Either path can set cwnd to 2^24. The next RTO or recovery then calls
the CC ssthresh callback with that cwnd:

  tcp_enter_loss()->icsk_ca_ops->ssthresh()
  tcp_init_cwnd_reduction()->icsk_ca_ops->ssthresh()

The sk_sndbuf argument in the commit message limits packets_out. These
callbacks read snd_cwnd, not packets_out.

The generic stack has a similar product as well:

net/ipv4/tcp_output.c:tcp_tso_should_defer() {
    ...
	u32 chunk = min(tp->snd_wnd, tcp_snd_cwnd(tp) * tp->mss_cache);
    ...
}

With a 1448 byte MSS, this wraps above about 2.97M packets.

Would a lower bound work here, around 2^21 or less to cover multipliers
up to 2048? The other option is widening these products to u64.

> +
>  static inline u32 tcp_snd_cwnd(const struct tcp_sock *tp)
>  {
>  	return tp->snd_cwnd;

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261027130617.1550253-1-edumazet%40kernel.org
Technical Details
Message-ID: <179321450338.3134.9348301510643981873@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353001-linux-kernel-netdev=dewy.ru
References: <20261027130617.1550253-1-edumazet@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353001-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: bound snd_cwnd_clamp to TCP_MAX_SND_CWND
Date: Wed, 28 Oct 2026 19:08:23 +0000
Organization: Usenet Network
Message-ID: <179321450338.3134.9348301510643981873@kernel.org>
References: <20261027130617.1550253-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1852279"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9pB6tibbXl5j6dTptBRPa7BNuhM= sha256:OhhDs2z8dvKTH41sGz9NBDY9qRpdaUmijDJlNrWxzRo=
	sha1:qgkTdRzWNduGCD3VRB4ogGI2UOQ= sha256:WGjjCK1/UK0ephDR8eFGONexnmOaCtJurufFK71406Q=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 8F815125C46; Wed, 28 Oct 2026 22:36:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 2GT8IvLWogcA;
	Wed, 28 Oct 2026 22:36:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-353001-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 87779125C44; Wed, 28 Oct 2026 22:36:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 1F5C630852; Wed, 28 Oct 2026 19:11:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793214506;
	b=XrXLBsGwDC2HfB60c+khgWvW1ZBS8kLQYm6iO9m4+8QPgFhwlf4kD/pcBrCCfinB82Gl
	 frHxKpfX/iz5meXOY6k+AlilMPDA/AqNDprIVYPVY3kAkXtqFQ1Va5VSRWGGOBvlz7wZx
	 esZGUvnkQOYAQwUmMX7L3BXcwrz1KY6Nd5EmyghH2tyBFada6Pkkt3NVm2Hlvsz4H2jv9
	 WciUyWu+7CwZG6EdD9n92SUsVvLR6qh70BN7wsJhHk3BBMq6pEM2ra/4v/okcjPXKibqz
	 GXQQYXxD6yco5mTFVZqB86UmvQyv+CBqNuoI7yNrs5rxFa70EfXMf2l+jHcRlPA7K7Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793214506;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=ay42DW5gDi19b0/kytVI8QPTW6jidQRZcuUkzRDznx4=;
	b=kXeV+VrKE1rTeRDB76YzQQEsppGlaSVgEPjCaAw/AMT7ye6iSrn4ookURaY+9R1tYfBw
	 0q1RbH1fOLCZPQRcEmY9x9C7wWKgp4JY+20kY0/gwxVA+C7tHdhCPxjGWkdVKFYbjBqnN
	 QXJBat4BUmIKzHlFwwgcf7/80b1kgKIN2CwtHgCiX0D3WS/7XSMlW0W82kOhT4J35a172
	 gkvob4Kp+z12abYRbb8gqkFJLm1ESpg2GADE1ozKQwJRALF6WP5TVxDpHEoRBcQg4OW5V
	 EtI9W2I68kJVB44TCAhpnjBEgah7RfuiljHq7ICjXt1laOShhCNyYVT4CnU9AtKIoKQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QqRqTf+s;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EBFA560A3823;
	Wed, 28 Oct 2026 19:08:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QqRqTf+s
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793214505;
	b=rqRAH2nc/QL/St8Vv37a4Hkf9pBDLMqKjPkNLDP8GVm6xM3duuVARepbb2ahKj8wHN1z
	 RmHVNjxE3uMaN7LXGGCUcY83plsJM0/2LLRtXtWAV0sFG98WnlZSUTlm1xjnKG6Xce7fx
	 NMjOLCJPUCxRPDPZakTYZikJyg/tP4UhGZfeSqVJjDJhfgmbvZMj1eAXwf85Mb2njqH5f
	 bSrh7Eqm6+2zUfUVBLP/6G8Cqx2KUqTjQPErxZvR02Kyb7a4tojPk04s85QCTJLkkAslv
	 ztmzSYVesrDVE2prSn/1oULZMxSEkXdCjYDgisxbyYDk5EAYy+WrKJDvW3Vk4JMidSA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793214505;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=ay42DW5gDi19b0/kytVI8QPTW6jidQRZcuUkzRDznx4=;
	b=HQOOs2ZCSRjAI/0DBJHgRF73hL1e7gSZGERIa6pJGqcKJJ6FxaK2qcd1oyBejUvOUs4L
	 Eh8Kex/zSJLnJP8kBKbdbFUO1yFcqhvsfToQnRpaFXb9oW4/7ZVJ/n8S811PQiMuvpSD/
	 /z1M00JdY7c2Dm6Si3wqptHSz9CxcSIy0JWwbaouICzMrf0wDSaV0qCNKyYGkhao7cxrS
	 jTDVt9dhoTfSKpmFVhq3hBLBTS658tTKnY80H42LY/yv9SbJtliBdftnuQfSUbi4iu6v3
	 bg+w9hRA4yvoycsibf0nsnxF1L2CCtmWmWghe9Y681JLwMCzssigJU97SAfGyr9XeRg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QqRqTf+s;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD08A606BFA7
	for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 19:08:24 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE3561F031E6;
	Wed, 28 Oct 2026 19:08:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793214504;
	bh=ay42DW5gDi19b0/kytVI8QPTW6jidQRZcuUkzRDznx4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=QqRqTf+sYEsWJArpEMEMr6WZSSdaHQnuDle98ZgRUdK+jDbls/ngH9HAf1n1j59wM
	 PbZwCnKepWsoOgSF/vFhDtkqSuJaoLLGpKhchJorDpN/wE1tNtiSu8V6TTcyzg4Cm+
	 mGybpIWFGGHE7zFmpR7NfT+tX7lea2mnl/+7WsXZVpb3viGO8EyeY9nmaIRV1DNhAm
	 WRwhvtXpGhLR1GI1D8uEJmQqyVV94Wh8Ek7PG1haB4/+N0z6jakoM7AE16rLT2g+gH
	 U6sgDeYy1dP46nbS0xxWc+zo+i+BLu3Ef56yKHUrXj80+N15fokzBc9h7QAhd3ezUw
	 l2/u9iq6qT7NA==
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
 ncardwell@google.com, kuniyu@google.com, horms@kernel.org,
 netdev@vger.kernel.org, mason@kernel.org
X-In-Reply-To: <20261027130617.1550253-1-edumazet@kernel.org>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list