Skip to content

Commit e4dd0d3

Browse files
JasonXingdavem330
authored andcommitted
net: fix the RTO timer retransmitting skb every 1ms if linear option is enabled
In the real workload, I encountered an issue which could cause the RTO timer to retransmit the skb per 1ms with linear option enabled. The amount of lost-retransmitted skbs can go up to 1000+ instantly. The root cause is that if the icsk_rto happens to be zero in the 6th round (which is the TCP_THIN_LINEAR_RETRIES value), then it will always be zero due to the changed calculation method in tcp_retransmit_timer() as follows: icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); Above line could be converted to icsk->icsk_rto = min(0 << 1, TCP_RTO_MAX) = 0 Therefore, the timer expires so quickly without any doubt. I read through the RFC 6298 and found that the RTO value can be rounded up to a certain value, in Linux, say TCP_RTO_MIN as default, which is regarded as the lower bound in this patch as suggested by Eric. Fixes: 36e31b0 ("net: TCP thin linear timeouts") Suggested-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jason Xing <kernelxing@tencent.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8a519a5 commit e4dd0d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/ipv4/tcp_timer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,9 @@ void tcp_retransmit_timer(struct sock *sk)
591591
tcp_stream_is_thin(tp) &&
592592
icsk->icsk_retransmits <= TCP_THIN_LINEAR_RETRIES) {
593593
icsk->icsk_backoff = 0;
594-
icsk->icsk_rto = min(__tcp_set_rto(tp), TCP_RTO_MAX);
594+
icsk->icsk_rto = clamp(__tcp_set_rto(tp),
595+
tcp_rto_min(sk),
596+
TCP_RTO_MAX);
595597
} else if (sk->sk_state != TCP_SYN_SENT ||
596598
icsk->icsk_backoff >
597599
READ_ONCE(net->ipv4.sysctl_tcp_syn_linear_timeouts)) {

0 commit comments

Comments
 (0)