Skip to content

Commit 14dd92d

Browse files
edumazetdavem330
authored andcommitted
tcp: use tp->total_rto to track number of linear timeouts in SYN_SENT state
In commit ccce324 ("tcp: make the first N SYN RTO backoffs linear") David used icsk->icsk_backoff field to track the number of linear timeouts. Since then, tp->total_rto has been added. This commit uses tp->total_rto instead of icsk->icsk_backoff so that tcp_ld_RTO_revert() no longer can trigger an overflow in inet_csk_rto_backoff(). Other than the potential UBSAN report, there was no issue because receiving an ICMP message currently aborts the connect(). In the following patch, we want to adhere to RFC 6069 and RFC 1122 4.2.3.9. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: David Morley <morleyd@google.com> Cc: Neal Cardwell <ncardwell@google.com> Cc: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c6e9dba commit 14dd92d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp_timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ void tcp_retransmit_timer(struct sock *sk)
626626
* implemented ftp to mars will work nicely. We will have to fix
627627
* the 120 second clamps though!
628628
*/
629-
icsk->icsk_backoff++;
630629

631630
out_reset_timer:
632631
/* If stream is thin, use linear timeouts. Since 'icsk_backoff' is
@@ -647,11 +646,12 @@ void tcp_retransmit_timer(struct sock *sk)
647646
tcp_rto_min(sk),
648647
TCP_RTO_MAX);
649648
} else if (sk->sk_state != TCP_SYN_SENT ||
650-
icsk->icsk_backoff >
649+
tp->total_rto >
651650
READ_ONCE(net->ipv4.sysctl_tcp_syn_linear_timeouts)) {
652651
/* Use normal (exponential) backoff unless linear timeouts are
653652
* activated.
654653
*/
654+
icsk->icsk_backoff++;
655655
icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
656656
}
657657
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,

0 commit comments

Comments
 (0)