summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf2.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-10-29 05:40:07 +0000
committersam <sam@FreeBSD.org>2003-10-29 05:40:07 +0000
commit409cf5f514ad9056b7dac76a11c4844021c2be2b (patch)
treed88c488f67b1157ed3b937a89a30e71bdcc2bd2b /sys/kern/uipc_mbuf2.c
parent0e35eb160176704d52210e5e548a61a6aaa6cd84 (diff)
downloadFreeBSD-src-409cf5f514ad9056b7dac76a11c4844021c2be2b.zip
FreeBSD-src-409cf5f514ad9056b7dac76a11c4844021c2be2b.tar.gz
Introduce the notion of "persistent mbuf tags"; these are tags that stay
with an mbuf until it is reclaimed. This is in contrast to tags that vanish when an mbuf chain passes through an interface. Persistent tags are used, for example, by MAC labels. Add an m_tag_delete_nonpersistent function to strip non-persistent tags from mbufs and use it to strip such tags from packets as they pass through the loopback interface and when turned around by icmp. This fixes problems with "tag leakage". Pointed out by: Jonathan Stone Reviewed by: Robert Watson
Diffstat (limited to 'sys/kern/uipc_mbuf2.c')
-rw-r--r--sys/kern/uipc_mbuf2.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c
index 215fc68..1b579e3 100644
--- a/sys/kern/uipc_mbuf2.c
+++ b/sys/kern/uipc_mbuf2.c
@@ -381,6 +381,23 @@ m_tag_delete_chain(struct mbuf *m, struct m_tag *t)
m_tag_delete(m, p);
}
+/*
+ * Strip off all tags that would normally vanish when
+ * passing through a network interface. Only persistent
+ * tags will exist after this; these are expected to remain
+ * so long as the mbuf chain exists, regardless of the
+ * path the mbufs take.
+ */
+void
+m_tag_delete_nonpersistent(struct mbuf *m)
+{
+ struct m_tag *p, *q;
+
+ SLIST_FOREACH_SAFE(p, &m->m_pkthdr.tags, m_tag_link, q)
+ if ((p->m_tag_id & MTAG_PERSISTENT) == 0)
+ m_tag_delete(m, p);
+}
+
/* Find a tag, starting from a given position. */
struct m_tag *
m_tag_locate(struct mbuf *m, u_int32_t cookie, int type, struct m_tag *t)
OpenPOWER on IntegriCloud