Netdev List
 help / color / mirror / Atom feed
From: Chris Mason <mason@kernel.org>
To: mason@kernel.org, edumazet@kernel.org, ncardwell@google.com,
	kuniyu@google.com, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, willemb@google.com,
	josef@toxicpanda.com, netdev@vger.kernel.org
Subject: [PATCH net v2 0/5] tcp: avoid integer wraps in the RTT estimator and the RTO
Date: Wed, 18 Nov 2026 10:51:44 -0500	[thread overview]
Message-ID: <20261118155144.18393-1-mason@kernel.org> (raw)

Hi everyone,

This is v2 of the RTT clamps, with Eric's review folded in.

Patch 1: __tcp_set_rto() never returns 0, so that the backoff recovers
from any state of the RTT estimator.

Patch 2: tcp_rtt_estimator() clamps each sample to 120 s, so that
srtt_us, mdev_us, rttvar_us and the sum in __tcp_set_rto() can't wrap.

Patch 3: tcp_rtt_tsopt_us() rejects a TSecr sample above 120 s.

Patch 4: new, from Eric's review. tcp_rcv_rtt_update() clamps its
samples too, which covers tcp_rcv_rtt_measure().

Patch 5: new. tcp_rto_min() bounds the locked rto_min of a route.

Eric, I have a question on patch 5. You pointed at a locked rto_min of 0 for
patch 1. We can also get an RTO of 0 out of tcp_init_metrics(), which doesn't
go through __tcp_set_rto(), so I bounded the metric in tcp_rto_min(). For a
locked cwnd of 0 you wanted ip_metrics_convert() to reject it instead.

I didn't do that here because claude points out that "rto_min lock 0" is
accepted today and mostly works, but just let me know how you want
this to look.

Changes since v1:

- Patch 1: no code change. New changelog and Fixes: tag (Eric). David
  suggested "return rto ?: 1;". I kept max(), since tcp_rtt_estimator()
  ends with max(1U, srtt).
- Patch 2: clamp mrtt_us itself, so that tcp_bpf_rtt() gets the clamped
  sample (Eric).
- Patch 3: no code change. The part on sample << 3 moved to patch 4.
- Patch 4: new (Eric), with min() instead of min_t() (David).
- Patch 5: new.

v1: https://lore.kernel.org/all/20261118005048.53393-1-mason@kernel.org/

This is on top of v7.4-rc3.

Chris Mason (5):
  tcp: don't let __tcp_set_rto() return 0
  tcp: clamp RTT samples in tcp_rtt_estimator()
  tcp: reject RTT samples from TSecr above 120 s
  tcp: clamp the samples in tcp_rcv_rtt_update()
  tcp: bound the rto_min of a route in tcp_rto_min()

 include/net/tcp.h    | 14 ++++++++++++--
 net/ipv4/tcp_input.c | 21 +++++++++++++++------
 2 files changed, 27 insertions(+), 8 deletions(-)

-- 
2.55.0


             reply	other threads:[~2026-11-18 15:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:51 Chris Mason [this message]
2026-11-18 15:51 ` [PATCH net v2 1/5] tcp: don't let __tcp_set_rto() return 0 Chris Mason
2026-11-18 15:51 ` [PATCH net v2 2/5] tcp: clamp RTT samples in tcp_rtt_estimator() Chris Mason
2026-11-18 15:51 ` [PATCH net v2 3/5] tcp: reject RTT samples from TSecr above 120 s Chris Mason
2026-11-18 15:51 ` [PATCH net v2 4/5] tcp: clamp the samples in tcp_rcv_rtt_update() Chris Mason
2026-11-18 16:34   ` Eric Dumazet
2026-11-18 15:51 ` [PATCH net v2 5/5] tcp: bound the rto_min of a route in tcp_rto_min() Chris Mason
2026-11-18 16:33   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118155144.18393-1-mason@kernel.org \
    --to=mason@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox