diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2005-04-26 18:10:21 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2005-04-26 18:10:21 +0000 |
commit | 31519b13c83c95d88446ba3866a981f86a1c75ee (patch) | |
tree | 4e5871997c5feabf14fcd71b68406dc649fa6fb0 | |
parent | b190ee6140c30ef0ea263d839e4b5be264bd0a1b (diff) | |
download | src-31519b13c83c95d88446ba3866a981f86a1c75ee.tar.gz src-31519b13c83c95d88446ba3866a981f86a1c75ee.zip |
Introduce a struct icmphdr which contains the type, code, and cksum
fields of an ICMP packet.
Use this to allow ipfw to pullup only these values since it does not use
the rest of the packet and it was failed on ICMP packets because they
were not long enough.
struct icmp should probably be modified to use these at some point, but
that will break a fair bit of code so it can wait for another day.
On the off chance that adding this struct breaks something in ports,
bump __FreeBSD_version.
Reported by: Randy Bush <randy at psg dot com>
Tested by: Randy Bush <randy at psg dot com>
Notes
Notes:
svn path=/head/; revision=145565
-rw-r--r-- | sys/netinet/ip_fw2.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_icmp.h | 11 | ||||
-rw-r--r-- | sys/sys/param.h | 2 |
3 files changed, 17 insertions, 10 deletions
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c index 5d50ce51bdf1..c0799706ccd9 100644 --- a/sys/netinet/ip_fw2.c +++ b/sys/netinet/ip_fw2.c @@ -328,11 +328,11 @@ SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, dyn_keepalive, CTLFLAG_RW, #define L3HDR(T, ip) ((T *)((u_int32_t *)(ip) + (ip)->ip_hl)) #define TCP(p) ((struct tcphdr *)(p)) #define UDP(p) ((struct udphdr *)(p)) -#define ICMP(p) ((struct icmp *)(p)) +#define ICMP(p) ((struct icmphdr *)(p)) #define ICMP6(p) ((struct icmp6_hdr *)(p)) static __inline int -icmptype_match(struct icmp *icmp, ipfw_insn_u32 *cmd) +icmptype_match(struct icmphdr *icmp, ipfw_insn_u32 *cmd) { int type = icmp->icmp_type; @@ -343,7 +343,7 @@ icmptype_match(struct icmp *icmp, ipfw_insn_u32 *cmd) (1 << ICMP_TSTAMP) | (1 << ICMP_IREQ) | (1 << ICMP_MASKREQ) ) static int -is_icmp_query(struct icmp *icmp) +is_icmp_query(struct icmphdr *icmp) { int type = icmp->icmp_type; @@ -760,7 +760,7 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ether_header *eh, } else { struct ip *ip = mtod(m, struct ip *); /* these three are all aliases to the same thing */ - struct icmp *const icmp = L3HDR(struct icmp, ip); + struct icmphdr *const icmp = L3HDR(struct icmphdr, ip); struct tcphdr *const tcp = (struct tcphdr *)icmp; struct udphdr *const udp = (struct udphdr *)icmp; @@ -2108,11 +2108,7 @@ do { \ break; case IPPROTO_ICMP: - /* - * we only care for 4 bytes: type, code, - * checksum - */ - PULLUP_TO(hlen, ulp, struct icmp); + PULLUP_TO(hlen, ulp, struct icmphdr); args->f_id.flags = ICMP(ulp)->icmp_type; break; diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h index 6acff63bbfa0..020dd9641915 100644 --- a/sys/netinet/ip_icmp.h +++ b/sys/netinet/ip_icmp.h @@ -49,6 +49,17 @@ struct icmp_ra_addr { /* * Structure of an icmp header. */ +struct icmphdr { + u_char icmp_type; /* type of message, see below */ + u_char icmp_code; /* type sub code */ + u_short icmp_cksum; /* ones complement cksum of struct */ +}; + +/* + * Structure of an icmp packet. + * + * XXX: should start with a struct icmphdr. + */ struct icmp { u_char icmp_type; /* type of message, see below */ u_char icmp_code; /* type sub code */ diff --git a/sys/sys/param.h b/sys/sys/param.h index d36a20bbe77a..be811801ca5c 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 600024 /* Master, propagated to newvers */ +#define __FreeBSD_version 600025 /* Master, propagated to newvers */ #ifndef LOCORE #include <sys/types.h> |