aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/icmp.c
diff options
context:
space:
mode:
authorDavid L Stevens <dlstevens@us.ibm.com>2007-09-17 12:57:33 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:28 -0400
commit96793b482540f3a26e2188eaf75cb56b7829d3e3 (patch)
tree3dfc2871b69cc358ed55dc2adc3bfeef47382cb3 /net/ipv4/icmp.c
parent14878f75abd5bf1d38becb405801cd491ee215dc (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/icmp.c')
-rw-r--r--net/ipv4/icmp.c53
1 files changed, 6 insertions, 47 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 68a22670f597..272c69e106e9 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -115,6 +115,7 @@ struct icmp_bxm {
115 * Statistics 115 * Statistics
116 */ 116 */
117DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly; 117DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly;
118DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;
118 119
119/* An array of errno for error messages from dest unreach. */ 120/* An array of errno for error messages from dest unreach. */
120/* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */ 121/* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
@@ -214,8 +215,6 @@ int sysctl_icmp_errors_use_inbound_ifaddr __read_mostly;
214 */ 215 */
215 216
216struct icmp_control { 217struct icmp_control {
217 int output_entry; /* Field for increment on output */
218 int input_entry; /* Field for increment on input */
219 void (*handler)(struct sk_buff *skb); 218 void (*handler)(struct sk_buff *skb);
220 short error; /* This ICMP is classed as an error message */ 219 short error; /* This ICMP is classed as an error message */
221}; 220};
@@ -316,12 +315,10 @@ out:
316/* 315/*
317 * Maintain the counters used in the SNMP statistics for outgoing ICMP 316 * Maintain the counters used in the SNMP statistics for outgoing ICMP
318 */ 317 */
319static void icmp_out_count(int type) 318void icmp_out_count(unsigned char type)
320{ 319{
321 if (type <= NR_ICMP_TYPES) { 320 ICMPMSGOUT_INC_STATS(type);
322 ICMP_INC_STATS(icmp_pointers[type].output_entry); 321 ICMP_INC_STATS(ICMP_MIB_OUTMSGS);
323 ICMP_INC_STATS(ICMP_MIB_OUTMSGS);
324 }
325} 322}
326 323
327/* 324/*
@@ -390,7 +387,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
390 return; 387 return;
391 388
392 icmp_param->data.icmph.checksum = 0; 389 icmp_param->data.icmph.checksum = 0;
393 icmp_out_count(icmp_param->data.icmph.type);
394 390
395 inet->tos = ip_hdr(skb)->tos; 391 inet->tos = ip_hdr(skb)->tos;
396 daddr = ipc.addr = rt->rt_src; 392 daddr = ipc.addr = rt->rt_src;
@@ -952,6 +948,7 @@ int icmp_rcv(struct sk_buff *skb)
952 948
953 icmph = icmp_hdr(skb); 949 icmph = icmp_hdr(skb);
954 950
951 ICMPMSGIN_INC_STATS_BH(icmph->type);
955 /* 952 /*
956 * 18 is the highest 'known' ICMP type. Anything else is a mystery 953 * 18 is the highest 'known' ICMP type. Anything else is a mystery
957 * 954 *
@@ -986,7 +983,6 @@ int icmp_rcv(struct sk_buff *skb)
986 } 983 }
987 } 984 }
988 985
989 ICMP_INC_STATS_BH(icmp_pointers[icmph->type].input_entry);
990 icmp_pointers[icmph->type].handler(skb); 986 icmp_pointers[icmph->type].handler(skb);
991 987
992drop: 988drop:
@@ -1002,109 +998,71 @@ error:
1002 */ 998 */
1003static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { 999static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
1004 [ICMP_ECHOREPLY] = { 1000 [ICMP_ECHOREPLY] = {
1005 .output_entry = ICMP_MIB_OUTECHOREPS,
1006 .input_entry = ICMP_MIB_INECHOREPS,
1007 .handler = icmp_discard, 1001 .handler = icmp_discard,
1008 }, 1002 },
1009 [1] = { 1003 [1] = {
1010 .output_entry = ICMP_MIB_DUMMY,
1011 .input_entry = ICMP_MIB_INERRORS,
1012 .handler = icmp_discard, 1004 .handler = icmp_discard,
1013 .error = 1, 1005 .error = 1,
1014 }, 1006 },
1015 [2] = { 1007 [2] = {
1016 .output_entry = ICMP_MIB_DUMMY,
1017 .input_entry = ICMP_MIB_INERRORS,
1018 .handler = icmp_discard, 1008 .handler = icmp_discard,
1019 .error = 1, 1009 .error = 1,
1020 }, 1010 },
1021 [ICMP_DEST_UNREACH] = { 1011 [ICMP_DEST_UNREACH] = {
1022 .output_entry = ICMP_MIB_OUTDESTUNREACHS,
1023 .input_entry = ICMP_MIB_INDESTUNREACHS,
1024 .handler = icmp_unreach, 1012 .handler = icmp_unreach,
1025 .error = 1, 1013 .error = 1,
1026 }, 1014 },
1027 [ICMP_SOURCE_QUENCH] = { 1015 [ICMP_SOURCE_QUENCH] = {
1028 .output_entry = ICMP_MIB_OUTSRCQUENCHS,
1029 .input_entry = ICMP_MIB_INSRCQUENCHS,
1030 .handler = icmp_unreach, 1016 .handler = icmp_unreach,
1031 .error = 1, 1017 .error = 1,
1032 }, 1018 },
1033 [ICMP_REDIRECT] = { 1019 [ICMP_REDIRECT] = {
1034 .output_entry = ICMP_MIB_OUTREDIRECTS,
1035 .input_entry = ICMP_MIB_INREDIRECTS,
1036 .handler = icmp_redirect, 1020 .handler = icmp_redirect,
1037 .error = 1, 1021 .error = 1,
1038 }, 1022 },
1039 [6] = { 1023 [6] = {
1040 .output_entry = ICMP_MIB_DUMMY,
1041 .input_entry = ICMP_MIB_INERRORS,
1042 .handler = icmp_discard, 1024 .handler = icmp_discard,
1043 .error = 1, 1025 .error = 1,
1044 }, 1026 },
1045 [7] = { 1027 [7] = {
1046 .output_entry = ICMP_MIB_DUMMY,
1047 .input_entry = ICMP_MIB_INERRORS,
1048 .handler = icmp_discard, 1028 .handler = icmp_discard,
1049 .error = 1, 1029 .error = 1,
1050 }, 1030 },
1051 [ICMP_ECHO] = { 1031 [ICMP_ECHO] = {
1052 .output_entry = ICMP_MIB_OUTECHOS,
1053 .input_entry = ICMP_MIB_INECHOS,
1054 .handler = icmp_echo, 1032 .handler = icmp_echo,
1055 }, 1033 },
1056 [9] = { 1034 [9] = {
1057 .output_entry = ICMP_MIB_DUMMY,
1058 .input_entry = ICMP_MIB_INERRORS,
1059 .handler = icmp_discard, 1035 .handler = icmp_discard,
1060 .error = 1, 1036 .error = 1,
1061 }, 1037 },
1062 [10] = { 1038 [10] = {
1063 .output_entry = ICMP_MIB_DUMMY,
1064 .input_entry = ICMP_MIB_INERRORS,
1065 .handler = icmp_discard, 1039 .handler = icmp_discard,
1066 .error = 1, 1040 .error = 1,
1067 }, 1041 },
1068 [ICMP_TIME_EXCEEDED] = { 1042 [ICMP_TIME_EXCEEDED] = {
1069 .output_entry = ICMP_MIB_OUTTIMEEXCDS,
1070 .input_entry = ICMP_MIB_INTIMEEXCDS,
1071 .handler = icmp_unreach, 1043 .handler = icmp_unreach,
1072 .error = 1, 1044 .error = 1,
1073 }, 1045 },
1074 [ICMP_PARAMETERPROB] = { 1046 [ICMP_PARAMETERPROB] = {
1075 .output_entry = ICMP_MIB_OUTPARMPROBS,
1076 .input_entry = ICMP_MIB_INPARMPROBS,
1077 .handler = icmp_unreach, 1047 .handler = icmp_unreach,
1078 .error = 1, 1048 .error = 1,
1079 }, 1049 },
1080 [ICMP_TIMESTAMP] = { 1050 [ICMP_TIMESTAMP] = {
1081 .output_entry = ICMP_MIB_OUTTIMESTAMPS,
1082 .input_entry = ICMP_MIB_INTIMESTAMPS,
1083 .handler = icmp_timestamp, 1051 .handler = icmp_timestamp,
1084 }, 1052 },
1085 [ICMP_TIMESTAMPREPLY] = { 1053 [ICMP_TIMESTAMPREPLY] = {
1086 .output_entry = ICMP_MIB_OUTTIMESTAMPREPS,
1087 .input_entry = ICMP_MIB_INTIMESTAMPREPS,
1088 .handler = icmp_discard, 1054 .handler = icmp_discard,
1089 }, 1055 },
1090 [ICMP_INFO_REQUEST] = { 1056 [ICMP_INFO_REQUEST] = {
1091 .output_entry = ICMP_MIB_DUMMY,
1092 .input_entry = ICMP_MIB_DUMMY,
1093 .handler = icmp_discard, 1057 .handler = icmp_discard,
1094 }, 1058 },
1095 [ICMP_INFO_REPLY] = { 1059 [ICMP_INFO_REPLY] = {
1096 .output_entry = ICMP_MIB_DUMMY,
1097 .input_entry = ICMP_MIB_DUMMY,
1098 .handler = icmp_discard, 1060 .handler = icmp_discard,
1099 }, 1061 },
1100 [ICMP_ADDRESS] = { 1062 [ICMP_ADDRESS] = {
1101 .output_entry = ICMP_MIB_OUTADDRMASKS,
1102 .input_entry = ICMP_MIB_INADDRMASKS,
1103 .handler = icmp_address, 1063 .handler = icmp_address,
1104 }, 1064 },
1105 [ICMP_ADDRESSREPLY] = { 1065 [ICMP_ADDRESSREPLY] = {
1106 .output_entry = ICMP_MIB_OUTADDRMASKREPS,
1107 .input_entry = ICMP_MIB_INADDRMASKREPS,
1108 .handler = icmp_address_reply, 1066 .handler = icmp_address_reply,
1109 }, 1067 },
1110}; 1068};
@@ -1146,4 +1104,5 @@ void __init icmp_init(struct net_proto_family *ops)
1146EXPORT_SYMBOL(icmp_err_convert); 1104EXPORT_SYMBOL(icmp_err_convert);
1147EXPORT_SYMBOL(icmp_send); 1105EXPORT_SYMBOL(icmp_send);
1148EXPORT_SYMBOL(icmp_statistics); 1106EXPORT_SYMBOL(icmp_statistics);
1107EXPORT_SYMBOL(icmpmsg_statistics);
1149EXPORT_SYMBOL(xrlim_allow); 1108EXPORT_SYMBOL(xrlim_allow);