Re: dev_alloc_skb() magic headroom

Alan Cox (alan@lxorguk.ukuu.org.uk)
Wed, 25 Aug 1999 00:16:47 +0100 (BST)


> dev_alloc_skb() allocates and reserves 16 extra bytes at the
> skbuff's head. Is this just some magic code (for cache optimization,
> protection against buggy drivers, ... what then???) subject to change

Its an optimisation for probable packet paths. The 16 is chosen for
cache reasons too. The largest common packet transfer for forwarding is
one that adds 14 bytes of needed header space - slip/ppp -> ethernet so
we drop the 16 in to ensure that for almost all cases the packet
will not be copied

> or can users (e.g. when allocating downstream skb's) rely on
> dev_alloc_skb() always returning an skb with
> 16 extra bytes reserved at the buffer head?

No you cannot. If you want an sk_buff with 16 bytes head room do
skb=alloc_skb(len+16, GFP_whatever);
if(skb==NULL) panic()
skb_reserve(skb,16);

> I thought dev_alloc_skb() is primarily intended for network
> device driver's interrupt handlers when allocation the upstream
> skb's (the header won't grow when passed upstream). Is this true?

Correct. It may break in future if you use it for anything else.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/