[dpdk-users] A question about rte_pktmbuf_init() and alike functions

Александр Самойлов cidjey1991 at mail.ru
Tue Nov 3 20:44:22 CET 2015


 Oh, that's emberrasing. After another manual reading I found this one (in mbuf section of Programmer's Guide): 

Freeing a mbuf means returning it into its original mempool. The content of an mbuf is not modified when it is stored in a pool (as a free mbuf). Fields initialized by the constructor do not need to be re-initialized at mbuf allocation.

Should've guessed then. But still, maybe it's reasonable to highlight this part a little? Smth like "So you can't safely use a mbuf repeatedly without memzeroing its content" or smth? :)

P.S. Sorry for disturbance


>
>
>On 11/3/15, 1:23 PM, "users on behalf of Александр Самойлов" < users-bounces at dpdk.org on behalf of  cidjey1991 at mail.ru > wrote:
>
>> An update. I decided to try this:
>>
>>m = rte_pktmbuf_alloc(mp);
>>if(unlikely(m == NULL))
>>{
>>    RTE_LOG(INFO, USER1, "%s: Couldn't allocate pkt_mbuf\n", __func__);
>>    return NULL;
>>}
>>rte_pktmbuf_init(mp, NULL, m, 0);
>>rte_mbuf_refcnt_set(m, 1);
>>Well, it worked out. My memory is not dirty anymore and TCP checksum is always OK. Thank you for the input.
>>But this raises another question: You said that rte_pktmbuf_alloc() implies resetting the buffer to a "sane state". 
>>So why this reset doesn't make my new "m" buffer "sane enough" to keep a new frame while rte_pktmbuf_init does?
>
>You can look at the code, but the reset tries to do the least amount work in touching the mbuf header for performance.
>>
>>
>>Alex Samoylov
>>
>>
>>
>
>
>Regards,
>Keith
>
>
>
>



More information about the users mailing list