mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
tcp: bound the rto_min of a route in tcp_rto_min()
For a route with a locked RTAX_RTO_MIN, tcp_rto_min() returns the metric
as it is, and that can be any 32-bit number of milliseconds. All other
ways to set the minimum RTO have a nonzero floor: the tcp_rto_min_us
sysctl, TCP_RTO_MIN_US and TCP_BPF_RTO_MIN.
Both ends of that range give us trouble.
With an rto_min of 0, tcp_init_metrics() can start a connection with an
RTO of 0, if the cached RTT is below one jiffy:
icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk)) = 0
It sets icsk_rto itself, so the lower bound in __tcp_set_rto() does not
help here.
At the other end, tcp_rto_min_us() and the sum in __tcp_set_rto() are
u32 values in usec, so an rto_min of more than about 71 minutes does not
fit.
Clamp a locked rto_min to the range from one jiffy to TCP_RTO_MAX in
tcp_rto_min().
ip_metrics_convert() could reject these values instead, as it does for a
locked cwnd of 0. But a route with "rto_min lock 0" is accepted today
and mostly works, so that would break existing setups.
A route still shows the rto_min that it was given, while TCP uses one
jiffy or 120 s.
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: 05bb1fad1c ("[TCP]: Allow minimum RTO to be configurable via routing metrics.")
Signed-off-by: Chris Mason <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
This commit is contained in:
+2
-1
@@ -939,7 +939,8 @@ static inline u32 tcp_rto_min(const struct sock *sk)
|
||||
u32 rto_min = READ_ONCE(inet_csk(sk)->icsk_rto_min);
|
||||
|
||||
if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
|
||||
rto_min = dst_metric_rtt(dst, RTAX_RTO_MIN);
|
||||
rto_min = clamp(dst_metric_rtt(dst, RTAX_RTO_MIN),
|
||||
1, TCP_RTO_MAX);
|
||||
return rto_min;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user