version 1.158, 2014/02/25 18:30:11 |
version 1.158.4.5, 2018/05/22 17:35:38 |
Line 453 mb_ctor(void *arg, void *object, int fla |
|
Line 453 mb_ctor(void *arg, void *object, int fla |
|
return (0); |
return (0); |
} |
} |
|
|
|
void |
|
m_pkthdr_remove(struct mbuf *m) |
|
{ |
|
KASSERT(m->m_flags & M_PKTHDR); |
|
|
|
m_tag_delete_chain(m, NULL); |
|
m->m_flags &= ~M_PKTHDR; |
|
memset(&m->m_pkthdr, 0, sizeof(m->m_pkthdr)); |
|
} |
|
|
/* |
/* |
* Add mbuf to the end of a chain |
* Add mbuf to the end of a chain |
*/ |
*/ |
Line 777 m_copym0(struct mbuf *m, int off0, int l |
|
Line 787 m_copym0(struct mbuf *m, int off0, int l |
|
/* |
/* |
* we are unsure about the way m was allocated. |
* we are unsure about the way m was allocated. |
* copy into multiple MCLBYTES cluster mbufs. |
* copy into multiple MCLBYTES cluster mbufs. |
|
* |
|
* recompute m_len, it is no longer valid if MCLGET() |
|
* fails to allocate a cluster. Then we try to split |
|
* the source into normal sized mbufs. |
*/ |
*/ |
MCLGET(n, wait); |
MCLGET(n, wait); |
|
n->m_len = 0; |
n->m_len = M_TRAILINGSPACE(n); |
n->m_len = M_TRAILINGSPACE(n); |
n->m_len = m_copylen(len, n->m_len); |
n->m_len = m_copylen(len, n->m_len); |
n->m_len = min(n->m_len, m->m_len - off); |
n->m_len = min(n->m_len, m->m_len - off); |
Line 1356 m_makewritable(struct mbuf **mp, int off |
|
Line 1371 m_makewritable(struct mbuf **mp, int off |
|
} |
} |
|
|
/* |
/* |
* Copy the mbuf chain to a new mbuf chain that is as short as possible. |
* Compress the mbuf chain. Return the new mbuf chain on success, NULL on |
* Return the new mbuf chain on success, NULL on failure. On success, |
* failure. The first mbuf is preserved, and on success the pointer returned |
* free the old mbuf chain. |
* is the same as the one passed. |
*/ |
*/ |
struct mbuf * |
struct mbuf * |
m_defrag(struct mbuf *mold, int flags) |
m_defrag(struct mbuf *mold, int flags) |
{ |
{ |
struct mbuf *m0, *mn, *n; |
struct mbuf *m0, *mn, *n; |
size_t sz = mold->m_pkthdr.len; |
int sz; |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if ((mold->m_flags & M_PKTHDR) == 0) |
if ((mold->m_flags & M_PKTHDR) == 0) |
panic("m_defrag: not a mbuf chain header"); |
panic("m_defrag: not a mbuf chain header"); |
#endif |
#endif |
|
|
m0 = m_gethdr(flags, MT_DATA); |
if (mold->m_next == NULL) |
|
return mold; |
|
|
|
m0 = m_get(flags, MT_DATA); |
if (m0 == NULL) |
if (m0 == NULL) |
return NULL; |
return NULL; |
M_COPY_PKTHDR(m0, mold); |
|
mn = m0; |
mn = m0; |
|
|
|
sz = mold->m_pkthdr.len - mold->m_len; |
|
KASSERT(sz >= 0); |
|
|
do { |
do { |
if (sz > MHLEN) { |
if (sz > MLEN) { |
MCLGET(mn, M_DONTWAIT); |
MCLGET(mn, flags); |
if ((mn->m_flags & M_EXT) == 0) { |
if ((mn->m_flags & M_EXT) == 0) { |
m_freem(m0); |
m_freem(m0); |
return NULL; |
return NULL; |
Line 1395 m_defrag(struct mbuf *mold, int flags) |
|
Line 1415 m_defrag(struct mbuf *mold, int flags) |
|
|
|
if (sz > 0) { |
if (sz > 0) { |
/* need more mbufs */ |
/* need more mbufs */ |
n = m_get(M_NOWAIT, MT_DATA); |
n = m_get(flags, MT_DATA); |
if (n == NULL) { |
if (n == NULL) { |
m_freem(m0); |
m_freem(m0); |
return NULL; |
return NULL; |
Line 1406 m_defrag(struct mbuf *mold, int flags) |
|
Line 1426 m_defrag(struct mbuf *mold, int flags) |
|
} |
} |
} while (sz > 0); |
} while (sz > 0); |
|
|
m_freem(mold); |
m_freem(mold->m_next); |
|
mold->m_next = m0; |
|
|
return m0; |
return mold; |
} |
} |
|
|
int |
int |