summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_var.h
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2005-07-02 23:13:31 +0000
committerthompsa <thompsa@FreeBSD.org>2005-07-02 23:13:31 +0000
commitd7e928629d1fd82199b336e5a513e6308c7ec45b (patch)
tree89cd1b3b1b8fc11081f836fcc5b77a4e00d644f2 /sys/netinet/ip_var.h
parentdd5c43b57252ea9dec17cd9c876da75544db45c4 (diff)
downloadFreeBSD-src-d7e928629d1fd82199b336e5a513e6308c7ec45b.zip
FreeBSD-src-d7e928629d1fd82199b336e5a513e6308c7ec45b.tar.gz
Check the alignment of the IP header before passing the packet up to the
packet filter. This would cause a panic on architectures that require strict alignment such as sparc64 (tier1) and ia64/ppc (tier2). This adds two new macros that check the alignment, these are compile time dependent on __NO_STRICT_ALIGNMENT which is set for i386 and amd64 where alignment isn't need so the cost is avoided. IP_HDR_ALIGNED_P() IP6_HDR_ALIGNED_P() Move bridge_ip_checkbasic()/bridge_ip6_checkbasic() up so that the alignment is checked for ipfw and dummynet too. PR: ia64/81284 Obtained from: NetBSD Approved by: re (dwhite), mlaier (mentor)
Diffstat (limited to 'sys/netinet/ip_var.h')
-rw-r--r--sys/netinet/ip_var.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index c7541bc..e64570b 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -136,6 +136,12 @@ struct ipstat {
/* mbuf flag used by ip_fastfwd */
#define M_FASTFWD_OURS M_PROTO1 /* changed dst to local */
+#ifdef __NO_STRICT_ALIGNMENT
+#define IP_HDR_ALIGNED_P(ip) 1
+#else
+#define IP_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0)
+#endif
+
struct ip;
struct inpcb;
struct route;
OpenPOWER on IntegriCloud