diff options
author | David L Stevens <dlstevens@us.ibm.com> | 2007-09-17 12:57:33 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:28 -0400 |
commit | 96793b482540f3a26e2188eaf75cb56b7829d3e3 (patch) | |
tree | 3dfc2871b69cc358ed55dc2adc3bfeef47382cb3 /net/ipv4/proc.c | |
parent | 14878f75abd5bf1d38becb405801cd491ee215dc (diff) |
[IPV4]: Add ICMPMsgStats MIB (RFC 4293)
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.
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/proc.c')
-rw-r--r-- | net/ipv4/proc.c | 120 |
1 files changed, 89 insertions, 31 deletions
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 95a8f8f2de71..2015148b41a8 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -124,33 +124,30 @@ static const struct snmp_mib snmp4_ipextstats_list[] = { | |||
124 | static const struct snmp_mib snmp4_icmp_list[] = { | 124 | static const struct snmp_mib snmp4_icmp_list[] = { |
125 | SNMP_MIB_ITEM("InMsgs", ICMP_MIB_INMSGS), | 125 | SNMP_MIB_ITEM("InMsgs", ICMP_MIB_INMSGS), |
126 | SNMP_MIB_ITEM("InErrors", ICMP_MIB_INERRORS), | 126 | SNMP_MIB_ITEM("InErrors", ICMP_MIB_INERRORS), |
127 | SNMP_MIB_ITEM("InDestUnreachs", ICMP_MIB_INDESTUNREACHS), | ||
128 | SNMP_MIB_ITEM("InTimeExcds", ICMP_MIB_INTIMEEXCDS), | ||
129 | SNMP_MIB_ITEM("InParmProbs", ICMP_MIB_INPARMPROBS), | ||
130 | SNMP_MIB_ITEM("InSrcQuenchs", ICMP_MIB_INSRCQUENCHS), | ||
131 | SNMP_MIB_ITEM("InRedirects", ICMP_MIB_INREDIRECTS), | ||
132 | SNMP_MIB_ITEM("InEchos", ICMP_MIB_INECHOS), | ||
133 | SNMP_MIB_ITEM("InEchoReps", ICMP_MIB_INECHOREPS), | ||
134 | SNMP_MIB_ITEM("InTimestamps", ICMP_MIB_INTIMESTAMPS), | ||
135 | SNMP_MIB_ITEM("InTimestampReps", ICMP_MIB_INTIMESTAMPREPS), | ||
136 | SNMP_MIB_ITEM("InAddrMasks", ICMP_MIB_INADDRMASKS), | ||
137 | SNMP_MIB_ITEM("InAddrMaskReps", ICMP_MIB_INADDRMASKREPS), | ||
138 | SNMP_MIB_ITEM("OutMsgs", ICMP_MIB_OUTMSGS), | 127 | SNMP_MIB_ITEM("OutMsgs", ICMP_MIB_OUTMSGS), |
139 | SNMP_MIB_ITEM("OutErrors", ICMP_MIB_OUTERRORS), | 128 | SNMP_MIB_ITEM("OutErrors", ICMP_MIB_OUTERRORS), |
140 | SNMP_MIB_ITEM("OutDestUnreachs", ICMP_MIB_OUTDESTUNREACHS), | ||
141 | SNMP_MIB_ITEM("OutTimeExcds", ICMP_MIB_OUTTIMEEXCDS), | ||
142 | SNMP_MIB_ITEM("OutParmProbs", ICMP_MIB_OUTPARMPROBS), | ||
143 | SNMP_MIB_ITEM("OutSrcQuenchs", ICMP_MIB_OUTSRCQUENCHS), | ||
144 | SNMP_MIB_ITEM("OutRedirects", ICMP_MIB_OUTREDIRECTS), | ||
145 | SNMP_MIB_ITEM("OutEchos", ICMP_MIB_OUTECHOS), | ||
146 | SNMP_MIB_ITEM("OutEchoReps", ICMP_MIB_OUTECHOREPS), | ||
147 | SNMP_MIB_ITEM("OutTimestamps", ICMP_MIB_OUTTIMESTAMPS), | ||
148 | SNMP_MIB_ITEM("OutTimestampReps", ICMP_MIB_OUTTIMESTAMPREPS), | ||
149 | SNMP_MIB_ITEM("OutAddrMasks", ICMP_MIB_OUTADDRMASKS), | ||
150 | SNMP_MIB_ITEM("OutAddrMaskReps", ICMP_MIB_OUTADDRMASKREPS), | ||
151 | SNMP_MIB_SENTINEL | 129 | SNMP_MIB_SENTINEL |
152 | }; | 130 | }; |
153 | 131 | ||
132 | static struct { | ||
133 | char *name; | ||
134 | int index; | ||
135 | } icmpmibmap[] = { | ||
136 | { "DestUnreachs", ICMP_DEST_UNREACH }, | ||
137 | { "TimeExcds", ICMP_TIME_EXCEEDED }, | ||
138 | { "ParmProbs", ICMP_PARAMETERPROB }, | ||
139 | { "SrcQuenchs", ICMP_SOURCE_QUENCH }, | ||
140 | { "Redirects", ICMP_REDIRECT }, | ||
141 | { "Echos", ICMP_ECHO }, | ||
142 | { "EchoReps", ICMP_ECHOREPLY }, | ||
143 | { "Timestamps", ICMP_TIMESTAMP }, | ||
144 | { "TimestampReps", ICMP_TIMESTAMPREPLY }, | ||
145 | { "AddrMasks", ICMP_ADDRESS }, | ||
146 | { "AddrMaskReps", ICMP_ADDRESSREPLY }, | ||
147 | { 0, 0 } | ||
148 | }; | ||
149 | |||
150 | |||
154 | static const struct snmp_mib snmp4_tcp_list[] = { | 151 | static const struct snmp_mib snmp4_tcp_list[] = { |
155 | SNMP_MIB_ITEM("RtoAlgorithm", TCP_MIB_RTOALGORITHM), | 152 | SNMP_MIB_ITEM("RtoAlgorithm", TCP_MIB_RTOALGORITHM), |
156 | SNMP_MIB_ITEM("RtoMin", TCP_MIB_RTOMIN), | 153 | SNMP_MIB_ITEM("RtoMin", TCP_MIB_RTOMIN), |
@@ -251,6 +248,72 @@ static const struct snmp_mib snmp4_net_list[] = { | |||
251 | SNMP_MIB_SENTINEL | 248 | SNMP_MIB_SENTINEL |
252 | }; | 249 | }; |
253 | 250 | ||
251 | static void icmpmsg_put(struct seq_file *seq) | ||
252 | { | ||
253 | #define PERLINE 16 | ||
254 | |||
255 | int j, i, count; | ||
256 | static int out[PERLINE]; | ||
257 | |||
258 | count = 0; | ||
259 | for (i = 0; i < ICMPMSG_MIB_MAX; i++) { | ||
260 | |||
261 | if (snmp_fold_field((void **) icmpmsg_statistics, i)) | ||
262 | out[count++] = i; | ||
263 | if (count < PERLINE) | ||
264 | continue; | ||
265 | |||
266 | seq_printf(seq, "\nIcmpMsg:"); | ||
267 | for (j = 0; j < PERLINE; ++j) | ||
268 | seq_printf(seq, " %sType%u", i & 0x100 ? "Out" : "In", | ||
269 | i & 0xff); | ||
270 | seq_printf(seq, "\nIcmpMsg: "); | ||
271 | for (j = 0; j < PERLINE; ++j) | ||
272 | seq_printf(seq, " %lu", | ||
273 | snmp_fold_field((void **) icmpmsg_statistics, | ||
274 | out[j])); | ||
275 | seq_putc(seq, '\n'); | ||
276 | } | ||
277 | if (count) { | ||
278 | seq_printf(seq, "\nIcmpMsg:"); | ||
279 | for (j = 0; j < count; ++j) | ||
280 | seq_printf(seq, " %sType%u", out[j] & 0x100 ? "Out" : | ||
281 | "In", out[j] & 0xff); | ||
282 | seq_printf(seq, "\nIcmpMsg:"); | ||
283 | for (j = 0; j < count; ++j) | ||
284 | seq_printf(seq, " %lu", snmp_fold_field((void **) | ||
285 | icmpmsg_statistics, out[j])); | ||
286 | } | ||
287 | |||
288 | #undef PERLINE | ||
289 | } | ||
290 | |||
291 | static void icmp_put(struct seq_file *seq) | ||
292 | { | ||
293 | int i; | ||
294 | |||
295 | seq_puts(seq, "\nIcmp: InMsgs InErrors"); | ||
296 | for (i=0; icmpmibmap[i].name != NULL; i++) | ||
297 | seq_printf(seq, " In%s", icmpmibmap[i].name); | ||
298 | seq_printf(seq, " OutMsgs OutErrors"); | ||
299 | for (i=0; icmpmibmap[i].name != NULL; i++) | ||
300 | seq_printf(seq, " Out%s", icmpmibmap[i].name); | ||
301 | seq_printf(seq, "\nIcmp: %lu %lu", | ||
302 | snmp_fold_field((void **) icmp_statistics, ICMP_MIB_INMSGS), | ||
303 | snmp_fold_field((void **) icmp_statistics, ICMP_MIB_INERRORS)); | ||
304 | for (i=0; icmpmibmap[i].name != NULL; i++) | ||
305 | seq_printf(seq, " %lu", | ||
306 | snmp_fold_field((void **) icmpmsg_statistics, | ||
307 | icmpmibmap[i].index)); | ||
308 | seq_printf(seq, " %lu %lu", | ||
309 | snmp_fold_field((void **) icmp_statistics, ICMP_MIB_OUTMSGS), | ||
310 | snmp_fold_field((void **) icmp_statistics, ICMP_MIB_OUTERRORS)); | ||
311 | for (i=0; icmpmibmap[i].name != NULL; i++) | ||
312 | seq_printf(seq, " %lu", | ||
313 | snmp_fold_field((void **) icmpmsg_statistics, | ||
314 | icmpmibmap[i].index)); | ||
315 | } | ||
316 | |||
254 | /* | 317 | /* |
255 | * Called from the PROCfs module. This outputs /proc/net/snmp. | 318 | * Called from the PROCfs module. This outputs /proc/net/snmp. |
256 | */ | 319 | */ |
@@ -271,15 +334,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
271 | snmp_fold_field((void **)ip_statistics, | 334 | snmp_fold_field((void **)ip_statistics, |
272 | snmp4_ipstats_list[i].entry)); | 335 | snmp4_ipstats_list[i].entry)); |
273 | 336 | ||
274 | seq_puts(seq, "\nIcmp:"); | 337 | icmp_put(seq); /* RFC 2011 compatibility */ |
275 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) | 338 | icmpmsg_put(seq); |
276 | seq_printf(seq, " %s", snmp4_icmp_list[i].name); | ||
277 | |||
278 | seq_puts(seq, "\nIcmp:"); | ||
279 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) | ||
280 | seq_printf(seq, " %lu", | ||
281 | snmp_fold_field((void **)icmp_statistics, | ||
282 | snmp4_icmp_list[i].entry)); | ||
283 | 339 | ||
284 | seq_puts(seq, "\nTcp:"); | 340 | seq_puts(seq, "\nTcp:"); |
285 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) | 341 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) |
@@ -336,6 +392,8 @@ static const struct file_operations snmp_seq_fops = { | |||
336 | .release = single_release, | 392 | .release = single_release, |
337 | }; | 393 | }; |
338 | 394 | ||
395 | |||
396 | |||
339 | /* | 397 | /* |
340 | * Output /proc/net/netstat | 398 | * Output /proc/net/netstat |
341 | */ | 399 | */ |