In m_megapullup() instead of reserving some space at the end of packet,
m_align() it, reserving space to prepend data. Reviewed by: mav
This commit is contained in:
parent
afdfb863d6
commit
09c3ea7c84
@ -1749,26 +1749,22 @@ LibAliasUnLoadAllModule(void)
|
|||||||
struct mbuf *
|
struct mbuf *
|
||||||
m_megapullup(struct mbuf *m, int len) {
|
m_megapullup(struct mbuf *m, int len) {
|
||||||
struct mbuf *mcl;
|
struct mbuf *mcl;
|
||||||
|
|
||||||
if (len > m->m_pkthdr.len)
|
if (len > m->m_pkthdr.len)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
/* Do not reallocate packet if it is sequentional,
|
if (m->m_next == NULL && M_WRITABLE(m))
|
||||||
* writable and has some extra space for expansion.
|
|
||||||
* XXX: Constant 100bytes is completely empirical. */
|
|
||||||
#define RESERVE 100
|
|
||||||
if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE)
|
|
||||||
return (m);
|
return (m);
|
||||||
|
|
||||||
mcl = m_get2(len + RESERVE, M_NOWAIT, MT_DATA, M_PKTHDR);
|
mcl = m_get2(len, M_NOWAIT, MT_DATA, M_PKTHDR);
|
||||||
if (mcl == NULL)
|
if (mcl == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
m_align(mcl, len);
|
||||||
m_move_pkthdr(mcl, m);
|
m_move_pkthdr(mcl, m);
|
||||||
m_copydata(m, 0, len, mtod(mcl, caddr_t));
|
m_copydata(m, 0, len, mtod(mcl, caddr_t));
|
||||||
mcl->m_len = mcl->m_pkthdr.len = len;
|
mcl->m_len = mcl->m_pkthdr.len = len;
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
|
|
||||||
return (mcl);
|
return (mcl);
|
||||||
bad:
|
bad:
|
||||||
m_freem(m);
|
m_freem(m);
|
||||||
|
Loading…
Reference in New Issue
Block a user