🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26774

Re: [PATCH net] tcp: clamp the u64 delta in tcp_rcv_rtt_measure()

#26774
From: Jiayuan Chen
Date: Fri, 04 Dec 2026 06:16
47 lines
9789 bytes

On 12/4/26 4:45 AM, Chris Mason wrote:
> TCP autotuning can leave the receive buffer too small if the sender
> takes more than 71 minutes to fill a receive window.
>
> tcp_rcv_rtt_measure() uses that time as an RTT sample, but truncates it
> to u32 before tcp_rcv_rtt_update() clamps it:
>
>     tcp_mstamp - rcv_rtt_est.time = 4295000000 us
>     (u32)4295000000               = 32704 us
>     min(32704, TCP_RTT_MAX_US)    = 32704 us

The math is right, but in practice it needs a lot of conditions to actually hit this.

> Without TCP timestamps, autotuning keeps the smallest sample as its RTT
> estimate for the rest of the connection.
>
> The fix used here is to clamp the sample while it is still a u64.
>
> Found by LLM code inspection, and confirmed with LLM generated
> reproducers on an unmodified kernel. Fixed by LLM, and tested with
> the reproducers and existing kernel selftests.
>
> Fixes: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high resolution timestamps")
> Signed-off-by: Chris Mason <mason@kernel.org>

Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>

> ---
>  net/ipv4/tcp_input.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 50c0da17923e4..0bbb0ed71469b 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -895,7 +895,7 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
>  		goto new_measure;
>  	if (before(tp->rcv_nxt, tp->rcv_rtt_est.seq))
>  		return;
> -	delta_us = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcv_rtt_est.time);
> +	delta_us = min(tp->tcp_mstamp - tp->rcv_rtt_est.time, TCP_RTT_MAX_US);
>  	if (!delta_us)
>  		delta_us = 1;
>  	tcp_rcv_rtt_update(tp, delta_us, 1);
Technical Details
Message-ID: <2018a6f6-ce72-480d-b820-b901014d7351@linux.dev>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377109-linux-kernel-netdev=dewy.ru
References: <20261203202930.14580-1-mason@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377109-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: clamp the u64 delta in tcp_rcv_rtt_measure()
Date: Fri, 4 Dec 2026 14:16:23 +0800
Organization: Usenet Network
Message-ID: <2018a6f6-ce72-480d-b820-b901014d7351@linux.dev>
References: <20261203202930.14580-1-mason@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2690930"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WYRIhQZWNacEtlVLwJf7JEvDRZc= sha256:3XjuC5HsPAdSNGWjvky5L/w68LwO4zjZwWjcrbFAu0E=
	sha1:pKv88eM6B0jDkDGB/HBnNpoxaX0= sha256:LHVYMCdXXXJUoLMGBarPvBg7Di/C/CNYPlAFXD4hbuo=
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 D0F6E117B29; Fri,  4 Dec 2026 09:16:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.399
X-Spam-Status: No, score=-2.399 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.001, HK_RANDOM_FROM=0.999,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 L8dQMsaLICby;
	Fri,  4 Dec 2026 09:16:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377109-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 05C52117B01; Fri,  4 Dec 2026 09:16:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id CA3262306A; Fri,  4 Dec 2026 06:16:35 +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=1796364993;
	b=cVl/JHZvPC461kf/g186Pr141vjWvxT2Av2OhiQh5QD5Xa47RHBqEBC5l4P8q4/9CM0A
	 4KyehgYwCpl1kiasmT9KoCJMrnNZgPz+1WhucvAT9JtICTRYtNXv3hrgGYpYXvi4lkdvK
	 M2vxwR+kjmtlvd4HpO2v+LBM5gMrGMtM2R3iJwVu6Gkl4dLYjd/DJb2DNpSLKk1rz9tmZ
	 oNsQuoIPOhUp5q7SMr6hDyrwpU1uPe4VrPRO/twBQsulFgmBt62rRCWktHqKZXa53T1Yn
	 Yl2PJf7EKyG9LN8QdfeDfdwisN4xvC+muyWEbg2NfILDnQiIYyu7QZnZNZzZwnhbmJA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796364993;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=WXKeOr6EDnE7Ge4dJAYMPSf4CGFVHYVoSeuLhbPl4yw=;
	b=DmI4P4Ogi+mIeAI4Ti2IHOSmz7r8/YTXNnd1TCyJ6aqGwf75dKwofWc0VbT2U2l8Y+Rc
	 bBSw4LB/ywnta89Ggo/LAO3+XJpeYBP8hpXh56W5dPDPm5U5dsb6QYxJ9U+pzBziIx7xf
	 mHglqiM7e7vCJlaEyYSauTjzA0rcmmYbRvWO0E6/FnihE11hbrwQoNDKuuLr5Wxqo1tOp
	 yKnFjIknxAugBBB2x1c2h3oI2iO4DaDdjqiSGFOWQ+j1TdKcXg473jQIWCeRVQYpmSgT0
	 Rmc/4gY876YMLb4oixYw2zJkWfHZaid+g3oiKwX2IUQumg8YxjxeC2Bp31mBKmvlVrQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NMmg29XB;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 A12FA606A696;
	Fri,  4 Dec 2026 06:16:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NMmg29XB
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.16
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796364992;
	b=QQMGQV33U/9AWCk5Q8XKVbaQARS2cuaCejC01X0Yx9KKIpQ8SOpdyiui3bRL4VVVV9/D
	 yiNXV5BHNrQnJUZf+LllJtm/CvDq2+wj4andHMx43hcx7Vz6MJjlkHQW3tJuxvCFdLQiF
	 QWWOFGct3fKzYgwNGUVDhVC9hVIJpy5LWPeRvTFlfJI7BSld5KB/EKAd9rUH4bdfyAhq3
	 sDuIrSGSJXxY+OOELikUijBj8JGh7A7O0uzyY5x+Cd2CQZRM+x9G03BxdtmdlT+5uwFtY
	 1+YBitaogUB4Jh+PWRo52w2zwzMHW2XHwPnDibDgclEy5+neg4LfxtvsXsA4fdN9VJQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796364992;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=WXKeOr6EDnE7Ge4dJAYMPSf4CGFVHYVoSeuLhbPl4yw=;
	b=zhJ/lE6/16Dc0kUPn/80VUQ3/542limUA5WY7fQ+7cafPKBgdOSQsK4LbpsT/z5rZcIO
	 JrkeeYM1NMqL6i6pOBwyI8h9xPbACUms3vGn/iXtclMqDP0eBANbO+ru364XkMcNR9JMV
	 OMHrs1YN4daskAURFzvJQGWMdZ4Gh2Js8HuSRkP+haB0OpiDAYQZTEjsVGSy7JKBrwsOT
	 crtiOhv/0GsiOU9CpyP41ZiPCWX7fapZdhe1z+BTHyJYkvNELfNvT0zMtWmgX6YuBg7sR
	 NOZTD2hxfGEjb7F3FUwjRj3gKW9GpCKKuLSlVWhdFFEa2tjMaDVhnC9mHoMNivlLAJQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NMmg29XB;
	arc=none smtp.remote-ip=95.215.58.16
X-Received: from mta1.migadu.com (out-16.mta1.migadu.com [95.215.58.16])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E044E606A689
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 06:16:31 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E044E606A689
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=b3BF9c1koVCFzaMq58LMFSdYhEK3cYxpIXymoj/fxrY=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1796364989; v=1; x=1796969789;
 b=NMmg29XBoGukmKzHczeb2HJDEElmjSawXYP4nM7m7UbhNOWHXaH7VuXXBYifWHh90gwuL5VU
 qq/yiSYThaTcvlqGrao8fgyfg0Y5DALJmLLuUeOI36T+WmUzAFIYJqMSnfyXDEvwdISOR6tG6yX
 CHLy8ihIZT0FG8+uR2TNi4UY=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 7c05ca393a42d0b8;
	Fri, 04 Dec 2026 06:16:29 +0000
X-Mizu-Trace-ID: 7c05ca393a42d0b8
X-Migadu-Flow: FLOW_OUT
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
X-User-Agent: Mozilla Thunderbird
X-In-Reply-To: <20261203202930.14580-1-mason@kernel.org>