diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-03-07 18:21:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-08 13:45:27 -0500 |
commit | 6cce09f87a04797fae5b947ef2626c14a78f0b49 (patch) | |
tree | a1d7638f9571a29db9bc5c5d8e0baee19597d59e | |
parent | 4045635318538d3ddd2007720412fdc4b08f6a62 (diff) |
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/snmp.h | 2 | ||||
-rw-r--r-- | net/ipv4/proc.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 7 | ||||
-rw-r--r-- | 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 e28f5a0182e8..4435d1084755 100644 --- a/include/linux/snmp.h +++ b/include/linux/snmp.h | |||
@@ -225,6 +225,8 @@ enum | |||
225 | LINUX_MIB_SACKSHIFTED, | 225 | LINUX_MIB_SACKSHIFTED, |
226 | LINUX_MIB_SACKMERGED, | 226 | LINUX_MIB_SACKMERGED, |
227 | LINUX_MIB_SACKSHIFTFALLBACK, | 227 | LINUX_MIB_SACKSHIFTFALLBACK, |
228 | LINUX_MIB_TCPBACKLOGDROP, | ||
229 | LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */ | ||
228 | __LINUX_MIB_MAX | 230 | __LINUX_MIB_MAX |
229 | }; | 231 | }; |
230 | 232 | ||
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 242ed2307370..4f1f337f4337 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -249,6 +249,8 @@ static const struct snmp_mib snmp4_net_list[] = { | |||
249 | SNMP_MIB_ITEM("TCPSackShifted", LINUX_MIB_SACKSHIFTED), | 249 | SNMP_MIB_ITEM("TCPSackShifted", LINUX_MIB_SACKSHIFTED), |
250 | SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED), | 250 | SNMP_MIB_ITEM("TCPSackMerged", LINUX_MIB_SACKMERGED), |
251 | SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK), | 251 | SNMP_MIB_ITEM("TCPSackShiftFallback", LINUX_MIB_SACKSHIFTFALLBACK), |
252 | SNMP_MIB_ITEM("TCPBacklogDrop", LINUX_MIB_TCPBACKLOGDROP), | ||
253 | SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP), | ||
252 | SNMP_MIB_SENTINEL | 254 | SNMP_MIB_SENTINEL |
253 | }; | 255 | }; |
254 | 256 | ||
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 1915f7dc30e6..8d51d39ad1bb 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) | |||
1651 | if (!sk) | 1651 | if (!sk) |
1652 | goto no_tcp_socket; | 1652 | goto no_tcp_socket; |
1653 | 1653 | ||
1654 | if (iph->ttl < inet_sk(sk)->min_ttl) | 1654 | if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) { |
1655 | NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP); | ||
1655 | goto discard_and_relse; | 1656 | goto discard_and_relse; |
1657 | } | ||
1656 | 1658 | ||
1657 | process: | 1659 | process: |
1658 | if (sk->sk_state == TCP_TIME_WAIT) | 1660 | if (sk->sk_state == TCP_TIME_WAIT) |
@@ -1682,8 +1684,9 @@ process: | |||
1682 | if (!tcp_prequeue(sk, skb)) | 1684 | if (!tcp_prequeue(sk, skb)) |
1683 | ret = tcp_v4_do_rcv(sk, skb); | 1685 | ret = tcp_v4_do_rcv(sk, skb); |
1684 | } | 1686 | } |
1685 | } else if (sk_add_backlog(sk, skb)) { | 1687 | } else if (unlikely(sk_add_backlog(sk, skb))) { |
1686 | bh_unlock_sock(sk); | 1688 | bh_unlock_sock(sk); |
1689 | NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP); | ||
1687 | goto discard_and_relse; | 1690 | goto discard_and_relse; |
1688 | } | 1691 | } |
1689 | bh_unlock_sock(sk); | 1692 | bh_unlock_sock(sk); |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2c378b1bd5cf..9b6dbba80d31 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1740,8 +1740,9 @@ process: | |||
1740 | if (!tcp_prequeue(sk, skb)) | 1740 | if (!tcp_prequeue(sk, skb)) |
1741 | ret = tcp_v6_do_rcv(sk, skb); | 1741 | ret = tcp_v6_do_rcv(sk, skb); |
1742 | } | 1742 | } |
1743 | } else if (sk_add_backlog(sk, skb)) { | 1743 | } else if (unlikely(sk_add_backlog(sk, skb))) { |
1744 | bh_unlock_sock(sk); | 1744 | bh_unlock_sock(sk); |
1745 | NET_INC_STATS_BH(net, LINUX_MIB_TCPBACKLOGDROP); | ||
1745 | goto discard_and_relse; | 1746 | goto discard_and_relse; |
1746 | } | 1747 | } |
1747 | bh_unlock_sock(sk); | 1748 | bh_unlock_sock(sk); |