From: "Кулешов Алексей" <rndfax@yandex.ru>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: sk_buff: why field 'head' contains skb_shared_info?
Date: Sat, 22 Feb 2014 21:08:27 +0400 [thread overview]
Message-ID: <317951393088907@web3h.yandex.ru> (raw)
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.
reply other threads:[~2014-02-22 17:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=317951393088907@web3h.yandex.ru \
--to=rndfax@yandex.ru \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®