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)
This commit is contained in:
Andrew Thompson 2005-07-03 18:24:03 +00:00
parent 86a655492a
commit ede3a2773d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=147760

View File

@ -1025,6 +1025,19 @@ bdg_forward(struct mbuf *m0, struct ifnet *dst)
bcopy(eh, &save_eh, ETHER_HDR_LEN); /* local copy for restore */
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.