diff options
author | Andrew Thompson <thompsa@FreeBSD.org> | 2005-07-03 18:24:03 +0000 |
---|---|---|
committer | Andrew Thompson <thompsa@FreeBSD.org> | 2005-07-03 18:24:03 +0000 |
commit | ede3a2773d93013d337178aff3e4e21c2d6c50a0 (patch) | |
tree | d3e985a533448413ac2eb52d13da1fe198b1d5fb /sys/net/bridge.c | |
parent | 86a655492a6fec7c2beb627e09cad07b114fb06b (diff) | |
download | src-ede3a2773d93013d337178aff3e4e21c2d6c50a0.tar.gz src-ede3a2773d93013d337178aff3e4e21c2d6c50a0.zip |
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, ia64 and ppc.
This uses the code block from if_bridge and the newly added macro
IP_HDR_ALIGNED_P().
This /might/ be a temporary messure before all NIC drivers are educated
to align the header themself.
PR: ia64/81284
Obtained from: NetBSD (if_bridge)
Approved by: re (dwhite), mlaier (mentor)
Notes
Notes:
svn path=/head/; revision=147760
Diffstat (limited to 'sys/net/bridge.c')
-rw-r--r-- | sys/net/bridge.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/net/bridge.c b/sys/net/bridge.c index 82a24fa87674..211f0e5bceb0 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -1026,6 +1026,19 @@ bdg_forward(struct mbuf *m0, struct ifnet *dst) m_adj(m0, ETHER_HDR_LEN); /* temporarily strip header */ /* + * Check that the IP header is aligned before passing up to the packet + * filter. + */ + if (ntohs(save_eh.ether_type) == ETHERTYPE_IP && + IP_HDR_ALIGNED_P(mtod(m0, caddr_t)) == 0) { + if ((m0 = m_copyup(m0, sizeof(struct ip), + (max_linkhdr + 3) & ~3)) == NULL) { + bdg_dropped++; + return NULL; + } + } + + /* * NetBSD-style generic packet filter, pfil(9), hooks. * Enables ipf(8) in bridging. */ |