[PATCH v2] mbuf: fix read packet data
Morten Brørup
mb at smartsharesystems.com
Thu Mar 19 15:31:01 CET 2026
> From: Marat Khalili [mailto:marat.khalili at huawei.com]
> Sent: Thursday, 19 March 2026 15.22
>
> Acked-by: Marat Khalili <marat.khalili at huawei.com>
> Tested-by: Marat Khalili <marat.khalili at huawei.com>
Thank you for testing, Marat!
>
> Good idea to clarify check texts in the test.
>
> > diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
> > index a41d2d0f97..db23259745 100644
> > --- a/app/test/test_mbuf.c
> > +++ b/app/test/test_mbuf.c
> > @@ -2037,13 +2037,13 @@ test_pktmbuf_read_from_offset(struct
> rte_mempool *pktmbuf_pool)
> > /* read length greater than mbuf data_len */
> > if (rte_pktmbuf_read(m, hdr_len, rte_pktmbuf_data_len(m) + 1,
> > NULL) != NULL)
> > - GOTO_FAIL("%s: Requested len is larger than mbuf data
> len!\n",
> > + GOTO_FAIL("%s: Requested offset + len is larger than mbuf
> data len!\n",
> > __func__);
>
> Another strange check tbh, there is nothing wrong with reading beyond
> mbuf data
> length. This only fails because we are reading beyond packet length,
> which is
> tested immediately after. I'd vote to delete it, although it has
> nothing to do
> with the patch. This is just a general comment, not an issue.
Agree.
I also noticed that the offset is not subtracted from length parameter.
Testing the corner case should be:
rte_pktmbuf_read(m, hdr_len, rte_pktmbuf_data_len(m) - hdr_len + 1,
And more tests could be added to test segmented mbufs.
But I'll leave this patch to only care about fixing the wrapping bug.
The mbufs tests can be further improved another day, if someone cares to do the work.
>
> >
> > /* read length greater than mbuf pkt_len */
> > if (rte_pktmbuf_read(m, hdr_len, rte_pktmbuf_pkt_len(m) + 1,
> > NULL) != NULL)
> > - GOTO_FAIL("%s: Requested len is larger than mbuf pkt
> len!\n",
> > + GOTO_FAIL("%s: Requested offset + len is larger than mbuf
> pkt len!\n",
> > __func__);
> >
> > /* read data of zero len from valid offset */
More information about the dev
mailing list