From: Eric Dumazet <eric.dumazet@gmail.com>
To: Sharat Masetty <sharat_masetty@yahoo.com>
Cc: netdev@vger.kernel.org, linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Question about more headroom in skb
Date: Tue, 11 May 2010 07:06:27 +0200 [thread overview]
Message-ID: <1273554387.10889.23.camel@edumazet-laptop> (raw)
In-Reply-To: <682359.68270.qm@web112510.mail.gq1.yahoo.com>
Le lundi 10 mai 2010 à 13:09 -0700, Sharat Masetty a écrit :
> Hello All,
Please dont use too long lines
>
> For my project I need 3 words of headroom in the skb in the network
> driver level, to add a custom header to the ethernet packet. I
> looked into the tcp code and figured out tcp uses sk->sk_prot->max_header
> for header allocation size. But I was not able to confirm that all other
> transport protocol use the same mechanism(?) For example in UDP/ICMP I was
> not able to figure out from the code where the allocation and header
> reservation happens(Any light here would be really helpful.)
>
> I have also looked at an API in skbuff skb_pad() which does what I want
> (add either headroom or tailroom), but I want to avoid that for performance
> reasons(skb_pad does kmalloc and memcpy). I want to figure out a good way
> (may be tune some parameters) to allocate extra 3 words for any skbuff
> independant of the transport protocol being used.
> Any light here would be very much appreciated.
LL_RESERVED_SPACE() is the magic you need.
#define LL_RESERVED_SPACE(dev) \
((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
sendmsg() -> ip_append_data()
...
hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
...
if (transhdrlen) {
skb = sock_alloc_send_skb(sk,
alloclen + hh_len + 15,
(flags & MSG_DONTWAIT), &err);
} else {
skb = NULL;
if (atomic_read(&sk->sk_wmem_alloc) <=
2 * sk->sk_sndbuf)
skb = sock_wmalloc(sk,
alloclen + hh_len + 15, 1,
sk->sk_allocation);
prev parent reply other threads:[~2010-05-11 5:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 20:09 Question about more headroom in skb Sharat Masetty
2010-05-11 5:06 ` Eric Dumazet [this message]
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=1273554387.10889.23.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sharat_masetty@yahoo.com \
/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