From: Kevin Traynor <ktraynor@redhat.com>
To: Robin Jarry <rjarry@redhat.com>,
dev@dpdk.org, Gregory Etelson <getelson@nvidia.com>
Cc: stable@dpdk.org
Subject: Re: [PATCH dpdk v3] net: fix VLAN packet type
Date: Thu, 23 Apr 2026 10:19:56 +0100 [thread overview]
Message-ID: <66613eae-13f6-42f9-bada-d1f3b5d9cee0@redhat.com> (raw)
In-Reply-To: <20260422133217.675900-3-rjarry@redhat.com>
On 4/22/26 2:32 PM, Robin Jarry wrote:
> Since commit 1f250674085a ("net: fix packet type for stacked VLAN"),
> rte_net_get_ptype() 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.
>
> Initialize pkt_type to 0 and defer the RTE_PTYPE_L2_ETHER assignment to
> the l3 label, only if no VLAN/QinQ type was set in the loop. This avoids
> the bitwise-or conflict between the L2 ptype constants entirely.
>
> Add a new net_ptype_autotest unit test that verifies the ptype and
> header lengths (l2_len, l3_len, l4_len) returned by rte_net_get_ptype()
> for plain Ethernet, single VLAN, stacked VLAN (two 802.1Q tags), and
> QinQ (802.1ad + 802.1Q) frames, with both IPv4/IPv6 and UDP/TCP
> combinations.
>
> Fixes: 1f250674085a ("net: fix packet type for stacked VLAN")
> Cc: stable@dpdk.org
>
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
Hi Robin,
Thanks for reporting this.
> ---
>
> Notes:
> v3:
>
> * changed the approach: initialize pkt_type=0 and only set it to
> RTE_PTYPE_L2_ETHER if neither of VLAN nor QINQ matched.
> * extended the unit tests to check for header lengths and added ipv6 / tcp
> cases.
>
> v2: added new ptype tests
>
> app/test/meson.build | 1 +
> app/test/test_net_ptype.c | 231 ++++++++++++++++++++++++++++++++++++++
> lib/net/rte_net.c | 4 +-
> 3 files changed, 235 insertions(+), 1 deletion(-)
> create mode 100644 app/test/test_net_ptype.c
>
<snip>
> diff --git a/lib/net/rte_net.c b/lib/net/rte_net.c
> index 458b4814a9c9..0228f1eb2f18 100644
> --- a/lib/net/rte_net.c
> +++ b/lib/net/rte_net.c
> @@ -331,8 +331,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> struct rte_net_hdr_lens local_hdr_lens;
> 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 pkt_type = 0;
> uint16_t proto;
> int ret;
>
> @@ -392,6 +392,8 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m,
> }
>
Not shown in diff, but for:
pkt_type |=
proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ?
RTE_PTYPE_L2_ETHER_VLAN :
RTE_PTYPE_L2_ETHER_QINQ;
It seems to be produce the right result, but I'm not sure we should be
treating the ptype L2 defines as bitmasks. Maybe I'm wrong and it was
planned, but it looks like a coincidence it works now because QINQ (0x7)
happens to be a superset of VLAN (0x6) for the OR.
Perhaps you could check vlan_depth and assign VLAN or QINQ based on that?
thanks,
Kevin.
> l3:
> + if (pkt_type == 0)
> + pkt_type = RTE_PTYPE_L2_ETHER;
> if ((layers & RTE_PTYPE_L3_MASK) == 0)
> return pkt_type;
>
next prev parent reply other threads:[~2026-04-23 9:20 UTC|newest]
Thread overview: 19+ 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 [this message]
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
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=66613eae-13f6-42f9-bada-d1f3b5d9cee0@redhat.com \
--to=ktraynor@redhat.com \
--cc=dev@dpdk.org \
--cc=getelson@nvidia.com \
--cc=rjarry@redhat.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