diff options
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 53 |
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 | */ |
117 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly; | 117 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly; |
118 | DEFINE_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 | ||
216 | struct icmp_control { | 217 | struct 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 | */ |
319 | static void icmp_out_count(int type) | 318 | void 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 | ||
992 | drop: | 988 | drop: |
@@ -1002,109 +998,71 @@ error: | |||
1002 | */ | 998 | */ |
1003 | static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = { | 999 | static 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) | |||
1146 | EXPORT_SYMBOL(icmp_err_convert); | 1104 | EXPORT_SYMBOL(icmp_err_convert); |
1147 | EXPORT_SYMBOL(icmp_send); | 1105 | EXPORT_SYMBOL(icmp_send); |
1148 | EXPORT_SYMBOL(icmp_statistics); | 1106 | EXPORT_SYMBOL(icmp_statistics); |
1107 | EXPORT_SYMBOL(icmpmsg_statistics); | ||
1149 | EXPORT_SYMBOL(xrlim_allow); | 1108 | EXPORT_SYMBOL(xrlim_allow); |