Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mason@kernel.org
Cc: 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: Re: [PATCH net v2 3/5] tcp: reject RTT samples from TSecr above 120 s
Date: Wed, 18 Nov 2026 18:23:02 +0000	[thread overview]
Message-ID: <179502618234.3136.4048099006829780599@kernel.org> (raw)
In-Reply-To: <20261118155144.18393-4-mason@kernel.org>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The header comment for TCP_RTT_MAX_US is out of date after this
  patch.

--

tcp: reject RTT samples from TSecr above 120 s

This patch makes tcp_rtt_tsopt_us() reject any TSecr-derived RTT sample
above TCP_RTT_MAX_US (120 s), in both the usec and ms timestamp branches.
Before, samples of up to about 2,147 s were accepted. Both callers,
tcp_ack_update_rtt() and tcp_rcv_rtt_measure_ts(), now get no sample when
TSecr echoes a very old timestamp.

> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index e796497b84be8..69e038b9389ae 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -901,15 +901,16 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
>  	tp->rcv_rtt_est.time = tp->tcp_mstamp;
>  }
>  
> +/* A sample from TSecr above TCP_RTT_MAX_US is bogus, not large. */
>  static s32 tcp_rtt_tsopt_us(const struct tcp_sock *tp, u32 min_delta)
>  {
>  	u32 delta, delta_us;
>  
>  	delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr;
>  	if (tp->tcp_usec_ts)
> -		return delta;
> +		return delta <= TCP_RTT_MAX_US ? delta : -1;
>  
> -	if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
> +	if (likely(delta <= TCP_RTT_MAX_US / (USEC_PER_SEC / TCP_TS_HZ))) {

[Severity: Low]
This isn't a bug, but should the comment on TCP_RTT_MAX_US in
include/net/tcp.h be updated to match its new use here? It currently reads:

/* Max RTT sample for tcp_rtt_estimator(). srtt_us holds 8 times the RTT, and
 * mdev_us and rttvar_us up to 4 times its deviation, all in u32, like the sum
 * in __tcp_set_rto(). A larger sample could not raise the RTO, which
 * TCP_RTO_MAX bounds.
 */
#define TCP_RTT_MAX_US	(TCP_RTO_MAX_SEC * USEC_PER_SEC)

That comment names tcp_rtt_estimator() as the only user. The only reason
it gives for the value is u32 headroom for a saturating clamp.

With this patch the same constant is also the validity cutoff in
tcp_rtt_tsopt_us(). That cutoff covers more than the estimator: it
decides rs->rtt_us, the tcp_update_rtt_min() input, and whether
icsk_backoff is reset in tcp_ack_update_rtt(). It also gates the
receive-side estimate in tcp_rcv_rtt_measure_ts().

The later patch in the series, "tcp: clamp the samples in
tcp_rcv_rtt_update()", adds another user, and the header comment is still
unchanged at the end of the series.

Someone who changes TCP_RTO_MAX_SEC or TCP_RTT_MAX_US because of the u32
headroom reasoning would not see that this also moves the TSecr rejection
threshold. Could the header comment mention that the constant also bounds
valid TSecr samples?

>  		if (!delta)
>  			delta = min_delta;
>  		delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118155144.18393-1-mason%40kernel.org

  parent reply	other threads:[~2026-11-18 18:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:51 [PATCH net v2 0/5] tcp: avoid integer wraps in the RTT estimator and the RTO Chris Mason
2026-11-18 15:51 ` [PATCH net v2 1/5] tcp: don't let __tcp_set_rto() return 0 Chris Mason
2026-11-18 18:23   ` netdev-bot+sashiko
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 16:35   ` Eric Dumazet
2026-11-18 18:23   ` netdev-bot+sashiko [this message]
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 18:23   ` netdev-bot+sashiko
2026-11-18 18:48     ` Chris Mason
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=179502618234.3136.4048099006829780599@kernel.org \
    --to=netdev-bot+sashiko@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=mason@kernel.org \
    --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