aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuchung Cheng <ycheng@google.com>2016-09-21 19:16:15 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-22 03:33:01 -0400
commit7e32b44361abc77fbc01f2b97b045c405b2583e5 (patch)
treedb26faa9681668af9678e478ec9aaed6a1b58c01
parentde1d657816c6fbb70f07b01d50ec669dff0d4e60 (diff)
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>
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_output.c2
-rw-r--r--net/ipv4/tcp_timer.c1
3 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3ebf45b38bc3..08323bd95f2a 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5885,7 +5885,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
5885 * so release it. 5885 * so release it.
5886 */ 5886 */
5887 if (req) { 5887 if (req) {
5888 tp->total_retrans = req->num_retrans; 5888 inet_csk(sk)->icsk_retransmits = 0;
5889 reqsk_fastopen_remove(sk, req, false); 5889 reqsk_fastopen_remove(sk, req, false);
5890 } else { 5890 } else {
5891 /* Make sure socket is routed, for correct metrics. */ 5891 /* Make sure socket is routed, for correct metrics. */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e15ec82a6319..5288cec4a2b2 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3568,6 +3568,8 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)
3568 if (!res) { 3568 if (!res) {
3569 __TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS); 3569 __TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
3570 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS); 3570 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
3571 if (unlikely(tcp_passive_fastopen(sk)))
3572 tcp_sk(sk)->total_retrans++;
3571 } 3573 }
3572 return res; 3574 return res;
3573} 3575}
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index d84930b2dd95..f712b411f6ed 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -384,6 +384,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk)
384 */ 384 */
385 inet_rtx_syn_ack(sk, req); 385 inet_rtx_syn_ack(sk, req);
386 req->num_timeout++; 386 req->num_timeout++;
387 icsk->icsk_retransmits++;
387 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 388 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
388 TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX); 389 TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
389} 390}