git: c69ae8419734 - main - if_epair: also remove vlan metadata from mbufs

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Mon, 10 Apr 2023 15:56:39 UTC
The branch main has been updated by kp:

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

commit c69ae8419734829404bdb47d694d105c85f9835e
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-04-10 11:02:55 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-04-10 13:55:35 +0000

    if_epair: also remove vlan metadata from mbufs
    
    We already remove mbuf tags from packets transitting an if_epair, but we
    didn't remove vlan metadata.
    In certain configurations this could lead to unexpected vlan tags
    turning up on the rx side.
    
    PR:             270736
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D39482
---
 sys/net/if_epair.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index aeed993249f5..e9e1a48b3d58 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
@@ -133,6 +133,8 @@ static struct epair_tasks_t epair_tasks;
 static void
 epair_clear_mbuf(struct mbuf *m)
 {
+	M_ASSERTPKTHDR(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);
@@ -140,6 +142,10 @@ epair_clear_mbuf(struct mbuf *m)
 		m->m_pkthdr.csum_flags &= ~CSUM_SND_TAG;
 	}
 
+	/* Clear vlan information. */
+	m->m_flags &= ~M_VLANTAG;
+	m->m_pkthdr.ether_vtag = 0;
+
 	m_tag_delete_nonpersistent(m);
 }