aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-04-03 18:09:04 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-03 18:09:04 -0400
commit1f8438a853667d48055ad38384c63e94b32c6578 (patch)
treed515b2246023abce5f151f35d70d270fa05b90c7
parentf66ef2d0649b220874532dfb83b6b5b368f83591 (diff)
icmp: Account for ICMP out errors
When ip_append() fails because of socket limit or memory shortage, increment ICMP_MIB_OUTERRORS counter, so that "netstat -s" can report these errors. LANG=C netstat -s | grep "ICMP messages failed" 0 ICMP messages failed For IPV6, implement ICMP6_MIB_OUTERRORS counter as well. # grep Icmp6OutErrors /proc/net/dev_snmp6/* /proc/net/dev_snmp6/eth0:Icmp6OutErrors 0 /proc/net/dev_snmp6/lo:Icmp6OutErrors 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.h1
-rw-r--r--net/ipv4/icmp.c5
-rw-r--r--net/ipv6/icmp.c2
-rw-r--r--net/ipv6/proc.c1
4 files changed, 7 insertions, 2 deletions
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index d2a9aa3c6c88..52797714ade7 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -100,6 +100,7 @@ enum
100 ICMP6_MIB_INMSGS, /* InMsgs */ 100 ICMP6_MIB_INMSGS, /* InMsgs */
101 ICMP6_MIB_INERRORS, /* InErrors */ 101 ICMP6_MIB_INERRORS, /* InErrors */
102 ICMP6_MIB_OUTMSGS, /* OutMsgs */ 102 ICMP6_MIB_OUTMSGS, /* OutMsgs */
103 ICMP6_MIB_OUTERRORS, /* OutErrors */
103 __ICMP6_MIB_MAX 104 __ICMP6_MIB_MAX
104}; 105};
105 106
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 4b4c2bcd15db..d2aa7438c523 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -330,9 +330,10 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
330 if (ip_append_data(sk, icmp_glue_bits, icmp_param, 330 if (ip_append_data(sk, icmp_glue_bits, icmp_param,
331 icmp_param->data_len+icmp_param->head_len, 331 icmp_param->data_len+icmp_param->head_len,
332 icmp_param->head_len, 332 icmp_param->head_len,
333 ipc, rt, MSG_DONTWAIT) < 0) 333 ipc, rt, MSG_DONTWAIT) < 0) {
334 ICMP_INC_STATS_BH(sock_net(sk), ICMP_MIB_OUTERRORS);
334 ip_flush_pending_frames(sk); 335 ip_flush_pending_frames(sk);
335 else if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { 336 } else if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
336 struct icmphdr *icmph = icmp_hdr(skb); 337 struct icmphdr *icmph = icmp_hdr(skb);
337 __wsum csum = 0; 338 __wsum csum = 0;
338 struct sk_buff *skb1; 339 struct sk_buff *skb1;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index eb9abe24bdf0..a00c18aa6c8d 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -482,6 +482,7 @@ route_done:
482 np->tclass, NULL, &fl, (struct rt6_info*)dst, 482 np->tclass, NULL, &fl, (struct rt6_info*)dst,
483 MSG_DONTWAIT); 483 MSG_DONTWAIT);
484 if (err) { 484 if (err) {
485 ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
485 ip6_flush_pending_frames(sk); 486 ip6_flush_pending_frames(sk);
486 goto out_put; 487 goto out_put;
487 } 488 }
@@ -562,6 +563,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
562 (struct rt6_info*)dst, MSG_DONTWAIT); 563 (struct rt6_info*)dst, MSG_DONTWAIT);
563 564
564 if (err) { 565 if (err) {
566 ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
565 ip6_flush_pending_frames(sk); 567 ip6_flush_pending_frames(sk);
566 goto out_put; 568 goto out_put;
567 } 569 }
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 58344c0fbd13..458eabfbe130 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -97,6 +97,7 @@ static const struct snmp_mib snmp6_icmp6_list[] = {
97 SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), 97 SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS),
98 SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), 98 SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS),
99 SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS), 99 SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS),
100 SNMP_MIB_ITEM("Icmp6OutErrors", ICMP6_MIB_OUTERRORS),
100 SNMP_MIB_SENTINEL 101 SNMP_MIB_SENTINEL
101}; 102};
102 103