sk_buff: why field 'head' contains skb_shared_info?
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:
Quoted 5 lines
*
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:
Quoted 2 lines
* 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.