Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Chris Mason
Wed, 18 Nov 2026 15:51
[PATCH net v2 1/5] tcp: don't let __tcp_set_rto() return 0
Author: Chris Mason
Date: Wed, 18 Nov 2026 15:51
Date: Wed, 18 Nov 2026 15:51
70 lines
9975 bytes
9975 bytes
tcp_retransmit_timer() backs off by doubling icsk_rto, so the backoff
only works if icsk_rto is nonzero.
__tcp_set_rto() adds srtt_us >> 3 and rttvar_us with no lower bound, and
relies on tcp_rtt_estimator() to keep rttvar_us at tcp_rto_min() or
above. But tcp_rto_min() returns 0 for a route with a locked
RTAX_RTO_MIN of 0. A first RTT sample of 0 usec, which usec TS allows,
then gives:
srtt_us = max(1U, 0 << 3) = 1
rttvar_us = max(mdev_us, tcp_rto_min_us(sk)) = 0
__tcp_set_rto() = usecs_to_jiffies((1 >> 3) + 0) = 0
Keep the result from 0, so that the backoff recovers from any state of
the RTT estimator.
Do it in __tcp_set_rto() and not in tcp_set_rto(), since
tcp_ld_RTO_revert() uses the same sum. The third caller, the linear
timeouts of thin streams in tcp_retransmit_timer(), already clamps the
result to tcp_rto_min().
Found by code inspection (Eric Dumazet), not reproduced. Fixed by LLM,
and tested with existing kernel selftests.
Fixes: 05bb1fad1cde ("[TCP]: Allow minimum RTO to be configurable via routing metrics.")
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Chris Mason <mason@kernel.org>
---
Notes:
v1->v2: no code change, new Fixes: tag (Eric), changelog updates
include/net/tcp.h | 4 +++-
net/ipv4/tcp_input.c | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 5c9203aae834..6a714189bcc7 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -910,7 +910,9 @@ static inline void tcp_bound_rto(struct sock *sk)
static inline u32 __tcp_set_rto(const struct tcp_sock *tp)
{
- return usecs_to_jiffies((tp->srtt_us >> 3) + tp->rttvar_us);
+ u32 rto = usecs_to_jiffies((tp->srtt_us >> 3) + tp->rttvar_us);
+
+ return max(rto, 1U);
}
static inline unsigned long tcp_reqsk_timeout(struct request_sock *req)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a2074a1af422..f65697bc96c9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1221,8 +1221,9 @@ void tcp_set_rto(struct sock *sk)
* with correct one. It is exactly, which we pretend to do.
*/
- /* NOTE: clamping at TCP_RTO_MIN is not required, current algo
- * guarantees that rto is higher.
+ /* NOTE: clamping at tcp_rto_min() is not required, tcp_rtt_estimator()
+ * applies it to rttvar_us. But rto must never be 0, which exponential
+ * backoff could not leave: __tcp_set_rto() takes care of that.
*/
tcp_bound_rto(sk);
}
--
2.55.0
Re: [PATCH net v2 1/5] tcp: don't let __tcp_set_rto() return 0
Author: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 18:23
Date: Wed, 18 Nov 2026 18:23
68 lines
10313 bytes
10313 bytes
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 commit message of "tcp: don't let __tcp_set_rto() return 0"
gets the thin-stream caller wrong.
--
tcp: don't let __tcp_set_rto() return 0
This commit makes __tcp_set_rto() return at least 1 jiffy. Without that
floor, a route with a locked RTAX_RTO_MIN of 0 and an RTT sum under one
jiffy leaves icsk_rto at 0, and the exponential backoff in
tcp_retransmit_timer() can never get it above 0. Because the floor is in
__tcp_set_rto(), both tcp_set_rto() and tcp_ld_RTO_revert() get it.
> Do it in __tcp_set_rto() and not in tcp_set_rto(), since
> tcp_ld_RTO_revert() uses the same sum. The third caller, the linear
> timeouts of thin streams in tcp_retransmit_timer(), already clamps the
> result to tcp_rto_min().
[Severity: Low]
Does this describe the thin stream caller correctly for the configuration
this patch targets?
The trigger here is tcp_rto_min() returning 0 for a route with a locked
RTAX_RTO_MIN of 0. At this commit, tcp_rto_min() passes the route metric
through with no lower bound:
include/net/tcp.h:tcp_rto_min() {
...
if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
return rto_min;
}
Before this patch, the thin stream branch in tcp_retransmit_timer() was:
net/ipv4/tcp_timer.c:tcp_retransmit_timer() {
...
icsk->icsk_rto = clamp(__tcp_set_rto(tp),
tcp_rto_min(sk),
tcp_rto_max(sk));
...
}
This gives clamp(0, 0, rto_max) == 0 whenever (srtt_us >> 3) + rttvar_us
is below one jiffy. icsk_rto then stays at 0 for up to
TCP_THIN_LINEAR_RETRIES retransmissions. After that, the exponential
branch (icsk_rto << 1) keeps it at 0.
The code change fixes this path as well, because the floor is in
__tcp_set_rto(). Only the rationale looks wrong.
Could the commit message say that the thin stream path is also affected
and fixed by this change, instead of saying it is already protected?
The later commit "tcp: bound the rto_min of a route in tcp_rto_min()"
clamps tcp_rto_min() to at least 1. That makes the statement true once
the whole series is applied. However, this patch has its own Fixes: tag
and may be backported on its own.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118155144.18393-1-mason%40kernel.org
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads