Subject: Re: Socket Buffers and Memory Managment

From: Stephen Hemminger <[email-masked]>
Date: Thu, 19 Jul 2007 09:10:41 +0100

On Wed, 18 Jul 2007 23:51:03 -0700 (PDT)
vinay ravuri <[email-masked]> wrote:

> How about the following approach:
> 
> I allocate an skb of 0 bytes and replace data element
> of skb struct (i.e. skb.data = addr_given_by_hw) when
> the h/w interrupts me with a packet.  I register for a
> destructor for this skb and when the kernel is ready
> to free the skb, I make sure that my free is invoked -
> Ofcourse this is assuming that their is a facility in
> linux socket buffers to be able to do destructors.  Is
> this approach a viable, if so, are any gottcha's?
> 
> -Vinay

You need to use frag list for that since upper layers expect to
be able to use that data area for normal use, ie bridging/routing, etc.
Also access to data area would be non-cached so you want to make
sure it is only accessed once.

But how will you handle a slow receiver where all the skb's end up
staying queued. Won't you exhaust your packet memory.