Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Zhu Yi <yi.zhu@intel.com>, David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH V3 2/8] tcp: use limited socket backlog
Date: Mon, 08 Mar 2010 10:21:57 +0100	[thread overview]
Message-ID: <1268040117.6148.68.camel@edumazet-laptop> (raw)
In-Reply-To: <1267769972.2867.1.camel@edumazet-laptop>

Le vendredi 05 mars 2010 à 07:19 +0100, Eric Dumazet a écrit :

> I'll submit a followup patch to add a MIB counter if your patch gets in.
> 

As promised, here it is.

[PATCH] tcp: Add SNMP counters for backlog and min_ttl drops

Commit 6b03a53a (tcp: use limited socket backlog) added the possibility
of dropping frames when backlog queue is full.

Commit d218d111 (tcp: Generalized TTL Security Mechanism) added the
possibility of dropping frames when TTL is under a given limit.

This patch adds new SNMP MIB entries, named TCPBacklogDrop and 
TCPMinTTLDrop, published in /proc/net/netstat in TcpExt: line

netstat -s | egrep "TCPBacklogDrop|TCPMinTTLDrop"
    TCPBacklogDrop: 0
    TCPMinTTLDrop: 0

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 include/linux/snmp.h |    2 ++
 net/ipv4/proc.c      |    2 ++
 net/ipv4/tcp_ipv4.c  |    7 +++++--
 net/ipv6/tcp_ipv6.c  |    3 ++-
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index e28f5a0..4435d10 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -225,6 +225,8 @@ enum
 	LINUX_MIB_SACKSHIFTED,
 	LINUX_MIB_SACKMERGED,
 	LINUX_MIB_SACKSHIFTFALLBACK,
+	LINUX_MIB_TCPBACKLOGDROP,
+	LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */
 	__LINUX_MIB_MAX
 };
 
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 242ed23..4f1f337 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -249,6 +249,8 @@ static const struct snmp_mib snmp4_net_list[] = {
 	SNMP_MIB_ITEM("TCPSackShifted", LINUX_MIB_SACKSHIFTED),
 	SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED),
 	SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK),
+	SNMP_MIB_ITEM("TCPBacklogDrop", LINUX_MIB_TCPBACKLOGDROP),
+	SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP),
 	SNMP_MIB_SENTINEL
 };
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1915f7d..8d51d39 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1651,8 +1651,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	if (!sk)
 		goto no_tcp_socket;
 
-	if (iph->ttl < inet_sk(sk)->min_ttl)
+	if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
+		NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
 		goto discard_and_relse;
+	}
 
 process:
 	if (sk->sk_state == TCP_TIME_WAIT)
@@ -1682,8 +1684,9 @@ process:
 			if (!tcp_prequeue(sk, skb))
 				ret = tcp_v4_do_rcv(sk, skb);
 		}
-	} else if (sk_add_backlog(sk, skb)) {
+	} else if (unlikely(sk_add_backlog(sk, skb))) {
 		bh_unlock_sock(sk);
+		NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP);
 		goto discard_and_relse;
 	}
 	bh_unlock_sock(sk);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2c378b1..9b6dbba 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1740,8 +1740,9 @@ process:
 			if (!tcp_prequeue(sk, skb))
 				ret = tcp_v6_do_rcv(sk, skb);
 		}
-	} else if (sk_add_backlog(sk, skb)) {
+	} else if (unlikely(sk_add_backlog(sk, skb))) {
 		bh_unlock_sock(sk);
+		NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP);
 		goto discard_and_relse;
 	}
 	bh_unlock_sock(sk);



  reply	other threads:[~2010-03-08  9:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1267761707-15605-1-git-send-email-yi.zhu@intel.com>
2010-03-05  4:01 ` [PATCH V3 2/8] tcp: use limited socket backlog Zhu Yi
2010-03-05  4:01   ` [PATCH V3 3/8] udp: " Zhu Yi
2010-03-05  4:01     ` [PATCH V3 4/8] llc: " Zhu Yi
2010-03-05  4:01       ` [PATCH V3 5/8] sctp: " Zhu Yi
2010-03-05  6:28         ` Eric Dumazet
2010-03-05 11:05           ` Zhu, Yi
2010-03-05 13:24             ` Eric Dumazet
2010-03-05 13:30             ` Vlad Yasevich
     [not found]         ` <1267761707-15605-6-git-send-email-yi.zhu@intel.com>
2010-03-05  4:01           ` [PATCH V3 7/8] x25: " Zhu Yi
2010-03-05  4:01             ` [PATCH V3 8/8] net: backlog functions rename Zhu Yi
2010-03-05  6:32               ` Eric Dumazet
2010-03-05 21:36                 ` David Miller
2010-03-05  6:30             ` [PATCH V3 7/8] x25: use limited socket backlog Eric Dumazet
2010-03-05  6:30           ` [PATCH V3 6/8] tipc: " Eric Dumazet
2010-03-05 20:48           ` Stephens, Allan
2010-03-05  6:22       ` [PATCH V3 4/8] llc: " Eric Dumazet
2010-03-05 13:00       ` Arnaldo Carvalho de Melo
2010-03-05  6:21     ` [PATCH V3 3/8] udp: " Eric Dumazet
2010-03-05  6:19   ` [PATCH V3 2/8] tcp: " Eric Dumazet
2010-03-08  9:21     ` Eric Dumazet [this message]
2010-03-08 18:46       ` David Miller
2010-03-05 13:00 ` [PATCH V3 1/8] net: add limit for " Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268040117.6148.68.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=yi.zhu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox