The prepend function did not handle non-pkthdr's correctly.

It always called MH_ALIGN for small lengths being
prepended (less than MHLEN). This meant that if you did
a prepend on a non M_PKTHDR the system would panic with
the KASSERT in MH_ALIGN. Instead we are not aware of
this and do a MH_ALIGN or M_ALIGN as appropriate.

Reviewed by:	andre
Approved by:	gnn
This commit is contained in:
Randall Stewart 2006-12-21 19:58:04 +00:00
parent af0673c204
commit 5288989fac

View File

@ -496,8 +496,13 @@ m_prepend(struct mbuf *m, int len, int how)
M_MOVE_PKTHDR(mn, m);
mn->m_next = m;
m = mn;
if (len < MHLEN)
MH_ALIGN(m, len);
if(m->m_flags & M_PKTHDR) {
if (len < MHLEN)
MH_ALIGN(m, len);
} else {
if (len < MLEN)
M_ALIGN(m, len);
}
m->m_len = len;
return (m);
}