Subject: Re: skb header allocation

From: Stephen Hemminger <[email-masked]>
Date: Tue, 25 Aug 2009 20:15:14 -0700

On Tue, 25 Aug 2009 22:04:10 -0500
Chris Ross <[email-masked]> wrote:

> I have a network driver that acts as a Ethernet device and builds up a
> series of outer headers on skb(s) it receives from upper layers. I am
> currently using the technique that is in ipip.c to ensure I have
> enough room to add my header ...
> 
> if (skb_headroom(skb) < some_value || skb_shared(skb) ||
>          ((skb_cloned(skb) && !skb_clone_writable(skb, 0))))
>    {
>       if ((skb2 = skb_realloc_headroom(skb, some_value)) == NULL)
>          return -1;
> 
>       dev_kfree_skb(skb);
>       skb = skb2;
>    }
> 
> Is this the best practice for a high bandwidth scenario?

Define a value of dev->hard_header_len that adds space for what you need.
Use skb_cow_head(skb, headroom) before touching skb header.