From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Gregory Etelson <getelson@nvidia.com>
Cc: stable@dpdk.org
Subject: [PATCH dpdk v5 1/5] Revert "net: fix packet type for stacked VLAN"
Date: Mon, 18 May 2026 15:27:15 +0200 [thread overview]
Message-ID: <20260518132712.70913-9-rjarry@redhat.com> (raw)
In-Reply-To: <20260518132712.70913-8-rjarry@redhat.com>
This reverts commit 1f250674085aeb4ffd15ac2519a68efc04faf7ac.
rte_net_get_ptype() now uses |= to set the L2 ptype inside the VLAN
parsing loop. Since pkt_type is already initialized with
RTE_PTYPE_L2_ETHER (0x1), or-ing it with RTE_PTYPE_L2_ETHER_VLAN (0x6)
results in RTE_PTYPE_L2_ETHER_QINQ (0x7). This causes single VLAN frames
to be misidentified as QinQ.
This was detected while testing DPDK 25.11.1 in grout. The net/tap
driver calls rte_net_get_ptype() in tap_verify_csum() to determine the
L2 header length. With the wrong ptype, l2_len is set to 22 (ether
+ QinQ = 14 + 8) instead of 18 (ether + VLAN = 14 + 4), shifting the IP
header pointer by 4 bytes. The checksum is then computed on garbage
data, causing valid packets to be dropped.
Bugzilla ID: 1941
Fixes: 1f250674085a ("net: fix packet type for stacked VLAN")
Cc: stable@dpdk.org
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
lib/net/rte_net.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
index 458b4814a9c9..c70b57fdc0f8 100644
--- a/lib/net/rte_net.c
+++ b/lib/net/rte_net.c
@@ -320,9 +320,6 @@ rte_net_skip_ip6_ext(uint16_t proto, const struct rte_mbuf *m, uint32_t *off,
return -1;
}
-/* limit number of supported VLAN headers */
-#define RTE_NET_VLAN_MAX_DEPTH 8
-
/* parse mbuf data to get packet type */
RTE_EXPORT_SYMBOL(rte_net_get_ptype)
uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
@@ -332,7 +329,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
const struct rte_ether_hdr *eh;
struct rte_ether_hdr eh_copy;
uint32_t pkt_type = RTE_PTYPE_L2_ETHER;
- uint32_t off = 0, vlan_depth = 0;
+ uint32_t off = 0;
uint16_t proto;
int ret;
@@ -352,26 +349,30 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4))
goto l3; /* fast path if packet is IPv4 */
- while (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
- proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+ if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN)) {
const struct rte_vlan_hdr *vh;
struct rte_vlan_hdr vh_copy;
- 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;
+ pkt_type = RTE_PTYPE_L2_ETHER_VLAN;
vh = rte_pktmbuf_read(m, off, sizeof(*vh), &vh_copy);
if (unlikely(vh == NULL))
return pkt_type;
off += sizeof(*vh);
hdr_lens->l2_len += sizeof(*vh);
proto = vh->eth_proto;
- }
+ } else if (proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
+ const struct rte_vlan_hdr *vh;
+ struct rte_vlan_hdr vh_copy;
- if ((proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS)) ||
+ pkt_type = RTE_PTYPE_L2_ETHER_QINQ;
+ vh = rte_pktmbuf_read(m, off + sizeof(*vh), sizeof(*vh),
+ &vh_copy);
+ if (unlikely(vh == NULL))
+ return pkt_type;
+ off += 2 * sizeof(*vh);
+ hdr_lens->l2_len += 2 * sizeof(*vh);
+ proto = vh->eth_proto;
+ } else if ((proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS)) ||
(proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLSM))) {
unsigned int i;
const struct rte_mpls_hdr *mh;
--
2.54.0
next prev parent reply other threads:[~2026-05-18 13:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 10:28 [PATCH dpdk] net: fix L2 ptype assignment in VLAN loop Robin Jarry
2026-04-22 10:35 ` Robin Jarry
2026-04-22 10:38 ` [PATCH dpdk v2] " Robin Jarry
2026-04-22 13:16 ` Thomas Monjalon
2026-04-22 13:18 ` Robin Jarry
2026-04-22 13:23 ` David Marchand
2026-04-22 13:32 ` [PATCH dpdk v3] net: fix VLAN packet type Robin Jarry
2026-04-23 9:19 ` Kevin Traynor
2026-04-23 9:49 ` Robin Jarry
2026-04-23 10:59 ` Kevin Traynor
2026-04-23 11:11 ` Robin Jarry
2026-04-23 11:24 ` [PATCH dpdk v4] " Robin Jarry
2026-04-24 16:18 ` Kevin Traynor
2026-04-25 8:40 ` David Marchand
2026-04-27 10:47 ` Robin Jarry
2026-04-27 15:53 ` Thomas Monjalon
2026-04-30 10:12 ` David Marchand
2026-04-30 11:06 ` Morten Brørup
2026-05-15 11:17 ` Kevin Traynor
2026-05-18 13:27 ` [PATCH dpdk v5 0/5] Fix and improve VLAN/MPLS parsing in rte_net_get_ptype Robin Jarry
2026-05-18 13:27 ` Robin Jarry [this message]
2026-05-20 9:47 ` [PATCH dpdk v5 1/5] Revert "net: fix packet type for stacked VLAN" David Marchand
2026-05-20 10:24 ` Kevin Traynor
2026-05-18 13:27 ` [PATCH dpdk v5 2/5] net: support multiple stacked VLAN tags Robin Jarry
2026-05-20 9:56 ` David Marchand
2026-05-20 11:09 ` Robin Jarry
2026-05-20 12:42 ` David Marchand
2026-05-18 13:27 ` [PATCH dpdk v5 3/5] net: add unit tests for rte_net_get_ptype Robin Jarry
2026-05-18 13:27 ` [PATCH dpdk v5 4/5] net: parse L3 protocol after MPLS labels Robin Jarry
2026-05-18 18:00 ` Stephen Hemminger
2026-05-18 13:27 ` [PATCH dpdk v5 5/5] net: add truncated packet tests for rte_net_get_ptype Robin Jarry
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=20260518132712.70913-9-rjarry@redhat.com \
--to=rjarry@redhat.com \
--cc=dev@dpdk.org \
--cc=getelson@nvidia.com \
--cc=stable@dpdk.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