Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66615
b: refs/heads/master
c: 96793b4
h: refs/heads/master
i:
  66613: fc3fd7a
  66611: 1065a00
  66607: a5635dd
v: v3
  • Loading branch information
David L Stevens authored and David S. Miller committed Oct 10, 2007
1 parent 802eb99 commit 6a33287
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 79 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 14878f75abd5bf1d38becb405801cd491ee215dc
refs/heads/master: 96793b482540f3a26e2188eaf75cb56b7829d3e3
2 changes: 2 additions & 0 deletions trunk/include/linux/snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ enum
__ICMP_MIB_MAX
};

#define __ICMPMSG_MIB_MAX 512 /* Out+In for all 8-bit ICMP types */

/* icmp6 mib definitions */
/*
* RFC 2466: ICMPv6-MIB
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/net/icmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ struct icmp_err {

extern struct icmp_err icmp_err_convert[];
DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics);
DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
#define ICMP_INC_STATS(field) SNMP_INC_STATS(icmp_statistics, field)
#define ICMP_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmp_statistics, field)
#define ICMP_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmp_statistics, field)
#define ICMPMSGOUT_INC_STATS(field) SNMP_INC_STATS(icmpmsg_statistics, field+256)
#define ICMPMSGOUT_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmpmsg_statistics, field+256)
#define ICMPMSGOUT_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmpmsg_statistics, field+256)
#define ICMPMSGIN_INC_STATS(field) SNMP_INC_STATS(icmpmsg_statistics, field)
#define ICMPMSGIN_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
#define ICMPMSGIN_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmpmsg_statistics, field)

struct dst_entry;
struct net_proto_family;
Expand All @@ -42,6 +49,7 @@ extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
extern int icmp_rcv(struct sk_buff *skb);
extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
extern void icmp_init(struct net_proto_family *ops);
extern void icmp_out_count(unsigned char type);

/* Move into dst.h ? */
extern int xrlim_allow(struct dst_entry *dst, int timeout);
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/net/snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ struct icmp_mib {
unsigned long mibs[ICMP_MIB_MAX];
} __SNMP_MIB_ALIGN__;

#define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX
struct icmpmsg_mib {
unsigned long mibs[ICMPMSG_MIB_MAX];
} __SNMP_MIB_ALIGN__;

