Index: share/man/man9/mbuf_tags.9 =================================================================== --- share/man/man9/mbuf_tags.9 +++ share/man/man9/mbuf_tags.9 @@ -20,7 +20,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2008 +.Dd October 28, 2021 .Dt MBUF_TAGS 9 .Os .Sh NAME @@ -58,6 +58,8 @@ .Fn m_tag_prepend "struct mbuf *m" "struct m_tag *t" .Ft void .Fn m_tag_unlink "struct mbuf *m" "struct m_tag *t" +.Ft void +.Fn m_clear_tags "struct mbuf *m" .Sh DESCRIPTION Mbuf tags allow additional meta-data to be associated with in-flight packets by providing a mechanism for the tagging of additional kernel memory onto @@ -270,6 +272,9 @@ .Fa tag from the list of tags of packet .Fa mbuf . +.It Fn m_clear_tags mbuf +Remove any (non-persistent) tags as well as send tags from the +.Fa mbuf . .El .Sh CODE REFERENCES The tag-manipulating code is contained in the file Index: sys/net/if_epair.c =================================================================== --- sys/net/if_epair.c +++ sys/net/if_epair.c @@ -196,19 +196,6 @@ }; DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu); -static void -epair_clear_mbuf(struct mbuf *m) -{ - /* Remove any CSUM_SND_TAG as ether_input will barf. */ - if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { - m_snd_tag_rele(m->m_pkthdr.snd_tag); - m->m_pkthdr.snd_tag = NULL; - m->m_pkthdr.csum_flags &= ~CSUM_SND_TAG; - } - - m_tag_delete_nonpersistent(m); -} - static void epair_dpcpu_init(void) { @@ -448,7 +435,7 @@ } DPRINTF("packet %s -> %s\n", ifp->if_xname, oifp->if_xname); - epair_clear_mbuf(m); + m_clear_tags(m); /* * Add a reference so the interface cannot go while the @@ -572,7 +559,7 @@ return (error); } - epair_clear_mbuf(m); + m_clear_tags(m); sc = oifp->if_softc; /* Index: sys/sys/mbuf.h =================================================================== --- sys/sys/mbuf.h +++ sys/sys/mbuf.h @@ -1477,6 +1477,18 @@ m_snd_tag_destroy(mst); } +static void +m_clear_tags(struct mbuf *m) +{ + if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { + m_snd_tag_rele(m->m_pkthdr.snd_tag); + m->m_pkthdr.snd_tag = NULL; + m->m_pkthdr.csum_flags &= ~CSUM_SND_TAG; + } + + m_tag_delete_nonpersistent(m); +} + static __inline struct mbuf * m_free(struct mbuf *m) {