diff options
author | David L Stevens <dlstevens@us.ibm.com> | 2007-09-16 19:52:35 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:27 -0400 |
commit | 14878f75abd5bf1d38becb405801cd491ee215dc (patch) | |
tree | 872d70add65e1e58ccbbcc4534c7e826bd3fa9ed /net/ipv6/proc.c | |
parent | 8b14a536701b50559a0d69d5d593323f550db4e9 (diff) |
[IPV6]: Add ICMPMsgStats MIB (RFC 4293) [rev 2]
Background: RFC 4293 deprecates existing individual, named ICMP
type counters to be replaced with the ICMPMsgStatsTable. This table
includes entries for both IPv4 and IPv6, and requires counting of all
ICMP types, whether or not the machine implements the type.
These patches "remove" (but not really) the existing counters, and
replace them with the ICMPMsgStats tables for v4 and v6.
It includes the named counters in the /proc places they were, but gets the
values for them from the new tables. It also counts packets generated
from raw socket output (e.g., OutEchoes, MLD queries, RA's from
radvd, etc).
Changes:
1) create icmpmsg_statistics mib
2) create icmpv6msg_statistics mib
3) modify existing counters to use these
4) modify /proc/net/snmp to add "IcmpMsg" with all ICMP types
listed by number for easy SNMP parsing
5) modify /proc/net/snmp printing for "Icmp" to get the named data
from new counters.
[new to 2nd revision]
6) support per-interface ICMP stats
7) use common macro for per-device stat macros
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/proc.c')
-rw-r--r-- | net/ipv6/proc.c | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index a712a2289484..db945018579e 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -86,47 +86,33 @@ static struct snmp_mib snmp6_ipstats_list[] = { | |||
86 | }; | 86 | }; |
87 | 87 | ||
88 | static struct snmp_mib snmp6_icmp6_list[] = { | 88 | static struct snmp_mib snmp6_icmp6_list[] = { |
89 | /* icmpv6 mib according to RFC 2466 | 89 | /* icmpv6 mib according to RFC 2466 */ |
90 | |||
91 | Exceptions: {In|Out}AdminProhibs are removed, because I see | ||
92 | no good reasons to account them separately | ||
93 | of another dest.unreachs. | ||
94 | OutErrs is zero identically. | ||
95 | OutEchos too. | ||
96 | OutRouterAdvertisements too. | ||
97 | OutGroupMembQueries too. | ||
98 | */ | ||
99 | SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), | 90 | SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS), |
100 | SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), | 91 | SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS), |
101 | SNMP_MIB_ITEM("Icmp6InDestUnreachs", ICMP6_MIB_INDESTUNREACHS), | ||
102 | SNMP_MIB_ITEM("Icmp6InPktTooBigs", ICMP6_MIB_INPKTTOOBIGS), | ||
103 | SNMP_MIB_ITEM("Icmp6InTimeExcds", ICMP6_MIB_INTIMEEXCDS), | ||
104 | SNMP_MIB_ITEM("Icmp6InParmProblems", ICMP6_MIB_INPARMPROBLEMS), | ||
105 | SNMP_MIB_ITEM("Icmp6InEchos", ICMP6_MIB_INECHOS), | ||
106 | SNMP_MIB_ITEM("Icmp6InEchoReplies", ICMP6_MIB_INECHOREPLIES), | ||
107 | SNMP_MIB_ITEM("Icmp6InGroupMembQueries", ICMP6_MIB_INGROUPMEMBQUERIES), | ||
108 | SNMP_MIB_ITEM("Icmp6InGroupMembResponses", ICMP6_MIB_INGROUPMEMBRESPONSES), | ||
109 | SNMP_MIB_ITEM("Icmp6InGroupMembReductions", ICMP6_MIB_INGROUPMEMBREDUCTIONS), | ||
110 | SNMP_MIB_ITEM("Icmp6InRouterSolicits", ICMP6_MIB_INROUTERSOLICITS), | ||
111 | SNMP_MIB_ITEM("Icmp6InRouterAdvertisements", ICMP6_MIB_INROUTERADVERTISEMENTS), | ||
112 | SNMP_MIB_ITEM("Icmp6InNeighborSolicits", ICMP6_MIB_INNEIGHBORSOLICITS), | ||
113 | SNMP_MIB_ITEM("Icmp6InNeighborAdvertisements", ICMP6_MIB_INNEIGHBORADVERTISEMENTS), | ||
114 | SNMP_MIB_ITEM("Icmp6InRedirects", ICMP6_MIB_INREDIRECTS), | ||
115 | SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS), | 92 | SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS), |
116 | SNMP_MIB_ITEM("Icmp6OutDestUnreachs", ICMP6_MIB_OUTDESTUNREACHS), | ||
117 | SNMP_MIB_ITEM("Icmp6OutPktTooBigs", ICMP6_MIB_OUTPKTTOOBIGS), | ||
118 | SNMP_MIB_ITEM("Icmp6OutTimeExcds", ICMP6_MIB_OUTTIMEEXCDS), | ||
119 | SNMP_MIB_ITEM("Icmp6OutParmProblems", ICMP6_MIB_OUTPARMPROBLEMS), | ||
120 | SNMP_MIB_ITEM("Icmp6OutEchoReplies", ICMP6_MIB_OUTECHOREPLIES), | ||
121 | SNMP_MIB_ITEM("Icmp6OutRouterSolicits", ICMP6_MIB_OUTROUTERSOLICITS), | ||
122 | SNMP_MIB_ITEM("Icmp6OutNeighborSolicits", ICMP6_MIB_OUTNEIGHBORSOLICITS), | ||
123 | SNMP_MIB_ITEM("Icmp6OutNeighborAdvertisements", ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS), | ||
124 | SNMP_MIB_ITEM("Icmp6OutRedirects", ICMP6_MIB_OUTREDIRECTS), | ||
125 | SNMP_MIB_ITEM("Icmp6OutGroupMembResponses", ICMP6_MIB_OUTGROUPMEMBRESPONSES), | ||
126 | SNMP_MIB_ITEM("Icmp6OutGroupMembReductions", ICMP6_MIB_OUTGROUPMEMBREDUCTIONS), | ||
127 | SNMP_MIB_SENTINEL | 93 | SNMP_MIB_SENTINEL |
128 | }; | 94 | }; |
129 | 95 | ||
96 | /* RFC 4293 v6 ICMPMsgStatsTable; named items for RFC 2466 compatibility */ | ||
97 | static char *icmp6type2name[256] = { | ||
98 | [ICMPV6_DEST_UNREACH] = "DestUnreachs", | ||
99 | [ICMPV6_PKT_TOOBIG] = "PktTooBigs", | ||
100 | [ICMPV6_TIME_EXCEED] = "TimeExcds", | ||
101 | [ICMPV6_PARAMPROB] = "ParmProblems", | ||
102 | [ICMPV6_ECHO_REQUEST] = "EchoRequest", | ||
103 | [ICMPV6_ECHO_REPLY] = "EchoReplies", | ||
104 | [ICMPV6_MGM_QUERY] = "GroupMembQueries", | ||
105 | [ICMPV6_MGM_REPORT] = "GroupMembResponses", | ||
106 | [ICMPV6_MGM_REDUCTION] = "GroupMembReductions", | ||
107 | [ICMPV6_MLD2_REPORT] = "MLDv2Reports", | ||
108 | [NDISC_ROUTER_ADVERTISEMENT] = "RouterAdvertisements", | ||
109 | [NDISC_ROUTER_SOLICITATION] = "RouterSolicits", | ||
110 | [NDISC_NEIGHBOUR_ADVERTISEMENT] = "NeighborAdvertisements", | ||
111 | [NDISC_NEIGHBOUR_SOLICITATION] = "NeighborSolicits", | ||
112 | [NDISC_REDIRECT] = "NeighborRedirects", | ||
113 | }; | ||
114 | |||
115 | |||
130 | static struct snmp_mib snmp6_udp6_list[] = { | 116 | static struct snmp_mib snmp6_udp6_list[] = { |
131 | SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS), | 117 | SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS), |
132 | SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS), | 118 | SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS), |
@@ -143,6 +129,40 @@ static struct snmp_mib snmp6_udplite6_list[] = { | |||
143 | SNMP_MIB_SENTINEL | 129 | SNMP_MIB_SENTINEL |
144 | }; | 130 | }; |
145 | 131 | ||
132 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) | ||
133 | { | ||
134 | static char name[32]; | ||
135 | int i; | ||
136 | |||
137 | /* print by name -- deprecated items */ | ||
138 | for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { | ||
139 | int icmptype; | ||
140 | char *p; | ||
141 | |||
142 | icmptype = i & 0xff; | ||
143 | p = icmp6type2name[icmptype]; | ||
144 | if (!p) /* don't print un-named types here */ | ||
145 | continue; | ||
146 | (void) snprintf(name, sizeof(name)-1, "Icmp6%s%s", | ||
147 | i & 0x100 ? "Out" : "In", p); | ||
148 | seq_printf(seq, "%-32s\t%lu\n", name, | ||
149 | snmp_fold_field(mib, i)); | ||
150 | } | ||
151 | |||
152 | /* print by number (nonzero only) - ICMPMsgStat format */ | ||
153 | for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { | ||
154 | unsigned long val; | ||
155 | |||
156 | val = snmp_fold_field(mib, i); | ||
157 | if (!val) | ||
158 | continue; | ||
159 | (void) snprintf(name, sizeof(name)-1, "Icmp6%sType%u", | ||
160 | i & 0x100 ? "Out" : "In", i & 0xff); | ||
161 | seq_printf(seq, "%-32s\t%lu\n", name, val); | ||
162 | } | ||
163 | return; | ||
164 | } | ||
165 | |||
146 | static inline void | 166 | static inline void |
147 | snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist) | 167 | snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist) |
148 | { | 168 | { |
@@ -160,9 +180,11 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
160 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); | 180 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); |
161 | snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list); | 181 | snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list); |
162 | snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); | 182 | snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); |
183 | snmp6_seq_show_icmpv6msg(seq, (void **)idev->stats.icmpv6msg); | ||
163 | } else { | 184 | } else { |
164 | snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); | 185 | snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); |
165 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); | 186 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); |
187 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); | ||
166 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); | 188 | snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); |
167 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); | 189 | snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list); |
168 | } | 190 | } |