Rather than checking for hlen causing misalignment, we should do the

m_adj() and then check the resulting mbuf for misalignment, copying
backwards to align the mbuf if required.

This fixes a longstanding problem where an mbuf which would have been
properly aligned after an m_adj() was being misaligned and causing an
unaligned access trap in ip_input().  This bug only triggered when booting
diskless.

Reviewed by:	dfr
This commit is contained in:
Andrew Gallatin 2000-05-26 13:47:02 +00:00
parent d02e84a626
commit fe81f64ffc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60952

View File

@ -242,17 +242,19 @@ if_simloop(ifp, m, af, hlen)
/* Strip away media header */
if (hlen > 0) {
m_adj(m, hlen);
#ifdef __alpha__
/* The alpha doesn't like unaligned data.
* We move data down in the first mbuf */
if (hlen & 3) {
bcopy(m->m_data + hlen, m->m_data, m->m_len - hlen);
m->m_len -= hlen;
if (m->m_flags & M_PKTHDR)
m->m_pkthdr.len -= hlen;
} else
if (mtod(m, vm_offset_t) & 3) {
KASSERT(hlen >= 3, "if_simloop: hlen too small");
bcopy(m->m_data,
(char *)(mtod(m, vm_offset_t)
- (mtod(m, vm_offset_t) & 3)),
m->m_len);
mtod(m,vm_offset_t) -= (mtod(m, vm_offset_t) & 3);
}
#endif
m_adj(m, hlen);
}
/* Deliver to upper layer protocol */