DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: William Bland <blandwwa@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Chas Williams <3chas3@gmail.com>
Cc: dev@dpdk.org, William Bland <blandwwa@gmail.com>, stable@dpdk.org
Subject: [PATCH v2 4/4] net/af_packet: fix QinQ outer TPID on VLAN reinsertion
Date: Wed, 26 Aug 2026 13:38:41 -0400	[thread overview]
Message-ID: <20260826173842.1298754-4-blandwwa@gmail.com> (raw)
In-Reply-To: <20260826173842.1298754-1-blandwwa@gmail.com>

eth_af_packet_rx() called rte_vlan_insert(), which hardcodes EtherType
0x8100 (802.1Q). This was wrong when reinserting a stripped tag whose
original TPID was 0x88a8 (802.1ad QinQ).

Fix by reading the actual TPID from tp_vlan_tpid (struct tpacket2_hdr),
then passing it to rte_vlan_insert_tpid().

This depends on the rte_vlan_insert_tpid() function added by "net: add
VLAN insert function with a TPID argument".

Fixes: 23deeebfcfa8 ("net/af_packet: support 802.1Q VLAN")
Cc: stable@dpdk.org

Signed-off-by: William Bland <blandwwa@gmail.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index d95d045a37..e7fbb3c31d 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -222,14 +222,20 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 		/* check for vlan info */
 		if (ppd->tp_status & TP_STATUS_VLAN_VALID) {
+			uint16_t tpid;
+
 			mbuf->vlan_tci = ppd->tp_vlan_tci;
 			mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN;
 
 			if (pkt_q->vlan_strip) {
 				mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED;
-			} else if (rte_vlan_insert(&mbuf) != 0) {
-				PMD_LOG(ERR, "Failed to reinsert VLAN tag");
-				mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED;
+			} else {
+				tpid = (ppd->tp_status & TP_STATUS_VLAN_TPID_VALID) ?
+					ppd->tp_vlan_tpid : RTE_ETHER_TYPE_VLAN;
+				if (rte_vlan_insert_tpid(&mbuf, tpid) != 0) {
+					PMD_LOG(ERR, "Failed to reinsert VLAN tag");
+					mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED;
+				}
 			}
 		}
 
-- 
2.43.0


  parent reply	other threads:[~2026-08-26 17:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 17:38 [PATCH v2 1/4] net: fix VLAN insert doc comment for shared-mbuf error code William Bland
2026-08-26 17:38 ` [PATCH v2 2/4] net/af_packet: make Rx VLAN stripped flag handling explicit William Bland
2026-08-26 20:26   ` Stephen Hemminger
2026-08-26 17:38 ` [PATCH v2 3/4] net: add VLAN insert function with a TPID argument William Bland
2026-08-26 20:27   ` Stephen Hemminger
2026-08-26 17:38 ` William Bland [this message]
2026-08-26 20:26 ` [PATCH v2 1/4] net: fix VLAN insert doc comment for shared-mbuf error code Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260826173842.1298754-4-blandwwa@gmail.com \
    --to=blandwwa@gmail.com \
    --cc=3chas3@gmail.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox