On Thu, 23 Feb 2023 14:54:13 +0000
NAGENDRA BALAGANI <nagendra.balag...@oracle.com> wrote:
> Hi Team,
>
> In my dpdk application, I am facing an issue where rte_pktmbuf_alloc() is
> returning same address for two consecutive calls in a single thread context.
>
> Following is the code snippet,
>
> int Func(struct rte_mbuf *mblk)
> {
> struct rte_mbuf *tmpbuf = nullptr;;
> struct rte_mbuf *copybuf = nullptr;
> char *nextPtr = NULL;
>
> tmpbuf = rte_pktmbuf_alloc(mbuf_pool);
>
> nextPtr = rte_pktmbuf_append(tmpbuf, IPV4_HDR_LEN);
> //update some info on nextptr
>
> copybuf = rte_pktmbuf_copy(mblk, mbuf_pool, 0, pkt_len);
>
> ....
> return 0;
> }
>
> With the above snippet, 'tmpbuf' and 'copybuf' which are getting allocated
> from same pool (mbuf_pool), pointing to same address, Due to this tmpbuf
> which gets allocated first, and further populated, is getting over written
> inside rte_pktmbuf_copy() call which is not expected .
> When I further debug , rte_pktmbuf_copy() is internally using
> rte_pktmbuf_alloc() to get the free buffer from mbuf_pool and copy the data
> from mblk.
>
> Please let us know if there is any known issue with rte_pktmbuf_alloc(), and
> why it may be giving same address on two consecutive calls.
>
> Regards,
> Nagendra
>
Most likely your mbuf pool has gotten corrupted before you get to that code.
Try building with the config options for POOL and MBUF debug.