bugs in rte_pktmbuf_copy

Stephen Hemminger stephen at networkplumber.org
Tue Nov 18 00:43:20 CET 2025


On Mon, 17 Nov 2025 12:51:51 +0100
Morten Brørup <mb at smartsharesystems.com> wrote:

> While working on a rte_pktmbuf_copy_bulk() function, I noticed a couple of bugs in rte_pktmbuf_copy():
> 
> 1. If the copy is allocated from a mempool using pinned external buffers, the copy's RTE_MBUF_F_EXTERNAL flag is lost.
> This is simple to fix:
> 
> -	/* copied mbuf is not indirect or external */
> -	mc->ol_flags = m->ol_flags & ~(RTE_MBUF_F_INDIRECT|RTE_MBUF_F_EXTERNAL);
> +	/* copy flags except indirect and external */
> +	mc->ol_flags |= m->ol_flags & ~(RTE_MBUF_F_INDIRECT|RTE_MBUF_F_EXTERNAL);

Good catch, external flag needs to be preserved. 


> 2. If the packet is copied with non-zero offset, much of the metadata do not apply to the copy, e.g. many of the offload flags and the packet_type field.
> Maybe metadata should be reset when copying with a non-zero offset?
> Or maybe rte_pktmbuf_copy() should be considered "payload copy", so the copy should have all metadata reset?

The use case for using offset, is for removing tunnel headers. I expect that the code doing so
would know what manipulation of offloads was required. 



More information about the dev mailing list