Re: [PATCH 1/4] net: add support for per-paged-fragment destructors
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: 2011-11-09 15:33:04
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: 2011-11-09 15:33:04
On Wed, Nov 09, 2011 at 03:02:04PM +0000, Ian Campbell wrote:
Entities which care about the complete lifecycle of pages which they inject into the network stack via an skb paged fragment can choose to set this destructor in order to receive a callback when the stack is really finished with a page (including all clones, retransmits, pull-ups etc etc).
[...]
--- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h@@ -139,9 +139,16 @@ struct sk_buff; typedef struct skb_frag_struct skb_frag_t; +struct skb_frag_destructor { + atomic_t ref; + int (*destroy)(void *data); + void *data; +}; + struct skb_frag_struct { struct { struct page *p; + struct skb_frag_destructor *destructor; } page;
You can get rid of the data field of skb_frag_destructor: if destroy() gets pointer to the destroyed struct skb_frag_set_destructor, its users can get at containing struct via container_of() if needed and the memory pointed to by data won't have to be managed separately. Nice work, BTW! Best Regards, Michał Mirosław