[PATCH dpdk v2] net: fix L2 ptype assignment in VLAN loop

David Marchand david.marchand at redhat.com
Wed Apr 22 15:23:46 CEST 2026


On Wed, 22 Apr 2026 at 12:39, Robin Jarry <rjarry at redhat.com> wrote:
> +static int
> +test_get_ptype(struct rte_mempool *pool, const char *pktdata, size_t len,
> +              uint32_t expected_l2, uint8_t expected_l2_len)
> +{
> +       struct rte_net_hdr_lens hdr_lens;
> +       struct rte_mbuf *m;
> +       uint32_t ptype;
> +       uint32_t l2;
> +       char *data;
> +
> +       m = rte_pktmbuf_alloc(pool);
> +       RTE_TEST_ASSERT_NOT_NULL(m, "cannot allocate mbuf");
> +
> +       data = rte_pktmbuf_append(m, len);
> +       if (data == NULL) {
> +               rte_pktmbuf_free(m);
> +               RTE_TEST_ASSERT_NOT_NULL(data, "cannot append data");
> +       }
> +
> +       memcpy(data, pktdata, len);
> +
> +       ptype = rte_net_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK);
> +       l2 = ptype & RTE_PTYPE_L2_MASK;
> +
> +       rte_pktmbuf_free(m);
> +
> +       RTE_TEST_ASSERT_EQUAL(l2, expected_l2,
> +               "unexpected L2 ptype: got 0x%x, expected 0x%x",
> +               l2, expected_l2);
> +       RTE_TEST_ASSERT_EQUAL(hdr_lens.l2_len, expected_l2_len,
> +               "unexpected l2_len: got %u, expected %u",
> +               hdr_lens.l2_len, expected_l2_len);

Since this test asks for RTE_PTYPE_ALL_MASK, let's validate the full
returned ptype, and the returned offsets.


> +
> +       return 0;


-- 
David Marchand



More information about the stable mailing list