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 /include | |
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 'include')
-rw-r--r-- | include/linux/snmp.h | 27 | ||||
-rw-r--r-- | include/net/if_inet6.h | 1 | ||||
-rw-r--r-- | include/net/ipv6.h | 67 | ||||
-rw-r--r-- | include/net/snmp.h | 6 |
4 files changed, 41 insertions, 60 deletions
diff --git a/include/linux/snmp.h b/include/linux/snmp.h index d24c55473821..86977e31548a 100644 --- a/include/linux/snmp.h +++ b/include/linux/snmp.h | |||
@@ -91,35 +91,12 @@ enum | |||
91 | ICMP6_MIB_NUM = 0, | 91 | ICMP6_MIB_NUM = 0, |
92 | ICMP6_MIB_INMSGS, /* InMsgs */ | 92 | ICMP6_MIB_INMSGS, /* InMsgs */ |
93 | ICMP6_MIB_INERRORS, /* InErrors */ | 93 | ICMP6_MIB_INERRORS, /* InErrors */ |
94 | ICMP6_MIB_INDESTUNREACHS, /* InDestUnreachs */ | ||
95 | ICMP6_MIB_INPKTTOOBIGS, /* InPktTooBigs */ | ||
96 | ICMP6_MIB_INTIMEEXCDS, /* InTimeExcds */ | ||
97 | ICMP6_MIB_INPARMPROBLEMS, /* InParmProblems */ | ||
98 | ICMP6_MIB_INECHOS, /* InEchos */ | ||
99 | ICMP6_MIB_INECHOREPLIES, /* InEchoReplies */ | ||
100 | ICMP6_MIB_INGROUPMEMBQUERIES, /* InGroupMembQueries */ | ||
101 | ICMP6_MIB_INGROUPMEMBRESPONSES, /* InGroupMembResponses */ | ||
102 | ICMP6_MIB_INGROUPMEMBREDUCTIONS, /* InGroupMembReductions */ | ||
103 | ICMP6_MIB_INROUTERSOLICITS, /* InRouterSolicits */ | ||
104 | ICMP6_MIB_INROUTERADVERTISEMENTS, /* InRouterAdvertisements */ | ||
105 | ICMP6_MIB_INNEIGHBORSOLICITS, /* InNeighborSolicits */ | ||
106 | ICMP6_MIB_INNEIGHBORADVERTISEMENTS, /* InNeighborAdvertisements */ | ||
107 | ICMP6_MIB_INREDIRECTS, /* InRedirects */ | ||
108 | ICMP6_MIB_OUTMSGS, /* OutMsgs */ | 94 | ICMP6_MIB_OUTMSGS, /* OutMsgs */ |
109 | ICMP6_MIB_OUTDESTUNREACHS, /* OutDestUnreachs */ | ||
110 | ICMP6_MIB_OUTPKTTOOBIGS, /* OutPktTooBigs */ | ||
111 | ICMP6_MIB_OUTTIMEEXCDS, /* OutTimeExcds */ | ||
112 | ICMP6_MIB_OUTPARMPROBLEMS, /* OutParmProblems */ | ||
113 | ICMP6_MIB_OUTECHOREPLIES, /* OutEchoReplies */ | ||
114 | ICMP6_MIB_OUTROUTERSOLICITS, /* OutRouterSolicits */ | ||
115 | ICMP6_MIB_OUTNEIGHBORSOLICITS, /* OutNeighborSolicits */ | ||
116 | ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS, /* OutNeighborAdvertisements */ | ||
117 | ICMP6_MIB_OUTREDIRECTS, /* OutRedirects */ | ||
118 | ICMP6_MIB_OUTGROUPMEMBRESPONSES, /* OutGroupMembResponses */ | ||
119 | ICMP6_MIB_OUTGROUPMEMBREDUCTIONS, /* OutGroupMembReductions */ | ||
120 | __ICMP6_MIB_MAX | 95 | __ICMP6_MIB_MAX |
121 | }; | 96 | }; |
122 | 97 | ||
98 | #define __ICMP6MSG_MIB_MAX 512 /* Out+In for all 8-bit ICMPv6 types */ | ||
99 | |||
123 | /* tcp mib definitions */ | 100 | /* tcp mib definitions */ |
124 | /* | 101 | /* |
125 | * RFC 1213: MIB-II TCP group | 102 | * RFC 1213: MIB-II TCP group |
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h index 3ec7d07346d6..448eccb20638 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h | |||
@@ -154,6 +154,7 @@ struct ipv6_devstat { | |||
154 | struct proc_dir_entry *proc_dir_entry; | 154 | struct proc_dir_entry *proc_dir_entry; |
155 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); | 155 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); |
156 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); | 156 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); |
157 | DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg); | ||
157 | }; | 158 | }; |
158 | 159 | ||
159 | struct inet6_dev | 160 | struct inet6_dev |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 9573c8d19153..31b3f1b45a2b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -112,45 +112,28 @@ struct frag_hdr { | |||
112 | extern int sysctl_ipv6_bindv6only; | 112 | extern int sysctl_ipv6_bindv6only; |
113 | extern int sysctl_mld_max_msf; | 113 | extern int sysctl_mld_max_msf; |
114 | 114 | ||
115 | /* MIBs */ | 115 | #define _DEVINC(statname, modifier, idev, field) \ |
116 | DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | 116 | ({ \ |
117 | #define IP6_INC_STATS(idev,field) ({ \ | ||
118 | struct inet6_dev *_idev = (idev); \ | 117 | struct inet6_dev *_idev = (idev); \ |
119 | if (likely(_idev != NULL)) \ | 118 | if (likely(_idev != NULL)) \ |
120 | SNMP_INC_STATS(_idev->stats.ipv6, field); \ | 119 | SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ |
121 | SNMP_INC_STATS(ipv6_statistics, field); \ | 120 | SNMP_INC_STATS##modifier(statname##_statistics, (field)); \ |
122 | }) | ||
123 | #define IP6_INC_STATS_BH(idev,field) ({ \ | ||
124 | struct inet6_dev *_idev = (idev); \ | ||
125 | if (likely(_idev != NULL)) \ | ||
126 | SNMP_INC_STATS_BH(_idev->stats.ipv6, field); \ | ||
127 | SNMP_INC_STATS_BH(ipv6_statistics, field); \ | ||
128 | }) | ||
129 | #define IP6_INC_STATS_USER(idev,field) ({ \ | ||
130 | struct inet6_dev *_idev = (idev); \ | ||
131 | if (likely(_idev != NULL)) \ | ||
132 | SNMP_INC_STATS_USER(_idev->stats.ipv6, field); \ | ||
133 | SNMP_INC_STATS_USER(ipv6_statistics, field); \ | ||
134 | }) | 121 | }) |
122 | |||
123 | /* MIBs */ | ||
124 | DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | ||
125 | |||
126 | #define IP6_INC_STATS(idev,field) _DEVINC(ipv6, , idev, field) | ||
127 | #define IP6_INC_STATS_BH(idev,field) _DEVINC(ipv6, _BH, idev, field) | ||
128 | #define IP6_INC_STATS_USER(idev,field) _DEVINC(ipv6, _USER, idev, field) | ||
129 | |||
135 | DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | 130 | DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); |
136 | #define ICMP6_INC_STATS(idev, field) ({ \ | 131 | DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); |
137 | struct inet6_dev *_idev = (idev); \ | 132 | |
138 | if (likely(_idev != NULL)) \ | 133 | #define ICMP6_INC_STATS(idev, field) _DEVINC(icmpv6, , idev, field) |
139 | SNMP_INC_STATS(idev->stats.icmpv6, field); \ | 134 | #define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field) |
140 | SNMP_INC_STATS(icmpv6_statistics, field); \ | 135 | #define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field) |
141 | }) | 136 | |
142 | #define ICMP6_INC_STATS_BH(idev, field) ({ \ | ||
143 | struct inet6_dev *_idev = (idev); \ | ||
144 | if (likely(_idev != NULL)) \ | ||
145 | SNMP_INC_STATS_BH((_idev)->stats.icmpv6, field); \ | ||
146 | SNMP_INC_STATS_BH(icmpv6_statistics, field); \ | ||
147 | }) | ||
148 | #define ICMP6_INC_STATS_USER(idev, field) ({ \ | ||
149 | struct inet6_dev *_idev = (idev); \ | ||
150 | if (likely(_idev != NULL)) \ | ||
151 | SNMP_INC_STATS_USER(_idev->stats.icmpv6, field); \ | ||
152 | SNMP_INC_STATS_USER(icmpv6_statistics, field); \ | ||
153 | }) | ||
154 | #define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \ | 137 | #define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \ |
155 | struct inet6_dev *_idev = idev; \ | 138 | struct inet6_dev *_idev = idev; \ |
156 | __typeof__(offset) _offset = (offset); \ | 139 | __typeof__(offset) _offset = (offset); \ |
@@ -158,6 +141,20 @@ DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | |||
158 | SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \ | 141 | SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \ |
159 | SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \ | 142 | SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \ |
160 | }) | 143 | }) |
144 | |||
145 | #define ICMP6MSGOUT_INC_STATS(idev, field) \ | ||
146 | _DEVINC(icmpv6msg, , idev, field +256) | ||
147 | #define ICMP6MSGOUT_INC_STATS_BH(idev, field) \ | ||
148 | _DEVINC(icmpv6msg, _BH, idev, field +256) | ||
149 | #define ICMP6MSGOUT_INC_STATS_USER(idev, field) \ | ||
150 | _DEVINC(icmpv6msg, _USER, idev, field +256) | ||
151 | #define ICMP6MSGIN_INC_STATS(idev, field) \ | ||
152 | _DEVINC(icmpv6msg, , idev, field) | ||
153 | #define ICMP6MSGIN_INC_STATS_BH(idev, field) \ | ||
154 | _DEVINC(icmpv6msg, _BH, idev, field) | ||
155 | #define ICMP6MSGIN_INC_STATS_USER(idev, field) \ | ||
156 | _DEVINC(icmpv6msg, _USER, idev, field) | ||
157 | |||
161 | DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); | 158 | DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); |
162 | DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | 159 | DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6); |
163 | #define UDP6_INC_STATS_BH(field, is_udplite) do { \ | 160 | #define UDP6_INC_STATS_BH(field, is_udplite) do { \ |
diff --git a/include/net/snmp.h b/include/net/snmp.h index 464970e39ec0..a566e11d2f98 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -88,6 +88,12 @@ struct icmpv6_mib { | |||
88 | unsigned long mibs[ICMP6_MIB_MAX]; | 88 | unsigned long mibs[ICMP6_MIB_MAX]; |
89 | } __SNMP_MIB_ALIGN__; | 89 | } __SNMP_MIB_ALIGN__; |
90 | 90 | ||
91 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX | ||
92 | struct icmpv6msg_mib { | ||
93 | unsigned long mibs[ICMP6MSG_MIB_MAX]; | ||
94 | } __SNMP_MIB_ALIGN__; | ||
95 | |||
96 | |||
91 | /* TCP */ | 97 | /* TCP */ |
92 | #define TCP_MIB_MAX __TCP_MIB_MAX | 98 | #define TCP_MIB_MAX __TCP_MIB_MAX |
93 | struct tcp_mib { | 99 | struct tcp_mib { |