* sk_buff: why field 'head' contains skb_shared_info?
@ 2014-02-22 17:08 Кулешов Алексей
0 siblings, 0 replies; only message in thread
From: Кулешов Алексей @ 2014-02-22 17:08 UTC (permalink / raw)
To: linux-kernel
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-22 17:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-22 17:08 sk_buff: why field 'head' contains skb_shared_info? Кулешов Алексей
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®