lkml.org 
[lkml]   [2014]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectsk_buff: why field 'head' contains skb_shared_info?
Date
Subj.

Look at this core function:
net/core/skbuff.c: __alloc_skb
...
size = SKB_DATA_ALIGN(size);
size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
...
shinfo = skb_shinfo(skb);
memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
...

It looks like it was made purposely, but for what?

Why this question has risen.
I found for my needs a very nice (for the first look) function <build_skb> from skbuff.c:
> * build_skb - build a network buffer
> * @data: data buffer provided by caller
> ...
> * Notes :
> * Before IO, driver allocates only data buffer where NIC put incoming frame

Everything looks delicious, until this place:
> * Driver should add room at head (NET_SKB_PAD) and
> * MUST add room at tail (SKB_DATA_ALIGN(skb_shared_info))

And what if NIC is not a regular net_device and it doesn't need sk_buff at all.
But for virtual ethernet device "Ethernet-over-NIC" sk_buff is crucial.
So driver for NIC can't just kmalloc(NICs_RCV_BUF_SIZE, ...) for incoming buffers,
it has to kmalloc(NICs_RCV_BUF_SIZE + <skb_shared_info>, ...) to cover
attached (if any) to NIC virtual ethernet device needs.
Or virtual ethernet device has to do netdev_alloc_skb + memcpy,
which is obviously not so good.


\
 
 \ /
  Last update: 2014-02-22 19:01    [W:0.031 / U:0.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site