public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] tcp: Update MIB counters for drops
@ 2013-01-30 22:57 Vijay Subramanian
  2013-01-30 23:31 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Vijay Subramanian @ 2013-01-30 22:57 UTC (permalink / raw)
  To: netdev; +Cc: davem, niveditasinghvi, Vijay Subramanian

This patch updates LINUX_MIB_LISTENDROPS and LINUX_MIB_LISTENOVERFLOWS in
tcp_v4_conn_request() and tcp_v4_err(). tcp_v4_conn_request() in particular can
drop SYNs for various reasons which are not currently tracked.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
---
Ignored "line over 80 chars" warning for readability.

 net/ipv4/tcp_ipv4.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 629937d..029ac1f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -496,6 +496,7 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
 		 * errors returned from accept().
 		 */
 		inet_csk_reqsk_queue_drop(sk, req, prev);
+		NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
 		goto out;
 
 	case TCP_SYN_SENT:
@@ -1491,8 +1492,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
 	 */
 	if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
 		want_cookie = tcp_syn_flood_action(sk, skb, "TCP");
-		if (!want_cookie)
+		if (!want_cookie) {
+			NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
 			goto drop;
+		}
 	}
 
 	/* Accept backlog is full. If we have already queued enough
@@ -1502,7 +1505,6 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
 	 */
 	if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) {
 		NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
-		NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
 		goto drop;
 	}
 
@@ -1669,6 +1671,7 @@ drop_and_release:
 drop_and_free:
 	reqsk_free(req);
 drop:
+	NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
 	return 0;
 }
 EXPORT_SYMBOL(tcp_v4_conn_request);
-- 
1.7.0.4

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

* Re: [PATCH net] tcp: Update MIB counters for drops
  2013-01-30 22:57 [PATCH net] tcp: Update MIB counters for drops Vijay Subramanian
@ 2013-01-30 23:31 ` Eric Dumazet
  2013-01-31  2:16   ` Vijay Subramanian
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2013-01-30 23:31 UTC (permalink / raw)
  To: Vijay Subramanian; +Cc: netdev, davem, niveditasinghvi

On Wed, 2013-01-30 at 14:57 -0800, Vijay Subramanian wrote:
> This patch updates LINUX_MIB_LISTENDROPS and LINUX_MIB_LISTENOVERFLOWS in
> tcp_v4_conn_request() and tcp_v4_err(). tcp_v4_conn_request() in particular can
> drop SYNs for various reasons which are not currently tracked.
> 
> Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
> ---
> Ignored "line over 80 chars" warning for readability.
> 
>  net/ipv4/tcp_ipv4.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)


>  	case TCP_SYN_SENT:
> @@ -1491,8 +1492,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
>  	 */
>  	if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
>  		want_cookie = tcp_syn_flood_action(sk, skb, "TCP");
> -		if (!want_cookie)
> +		if (!want_cookie) {
> +			NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
>  			goto drop;
> +		}

This should be done in tcp_syn_flood_action() for IPv4/IPv6
factorization.

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

* Re: [PATCH net] tcp: Update MIB counters for drops
  2013-01-30 23:31 ` Eric Dumazet
@ 2013-01-31  2:16   ` Vijay Subramanian
  0 siblings, 0 replies; 3+ messages in thread
From: Vijay Subramanian @ 2013-01-31  2:16 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem, niveditasinghvi

>
>
>>       case TCP_SYN_SENT:
>> @@ -1491,8 +1492,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
>>        */
>>       if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
>>               want_cookie = tcp_syn_flood_action(sk, skb, "TCP");
>> -             if (!want_cookie)
>> +             if (!want_cookie) {
>> +                     NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
>>                       goto drop;
>> +             }
>
> This should be done in tcp_syn_flood_action() for IPv4/IPv6
> factorization.
>

Thanks Eric. In fact, tcp_syn_flood_action() already has
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);

which is the right thing to do instead of incrementing LISTENOVERFLOWS
since it is syn table that is overflowing and
not accept_queue.

I will send V2 with this fixed.

Vijay

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

end of thread, other threads:[~2013-01-31  2:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-30 22:57 [PATCH net] tcp: Update MIB counters for drops Vijay Subramanian
2013-01-30 23:31 ` Eric Dumazet
2013-01-31  2:16   ` Vijay Subramanian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox