提交 1f8438a8 编写于 作者: E Eric Dumazet 提交者: David S. Miller

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: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 f66ef2d0
...@@ -100,6 +100,7 @@ enum ...@@ -100,6 +100,7 @@ enum
ICMP6_MIB_INMSGS, /* InMsgs */ ICMP6_MIB_INMSGS, /* InMsgs */
ICMP6_MIB_INERRORS, /* InErrors */ ICMP6_MIB_INERRORS, /* InErrors */
ICMP6_MIB_OUTMSGS, /* OutMsgs */ ICMP6_MIB_OUTMSGS, /* OutMsgs */
ICMP6_MIB_OUTERRORS, /* OutErrors */
__ICMP6_MIB_MAX __ICMP6_MIB_MAX
}; };
......
...@@ -330,9 +330,10 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param, ...@@ -330,9 +330,10 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
if (ip_append_data(sk, icmp_glue_bits, icmp_param, if (ip_append_data(sk, icmp_glue_bits, icmp_param,
icmp_param->data_len+icmp_param->head_len, icmp_param->data_len+icmp_param->head_len,
icmp_param->head_len, icmp_param->head_len,
ipc, rt, MSG_DONTWAIT) < 0) ipc, rt, MSG_DONTWAIT) < 0) {
ICMP_INC_STATS_BH(sock_net(sk), ICMP_MIB_OUTERRORS);
ip_flush_pending_frames(sk); ip_flush_pending_frames(sk);
else if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { } else if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
struct icmphdr *icmph = icmp_hdr(skb); struct icmphdr *icmph = icmp_hdr(skb);
__wsum csum = 0; __wsum csum = 0;
struct sk_buff *skb1; struct sk_buff *skb1;
......
...@@ -482,6 +482,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) ...@@ -482,6 +482,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
np->tclass, NULL, &fl, (struct rt6_info*)dst, np->tclass, NULL, &fl, (struct rt6_info*)dst,
MSG_DONTWAIT); MSG_DONTWAIT);
if (err) { if (err) {
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
ip6_flush_pending_frames(sk); ip6_flush_pending_frames(sk);
goto out_put; goto out_put;
} }
...@@ -562,6 +563,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -562,6 +563,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
(struct rt6_info*)dst, MSG_DONTWAIT); (struct rt6_info*)dst, MSG_DONTWAIT);
if (err) { if (err) {
ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
ip6_flush_pending_frames(sk); ip6_flush_pending_frames(sk);
goto out_put; goto out_put;
} }
......
...@@ -97,6 +97,7 @@ static const struct snmp_mib snmp6_icmp6_list[] = { ...@@ -97,6 +97,7 @@ static const struct snmp_mib snmp6_icmp6_list[] = {
SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS),
SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS),
SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS), SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS),
SNMP_MIB_ITEM("Icmp6OutErrors", ICMP6_MIB_OUTERRORS),
SNMP_MIB_SENTINEL SNMP_MIB_SENTINEL
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册