netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tcp: fix under-accounting retransmit SNMP counters
@ 2016-09-21 23:16 Yuchung Cheng
  2016-09-21 23:16 ` [PATCH net] tcp: properly account Fast Open SYN-ACK retrans Yuchung Cheng
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yuchung Cheng @ 2016-09-21 23:16 UTC (permalink / raw)
  To: davem; +Cc: netdev, edumazet, Yuchung Cheng

This patch fixes these under-accounting SNMP rtx stats
LINUX_MIB_TCPFORWARDRETRANS
LINUX_MIB_TCPFASTRETRANS
LINUX_MIB_TCPSLOWSTARTRETRANS
when retransmitting TSO packets

Fixes: 10d3be569243 ("tcp-tso: do not split TSO packets at retransmit time")
Signed-off-by: Yuchung Cheng <ycheng@google.com>
---
 net/ipv4/tcp_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 810be35..5725822 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2822,7 +2822,7 @@ begin_fwd:
 		if (tcp_retransmit_skb(sk, skb, segs))
 			return;
 
-		NET_INC_STATS(sock_net(sk), mib_idx);
+		NET_ADD_STATS(sock_net(sk), mib_idx, tcp_skb_pcount(skb));
 
 		if (tcp_in_cwnd_reduction(sk))
 			tp->prr_out += tcp_skb_pcount(skb);
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net] tcp: properly account Fast Open SYN-ACK retrans
  2016-09-21 23:16 [PATCH net] tcp: fix under-accounting retransmit SNMP counters Yuchung Cheng
@ 2016-09-21 23:16 ` Yuchung Cheng
  2016-09-22  7:33   ` David Miller
  2016-09-22  2:19 ` [PATCH net] tcp: fix under-accounting retransmit SNMP counters Eric Dumazet
  2016-09-22  7:33 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Yuchung Cheng @ 2016-09-21 23:16 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, Yuchung Cheng, Neal Cardwell, Soheil Hassas Yeganeh

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>
---
 net/ipv4/tcp_input.c  | 2 +-
 net/ipv4/tcp_output.c | 2 ++
 net/ipv4/tcp_timer.c  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d6c8f4cd0..8faf97e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5852,7 +5852,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 		 * so release it.
 		 */
 		if (req) {
-			tp->total_retrans = req->num_retrans;
+			inet_csk(sk)->icsk_retransmits = 0;
 			reqsk_fastopen_remove(sk, req, false);
 		} else {
 			/* Make sure socket is routed, for correct metrics. */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 8bd9911..810be35 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3559,6 +3559,8 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)
 	if (!res) {
 		__TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
 		__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
+		if (unlikely(tcp_passive_fastopen(sk)))
+			tcp_sk(sk)->total_retrans++;
 	}
 	return res;
 }
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index debdd8b..39bc5b2 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -346,6 +346,7 @@ static void tcp_fastopen_synack_timer(struct sock *sk)
 	 */
 	inet_rtx_syn_ack(sk, req);
 	req->num_timeout++;
+	icsk->icsk_retransmits++;
 	inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
 			  TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX);
 }
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] tcp: fix under-accounting retransmit SNMP counters
  2016-09-21 23:16 [PATCH net] tcp: fix under-accounting retransmit SNMP counters Yuchung Cheng
  2016-09-21 23:16 ` [PATCH net] tcp: properly account Fast Open SYN-ACK retrans Yuchung Cheng
@ 2016-09-22  2:19 ` Eric Dumazet
  2016-09-22  7:33 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2016-09-22  2:19 UTC (permalink / raw)
  To: Yuchung Cheng; +Cc: davem, netdev, edumazet

On Wed, 2016-09-21 at 16:16 -0700, Yuchung Cheng wrote:
> This patch fixes these under-accounting SNMP rtx stats
> LINUX_MIB_TCPFORWARDRETRANS
> LINUX_MIB_TCPFASTRETRANS
> LINUX_MIB_TCPSLOWSTARTRETRANS
> when retransmitting TSO packets
> 
> Fixes: 10d3be569243 ("tcp-tso: do not split TSO packets at retransmit time")
> Signed-off-by: Yuchung Cheng <ycheng@google.com>
> ---

Good catch, thanks Yuchung !

Acked-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] tcp: fix under-accounting retransmit SNMP counters
  2016-09-21 23:16 [PATCH net] tcp: fix under-accounting retransmit SNMP counters Yuchung Cheng
  2016-09-21 23:16 ` [PATCH net] tcp: properly account Fast Open SYN-ACK retrans Yuchung Cheng
  2016-09-22  2:19 ` [PATCH net] tcp: fix under-accounting retransmit SNMP counters Eric Dumazet
@ 2016-09-22  7:33 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-09-22  7:33 UTC (permalink / raw)
  To: ycheng; +Cc: netdev, edumazet

From: Yuchung Cheng <ycheng@google.com>
Date: Wed, 21 Sep 2016 16:16:14 -0700

> This patch fixes these under-accounting SNMP rtx stats
> LINUX_MIB_TCPFORWARDRETRANS
> LINUX_MIB_TCPFASTRETRANS
> LINUX_MIB_TCPSLOWSTARTRETRANS
> when retransmitting TSO packets
> 
> Fixes: 10d3be569243 ("tcp-tso: do not split TSO packets at retransmit time")
> Signed-off-by: Yuchung Cheng <ycheng@google.com>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] tcp: properly account Fast Open SYN-ACK retrans
  2016-09-21 23:16 ` [PATCH net] tcp: properly account Fast Open SYN-ACK retrans Yuchung Cheng
@ 2016-09-22  7:33   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-09-22  7:33 UTC (permalink / raw)
  To: ycheng; +Cc: netdev, edumazet, ncardwell, soheil

From: Yuchung Cheng <ycheng@google.com>
Date: Wed, 21 Sep 2016 16:16:15 -0700

> 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>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-22  7:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 23:16 [PATCH net] tcp: fix under-accounting retransmit SNMP counters Yuchung Cheng
2016-09-21 23:16 ` [PATCH net] tcp: properly account Fast Open SYN-ACK retrans Yuchung Cheng
2016-09-22  7:33   ` David Miller
2016-09-22  2:19 ` [PATCH net] tcp: fix under-accounting retransmit SNMP counters Eric Dumazet
2016-09-22  7:33 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).