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: [email protected]

Signed-off-by: William Bland <[email protected]>
---
 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

Reply via email to