/* ICMP6 (IPv6-ICMP) */
#define ICMP6_MIB_MAX __ICMP6_MIB_MAX
struct icmpv6_mib {
Expand Down
6 changes: 6 additions & 0 deletions trunk/net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,10 @@ static int __init init_ipv4_mibs(void)
sizeof(struct icmp_mib),
__alignof__(struct icmp_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)icmpmsg_statistics,
sizeof(struct icmpmsg_mib),
__alignof__(struct icmpmsg_mib)) < 0)
goto err_icmpmsg_mib;
if (snmp_mib_init((void **)tcp_statistics,
sizeof(struct tcp_mib),
__alignof__(struct tcp_mib)) < 0)
Expand All @@ -1324,6 +1328,8 @@ static int __init init_ipv4_mibs(void)
err_udp_mib:
snmp_mib_free((void **)tcp_statistics);
err_tcp_mib:
snmp_mib_free((void **)icmpmsg_statistics);
err_icmpmsg_mib:
snmp_mib_free((void **)icmp_statistics);
err_icmp_mib:
snmp_mib_free((void **)ip_statistics);
Expand Down
53 changes: 6 additions & 47 deletions trunk/net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct icmp_bxm {
* Statistics
*/
DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly;
DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;

/* An array of errno for error messages from dest unreach. */
/* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
Expand Down Expand Up @@ -214,8 +215,6 @@ int sysctl_icmp_errors_use_inbound_ifaddr __read_mostly;
*/

struct icmp_control {
int output_entry; /* Field for increment on output */
int input_entry; /* Field for increment on input */
void (*handler)(struct sk_buff *skb);
short error; /* This ICMP is classed as an error message */
};
Expand Down Expand Up @@ -316,12 +315,10 @@ static inline int icmpv4_xrlim_allow(struct rtable *rt, int type, int code)
/*
* Maintain the counters used in the SNMP statistics for outgoing ICMP
*/
static void icmp_out_count(int type)
void icmp_out_count(unsigned char type)
{
if (type <= NR_ICMP_TYPES) {
ICMP_INC_STATS(icmp_pointers[type].output_entry);
ICMP_INC_STATS(ICMP_MIB_OUTMSGS);
}
ICMPMSGOUT_INC_STATS(type);
ICMP_INC_STATS(ICMP_MIB_OUTMSGS);
}

/*
Expand Down Expand Up @@ -390,7 +387,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
return;

icmp_param->data.icmph.checksum = 0;
icmp_out_count(icmp_param->data.icmph.type);

inet->tos = ip_hdr(skb)->tos;
daddr = ipc.addr = rt->rt_src;
Expand Down Expand Up @@ -952,6 +948,7 @@ int icmp_rcv(struct sk_buff *skb)

icmph = icmp_hdr(skb);

ICMPMSGIN_INC_STATS_BH(icmph->type);
/*
* 18 is the highest 'known' ICMP type. Anything else is a mystery
*
Expand Down Expand Up @@ -986,7 +983,6 @@ int icmp_rcv(struct sk_buff *skb)
}
}

ICMP_INC_STATS_BH(icmp_pointers[icmph->type].input_entry);
icmp_pointers[icmph->type].handler(skb);

drop:
Expand All @@ -1002,109 +998,71 @@ int icmp_rcv(struct sk_buff *skb)
*/
static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
[ICMP_ECHOREPLY] = {
.output_entry = ICMP_MIB_OUTECHOREPS,
.input_entry = ICMP_MIB_INECHOREPS,
.handler = icmp_discard,
},
[1] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[2] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[ICMP_DEST_UNREACH] = {
.output_entry = ICMP_MIB_OUTDESTUNREACHS,
.input_entry = ICMP_MIB_INDESTUNREACHS,
.handler = icmp_unreach,
.error = 1,
},
[ICMP_SOURCE_QUENCH] = {
.output_entry = ICMP_MIB_OUTSRCQUENCHS,
.input_entry = ICMP_MIB_INSRCQUENCHS,
.handler = icmp_unreach,
.error = 1,
},
[ICMP_REDIRECT] = {
.output_entry = ICMP_MIB_OUTREDIRECTS,
.input_entry = ICMP_MIB_INREDIRECTS,
.handler = icmp_redirect,
.error = 1,
},
[6] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[7] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[ICMP_ECHO] = {
.output_entry = ICMP_MIB_OUTECHOS,
.input_entry = ICMP_MIB_INECHOS,
.handler = icmp_echo,
},
[9] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[10] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_INERRORS,
.handler = icmp_discard,
.error = 1,
},
[ICMP_TIME_EXCEEDED] = {
.output_entry = ICMP_MIB_OUTTIMEEXCDS,
.input_entry = ICMP_MIB_INTIMEEXCDS,
.handler = icmp_unreach,
.error = 1,
},
[ICMP_PARAMETERPROB] = {
.output_entry = ICMP_MIB_OUTPARMPROBS,
.input_entry = ICMP_MIB_INPARMPROBS,
.handler = icmp_unreach,
.error = 1,
},
[ICMP_TIMESTAMP] = {
.output_entry = ICMP_MIB_OUTTIMESTAMPS,
.input_entry = ICMP_MIB_INTIMESTAMPS,
.handler = icmp_timestamp,
},
[ICMP_TIMESTAMPREPLY] = {
.output_entry = ICMP_MIB_OUTTIMESTAMPREPS,
.input_entry = ICMP_MIB_INTIMESTAMPREPS,
.handler = icmp_discard,
},
[ICMP_INFO_REQUEST] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_DUMMY,
.handler = icmp_discard,
},
[ICMP_INFO_REPLY] = {
.output_entry = ICMP_MIB_DUMMY,
.input_entry = ICMP_MIB_DUMMY,
.handler = icmp_discard,
},
[ICMP_ADDRESS] = {
.output_entry = ICMP_MIB_OUTADDRMASKS,
.input_entry = ICMP_MIB_INADDRMASKS,
.handler = icmp_address,
},
[ICMP_ADDRESSREPLY] = {
.output_entry = ICMP_MIB_OUTADDRMASKREPS,
.input_entry = ICMP_MIB_INADDRMASKREPS,
.handler = icmp_address_reply,
},
};
Expand Down Expand Up @@ -1146,4 +1104,5 @@ void __init icmp_init(struct net_proto_family *ops)
EXPORT_SYMBOL(icmp_err_convert);
EXPORT_SYMBOL(icmp_send);
EXPORT_SYMBOL(icmp_statistics);
EXPORT_SYMBOL(icmpmsg_statistics);
EXPORT_SYMBOL(xrlim_allow);
4 changes: 4 additions & 0 deletions trunk/net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,10 @@ int ip_push_pending_frames(struct sock *sk)
skb->priority = sk->sk_priority;
skb->dst = dst_clone(&rt->u.dst);

if (iph->protocol == IPPROTO_ICMP)
icmp_out_count(((struct icmphdr *)
skb_transport_header(skb))->type);

/* Netfilter gets whole the not fragmented skb. */
err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL,
skb->dst->dev, dst_output);
Expand Down
Loading

0 comments on commit 6a33287

Please sign in to comment.