Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2023 04:53:09 GMT
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: c0038743d357 - stable/12 - net: Remove vlan metadata on pcp / vlan encapsulation
Message-ID:  <202309060453.3864r9NN022448@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by zlei:

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

commit c0038743d357da9b5ebf756f4fc3b2cf7d2ef3e9
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-08-30 09:36:38 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-06 04:32:56 +0000

    net: Remove vlan metadata on pcp / vlan encapsulation
    
    For oubound traffic, the flag M_VLANTAG is set in mbuf packet header to
    indicate the underlaying interface do hardware VLAN tag insertion if
    capable, otherwise the net stack will do 802.1Q encapsulation instead.
    
    Commit 868aabb4708d introduced per-flow priority which set the priority ID
    in the mbuf packet header. There's a corner case that when the driver is
    disabled to do hardware VLAN tag insertion, and the net stack do 802.1Q
    encapsulation, then it will result double tagged packets if the driver do
    not check the enabled capability (hardware VLAN tag insertion).
    
    Unfortunately some drivers, currently known cxgbe(4) re(4) ure(4) igc(4)
    and vmx(4), have this issue. From a quick review for other interface
    drivers I believe a lot more drivers have the same issue. It makes more
    sense to fix in net stack than to try to change every single driver.
    
    PR:             270736
    Reviewed by:    kp
    Fixes:  868aabb4708d Add IP(V6)_VLAN_PCP to set 802.1 priority per-flow
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D39499
    
    (cherry picked from commit b22aae410bc7e4e9a6b43e556dc34be72deadb65)
    (cherry picked from commit 494de30b63de9ef31587dcc3fb8e7249535e840a)
    (cherry picked from commit 337475505b4cdf40510bd2e2788fdce5c0c47367)
---
 sys/net/if_ethersubr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index ddc92535be60..f832700003ef 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -443,8 +443,11 @@ ether_set_pcp(struct mbuf **mp, struct ifnet *ifp, uint8_t pcp)
 	struct ether_header *eh;
 
 	eh = mtod(*mp, struct ether_header *);
-	if (ntohs(eh->ether_type) == ETHERTYPE_VLAN ||
-	    ether_8021q_frame(mp, ifp, ifp, 0, pcp))
+	if (eh->ether_type == htons(ETHERTYPE_VLAN)) {
+		(*mp)->m_flags &= ~M_VLANTAG;
+		return (true);
+	}
+	if (ether_8021q_frame(mp, ifp, ifp, 0, pcp))
 		return (true);
 	if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 	return (false);
@@ -1373,6 +1376,7 @@ ether_8021q_frame(struct mbuf **mp, struct ifnet *ife, struct ifnet *p,
 			if_printf(ife, "unable to prepend 802.1Q header");
 			return (false);
 		}
+		(*mp)->m_flags &= ~M_VLANTAG;
 	}
 	return (true);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309060453.3864r9NN022448>