Strange behavior with rte_pktmbuf_clone cal

Stephen Hemminger stephen at networkplumber.org
Fri Dec 23 17:43:17 CET 2022


On Fri, 23 Dec 2022 07:00:40 +0000
NAGENDRA BALAGANI <nagendra.balagani at oracle.com> wrote:

> Hi,
> 
> I am seeing strange behavior where rte_pktmbuf_clone is not giving desired result.
> Here is the detailed info, in my dpdk application  , once I received the packet info in mbuf, I need to send the same packet to two destinations, the sequence  I should follow is,
> 
> (i)                  First, Tunnel the packet to one of desired destination, so I created the shallow copy using rte_pktmbuf_clone, had another mbuf for Outer IP Header for IPinIP tunnel and sent to NIC.
> 
> (ii)                Second, I need to modify the source and destination ip addresses of the packet and send out.

As you showed, that won't work like you think.
A shallow clone means that both versions share the same data area.
If you modify one one instance both change.

The best practice is to consider a clone (or any mbuf with refcount > 1) as read only.



More information about the dev mailing list