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:
parent
9363cb885b
commit
e8a925d9d4
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user