@@ -115,6 +115,7 @@ struct icmp_bxm {
115
115
* Statistics
116
116
*/
117
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
120
/* An array of errno for error messages from dest unreach. */
120
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
217
struct icmp_control {
217
- int output_entry ; /* Field for increment on output */
218
- int input_entry ; /* Field for increment on input */
219
218
void (* handler )(struct sk_buff * skb );
220
219
short error ; /* This ICMP is classed as an error message */
221
220
};
@@ -316,12 +315,10 @@ static inline int icmpv4_xrlim_allow(struct rtable *rt, int type, int code)
316
315
/*
317
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 ) {
322
- ICMP_INC_STATS (icmp_pointers [type ].output_entry );
323
- ICMP_INC_STATS (ICMP_MIB_OUTMSGS );
324
- }
320
+ ICMPMSGOUT_INC_STATS (type );
321
+ ICMP_INC_STATS (ICMP_MIB_OUTMSGS );
325
322
}
326
323
327
324
/*
@@ -390,7 +387,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
390
387
return ;
391
388
392
389
icmp_param -> data .icmph .checksum = 0 ;
393
- icmp_out_count (icmp_param -> data .icmph .type );
394
390
395
391
inet -> tos = ip_hdr (skb )-> tos ;
396
392
daddr = ipc .addr = rt -> rt_src ;
@@ -952,6 +948,7 @@ int icmp_rcv(struct sk_buff *skb)
952
948
953
949
icmph = icmp_hdr (skb );
954
950
951
+ ICMPMSGIN_INC_STATS_BH (icmph -> type );
955
952
/*
956
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
986
icmp_pointers [icmph -> type ].handler (skb );
991
987
992
988
drop :
@@ -1002,109 +998,71 @@ int icmp_rcv(struct sk_buff *skb)
1002
998
*/
1003
999
static const struct icmp_control icmp_pointers [NR_ICMP_TYPES + 1 ] = {
1004
1000
[ICMP_ECHOREPLY ] = {
1005
- .output_entry = ICMP_MIB_OUTECHOREPS ,
1006
- .input_entry = ICMP_MIB_INECHOREPS ,
1007
1001
.handler = icmp_discard ,
1008
1002
},
1009
1003
[1 ] = {
1010
- .output_entry = ICMP_MIB_DUMMY ,
1011
- .input_entry = ICMP_MIB_INERRORS ,
1012
1004
.handler = icmp_discard ,
1013
1005
.error = 1 ,
1014
1006
},
1015
1007
[2 ] = {
1016
- .output_entry = ICMP_MIB_DUMMY ,
1017
- .input_entry = ICMP_MIB_INERRORS ,
1018
1008
.handler = icmp_discard ,
1019
1009
.error = 1 ,
1020
1010
},
1021
1011
[ICMP_DEST_UNREACH ] = {
1022
- .output_entry = ICMP_MIB_OUTDESTUNREACHS ,
1023
- .input_entry = ICMP_MIB_INDESTUNREACHS ,
1024
1012
.handler = icmp_unreach ,
1025
1013
.error = 1 ,
1026
1014
},
1027
1015
[ICMP_SOURCE_QUENCH ] = {
1028
- .output_entry = ICMP_MIB_OUTSRCQUENCHS ,
1029
- .input_entry = ICMP_MIB_INSRCQUENCHS ,
1030
1016
.handler = icmp_unreach ,
1031
1017
.error = 1 ,
1032
1018
},
1033
1019
[ICMP_REDIRECT ] = {
1034
- .output_entry = ICMP_MIB_OUTREDIRECTS ,
1035
- .input_entry = ICMP_MIB_INREDIRECTS ,
1036
1020
.handler = icmp_redirect ,
1037
1021
.error = 1 ,
1038
1022
},
1039
1023
[6 ] = {
1040
- .output_entry = ICMP_MIB_DUMMY ,
1041
- .input_entry = ICMP_MIB_INERRORS ,
1042
1024
.handler = icmp_discard ,
1043
1025
.error = 1 ,
1044
1026
},
1045
1027
[7 ] = {
1046
- .output_entry = ICMP_MIB_DUMMY ,
1047
- .input_entry = ICMP_MIB_INERRORS ,
1048
1028
.handler = icmp_discard ,
1049
1029
.error = 1 ,
1050
1030
},
1051
1031
[ICMP_ECHO ] = {
1052
- .output_entry = ICMP_MIB_OUTECHOS ,
1053
- .input_entry = ICMP_MIB_INECHOS ,
1054
1032
.handler = icmp_echo ,
1055
1033
},
1056
1034
[9 ] = {
1057
- .output_entry = ICMP_MIB_DUMMY ,
1058
- .input_entry = ICMP_MIB_INERRORS ,
1059
1035
.handler = icmp_discard ,
1060
1036
.error = 1 ,
1061
1037
},
1062
1038
[10 ] = {
1063
- .output_entry = ICMP_MIB_DUMMY ,
1064
- .input_entry = ICMP_MIB_INERRORS ,
1065
1039
.handler = icmp_discard ,
1066
1040
.error = 1 ,
1067
1041
},
1068
1042
[ICMP_TIME_EXCEEDED ] = {
1069
- .output_entry = ICMP_MIB_OUTTIMEEXCDS ,
1070
- .input_entry = ICMP_MIB_INTIMEEXCDS ,
1071
1043
.handler = icmp_unreach ,
1072
1044
.error = 1 ,
1073
1045
},
1074
1046
[ICMP_PARAMETERPROB ] = {
1075
- .output_entry = ICMP_MIB_OUTPARMPROBS ,
1076
- .input_entry = ICMP_MIB_INPARMPROBS ,
1077
1047
.handler = icmp_unreach ,
1078
1048
.error = 1 ,
1079
1049
},
1080
1050
[ICMP_TIMESTAMP ] = {
1081
- .output_entry = ICMP_MIB_OUTTIMESTAMPS ,
1082
- .input_entry = ICMP_MIB_INTIMESTAMPS ,
1083
1051
.handler = icmp_timestamp ,
1084
1052
},
1085
1053
[ICMP_TIMESTAMPREPLY ] = {
1086
- .output_entry = ICMP_MIB_OUTTIMESTAMPREPS ,
1087
- .input_entry = ICMP_MIB_INTIMESTAMPREPS ,
1088
1054
.handler = icmp_discard ,
1089
1055
},
1090
1056
[ICMP_INFO_REQUEST ] = {
1091
- .output_entry = ICMP_MIB_DUMMY ,
1092
- .input_entry = ICMP_MIB_DUMMY ,
1093
1057
.handler = icmp_discard ,
1094
1058
},
1095
1059
[ICMP_INFO_REPLY ] = {
1096
- .output_entry = ICMP_MIB_DUMMY ,
1097
- .input_entry = ICMP_MIB_DUMMY ,
1098
1060
.handler = icmp_discard ,
1099
1061
},
1100
1062
[ICMP_ADDRESS ] = {
1101
- .output_entry = ICMP_MIB_OUTADDRMASKS ,
1102
- .input_entry = ICMP_MIB_INADDRMASKS ,
1103
1063
.handler = icmp_address ,
1104
1064
},
1105
1065
[ICMP_ADDRESSREPLY ] = {
1106
- .output_entry = ICMP_MIB_OUTADDRMASKREPS ,
1107
- .input_entry = ICMP_MIB_INADDRMASKREPS ,
1108
1066
.handler = icmp_address_reply ,
1109
1067
},
1110
1068
};
@@ -1146,4 +1104,5 @@ void __init icmp_init(struct net_proto_family *ops)
1146
1104
EXPORT_SYMBOL (icmp_err_convert );
1147
1105
EXPORT_SYMBOL (icmp_send );
1148
1106
EXPORT_SYMBOL (icmp_statistics );
1107
+ EXPORT_SYMBOL (icmpmsg_statistics );
1149
1108
EXPORT_SYMBOL (xrlim_allow );
0 commit comments