Skip to content

Commit 7e32b44

Browse files
yuchungchengdavem330
authored andcommitted
tcp: properly account Fast Open SYN-ACK retrans
Since the TFO socket is accepted right off SYN-data, the socket owner can call getsockopt(TCP_INFO) to collect ongoing SYN-ACK retransmission or timeout stats (i.e., tcpi_total_retrans, tcpi_retransmits). Currently those stats are only updated upon handshake completes. This patch fixes it. Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de1d657 commit 7e32b44

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎net/ipv4/tcp_input.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5885,7 +5885,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
58855885
* so release it.
58865886
*/
58875887
if (req) {
5888-
tp->total_retrans = req->num_retrans;
5888+
inet_csk(sk)->icsk_retransmits = 0;
58895889
reqsk_fastopen_remove(sk, req, false);
58905890
} else {
58915891
/* Make sure socket is routed, for correct metrics. */

‎net/ipv4/tcp_output.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,8 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)
35683568
if (!res) {
35693569
__TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
35703570
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
3571+
if (unlikely(tcp_passive_fastopen(sk)))
3572+
tcp_sk(sk)->total_retrans++;
35713573
}
35723574
return res;
35733575
}

‎net/ipv4/tcp_timer.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk)
384384
*/
385385
inet_rtx_syn_ack(sk, req);
386386
req->num_timeout++;
387+
icsk->icsk_retransmits++;
387388
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
388389
TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
389390
}

0 commit comments

Comments
 (0)