All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] net: fix L2 ptype for VLAN-tagged packets
@ 2026-09-13 23:36 Ivan Malov
  2026-09-14 17:00 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Malov @ 2026-09-13 23:36 UTC (permalink / raw)
  To: dev; +Cc: stable

When a tag is discovered, the code does not remove 'RTE_PTYPE_L2_ETHER'
set on function entry. For single-tagged packets, 'RTE_PTYPE_L2_ETHER'
and 'RTE_PTYPE_L2_ETHER_VLAN' give 'RTE_PTYPE_L2_ETHER_QINQ' when
OR-ed together. Clear previously set L2 type when handling VLANs.

Also, since 'RTE_PTYPE_L2_ETHER_VLAN' requires that the EtherType field
in the Ethernet header be set to 0x8100 and 'RTE_PTYPE_L2_ETHER_QINQ'
requires that it be set to 0x88a8, it is the outermost (first) tag
that determines what the software L2 ptype should be. Clarify that.

Fixes: 1f250674085a ("net: fix packet type for stacked VLAN")
Cc: stable@dpdk.org

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
---
 lib/net/rte_net.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 0a91e92ba0..826d9f58b9 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -365,10 +365,18 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
 
 		if (++vlan_depth > RTE_NET_VLAN_MAX_DEPTH)
 			return 0;
-		pkt_type |=
-			proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ?
-				 RTE_PTYPE_L2_ETHER_VLAN :
-				 RTE_PTYPE_L2_ETHER_QINQ;
+
+		/*
+		 * It is the outermost tag that determines whether
+		 * the packet will be classified as VLAN or QinQ.
+		 */
+		if (vlan_depth == 1) {
+			/* Override previously set 'RTE_PTYPE_L2_ETHER'. */
+			pkt_type = (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ?
+					RTE_PTYPE_L2_ETHER_VLAN :
+					RTE_PTYPE_L2_ETHER_QINQ);
+		}
+
 		vh = rte_pktmbuf_read(m, off, sizeof(*vh), &vh_copy);
 		if (unlikely(vh == NULL))
 			return pkt_type;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-14 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-13 23:36 [PATCH 1/1] net: fix L2 ptype for VLAN-tagged packets Ivan Malov
2026-09-14 17:00 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.