git: ae23f081c5c7 - stable/12 - if_epair: delete mbuf tags

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 19 Nov 2021 06:39:18 UTC
The branch stable/12 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae23f081c5c741b9f3019ed8a84226548ec15308

commit ae23f081c5c741b9f3019ed8a84226548ec15308
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-10-26 07:57:56 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-11-19 06:35:58 +0000

    if_epair: delete mbuf tags
    
    Remove all (non-persistent) tags when we transmit a packet. Real network
    interfaces do not carry any tags either, and leaving tags attached can
    produce unexpected results.
    
    Reviewed by:    bz, glebius
    MFC after:      3 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D32663
    
    (cherry picked from commit 62d2dcafb7f33fe8f47e9d5dd519d665f7af140e)
---
 sys/net/if_epair.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index 376bdbe9117f..cd11036ad028 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
@@ -194,6 +194,12 @@ struct epair_dpcpu {
 };
 DPCPU_DEFINE(struct epair_dpcpu, epair_dpcpu);
 
+static void
+epair_clear_mbuf(struct mbuf *m)
+{
+	m_tag_delete_nonpersistent(m);
+}
+
 static void
 epair_dpcpu_init(void)
 {
@@ -433,6 +439,8 @@ epair_start_locked(struct ifnet *ifp)
 		}
 		DPRINTF("packet %s -> %s\n", ifp->if_xname, oifp->if_xname);
 
+		epair_clear_mbuf(m);
+
 		/*
 		 * Add a reference so the interface cannot go while the
 		 * packet is in transit as we rely on rcvif to stay valid.
@@ -554,6 +562,9 @@ epair_transmit_locked(struct ifnet *ifp, struct mbuf *m)
 			(void)epair_add_ifp_for_draining(ifp);
 		return (error);
 	}
+
+	epair_clear_mbuf(m);
+
 	sc = oifp->if_softc;
 	/*
 	 * Add a reference so the interface cannot go while the