mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-26 16:18:31 +00:00
Add m_demote(struct mbuf *m, int all) to clean up mbuf (chain) from
any tags and packet headers. If "all" is set then the first mbuf in the chain will be cleaned too. This function is used before an mbuf, that arrived as packet with m->flags & M_PKTHDR, is appended to an mbuf chain using m->m_next (not m->m_nextpkt). Reviewed by: glebius
This commit is contained in:
parent
919ccba73e
commit
ed111688e9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=149598
@ -269,6 +269,30 @@ mb_free_ext(struct mbuf *m)
|
||||
uma_zfree(zone_mbuf, m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up mbuf (chain) from any tags and packet headers.
|
||||
* If "all" is set then the first mbuf in the chain will be
|
||||
* cleaned too.
|
||||
*/
|
||||
void
|
||||
m_demote(struct mbuf *m0, int all)
|
||||
{
|
||||
struct mbuf *m;
|
||||
|
||||
for (m = all ? m0 : m0->m_next; m != NULL; m = m->m_next) {
|
||||
if (m->m_flags & M_PKTHDR) {
|
||||
m_tag_delete_chain(m, NULL);
|
||||
m->m_flags &= ~M_PKTHDR;
|
||||
bzero(&m->m_pkthdr, sizeof(struct pkthdr));
|
||||
}
|
||||
if (m->m_type & MT_HEADER)
|
||||
m->m_type = MT_DATA;
|
||||
if (m != m0 && m->m_nextpkt)
|
||||
m->m_nextpkt = NULL;
|
||||
m->m_flags = m->m_flags & (M_EXT|M_EOR|M_RDONLY|M_FREELIST);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "Move" mbuf pkthdr from "from" to "to".
|
||||
* "from" must have M_PKTHDR set, and "to" must be empty.
|
||||
|
@ -577,6 +577,7 @@ struct mbuf *m_copypacket(struct mbuf *, int);
|
||||
void m_copy_pkthdr(struct mbuf *, struct mbuf *);
|
||||
struct mbuf *m_copyup(struct mbuf *n, int len, int dstoff);
|
||||
struct mbuf *m_defrag(struct mbuf *, int);
|
||||
void m_demote(struct mbuf *, int);
|
||||
struct mbuf *m_devget(char *, int, int, struct ifnet *,
|
||||
void (*)(char *, caddr_t, u_int));
|
||||
struct mbuf *m_dup(struct mbuf *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user