summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2005-08-29 19:45:39 +0000
committerandre <andre@FreeBSD.org>2005-08-29 19:45:39 +0000
commit71f036e379e29d52810f39a7ae320ea932e39f32 (patch)
treecefd183af10a389ed774ae9535fdc5afca9afd29 /sys/kern/uipc_mbuf.c
parent3c8a222751be83a28bbd85664bdaa68c0688c475 (diff)
downloadFreeBSD-src-71f036e379e29d52810f39a7ae320ea932e39f32.zip
FreeBSD-src-71f036e379e29d52810f39a7ae320ea932e39f32.tar.gz
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
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 6a0e9ba..6932245 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -270,6 +270,30 @@ mb_free_ext(struct 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.
*/
OpenPOWER on IntegriCloud