mbuf validity in conjunction with ref cnt

Stephen Hemminger stephen at networkplumber.org
Sat Feb 22 17:18:27 CET 2025


On Sat, 22 Feb 2025 10:22:51 +0530
Lokesh Chakka <lvenkatakumarchakka at gmail.com> wrote:

> My objective is to reuse mbuf unlimited number of times for a configurable
> amount of time.
> 
> rte_pktmbuf_alloc // after here refcnt is 1
> refcnt_update ( , 1) //after here refcnt is 2
> while( time still exists )
> {
>       tx_burst
> }
> 
> Will this approach work with all drivers/cards ?

For that kind of flood you need to get reference before tx_burst.
The driver will see mbuf with refcnt of 2 and decrement it to 1 when
done.

	mb = rte_pktmbuf_alloc();
	// setup the mbuf

	while (!stopped) {
		rte_mbuf_ref_update(mb, 1); // retain original
		... tx_burst
	}
	rte_pktmbuf_free(mb); // release original





More information about the users mailing list