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 @@ -105,19 +105,6 @@ STAILQ_ENTRY(epair_softc) entry; }; -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_if_input(struct epair_softc *sc, int ridx) { @@ -191,7 +178,7 @@ ifp = osc->oifp; M_ASSERTPKTHDR(m); - epair_clear_mbuf(m); + m_clear_tags(m); if_setrcvif(m, oifp); M_SETFIB(m, oifp->if_fib); Index: sys/sys/mbuf.h =================================================================== --- sys/sys/mbuf.h +++ sys/sys/mbuf.h @@ -1477,6 +1477,18 @@ m_snd_tag_destroy(mst); } +static inline 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) {