All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: cwang@twopensource.com
Cc: alexander.h.duyck@intel.com, amirv@mellanox.com,
	edumazet@google.com, netdev@vger.kernel.org,
	ogerlitz@mellanox.com, yevgenyp@mellanox.com, idos@mellanox.com,
	eric.dumazet@gmail.com
Subject: Re: [PATCH net-next V1 1/2] net: Header length compution function
Date: Mon, 28 Jul 2014 15:42:11 -0700 (PDT)	[thread overview]
Message-ID: <20140728.154211.834824360197491109.davem@davemloft.net> (raw)
In-Reply-To: <CAHA+R7NkWxbLM_T202o86G_0MgmpHG71jV+2_fQ3JCjZu9sw1g@mail.gmail.com>

From: Cong Wang <cwang@twopensource.com>
Date: Mon, 28 Jul 2014 14:26:08 -0700

> On Mon, Jul 28, 2014 at 7:50 AM, Alexander Duyck
> <alexander.h.duyck@intel.com> wrote:
>> On 07/28/2014 04:28 AM, Amir Vadai wrote:
>>> +u32 eth_frame_headlen(void *data, unsigned int len)
>>> +{
>>> +     const struct ethhdr *eth = data;
>>> +     struct sk_buff skb;
>>> +
>>> +     if (unlikely(len < ETH_HLEN))
>>> +             return len;
>>> +
>>> +     skb.protocol = eth->h_proto;
>>> +     skb.head = data + ETH_HLEN;
>>> +     skb.data = skb.head;
>>> +     skb_reset_network_header(&skb);
>>> +     skb.len = len - ETH_HLEN;
>>> +     skb.data_len = 0;
>>> +     return __skb_get_poff(&skb) + ETH_HLEN;
>>> +}
>>
>> I'm still not a big fan of allocating an sk_buff on the stack.  Seems
>> like it isn't maintainable and really opens things up to possible issues
>> if someone ever extends the __skb_get_poff call.  But I'm not going to
>> force the issue since for now this isn't impacting igb or ixgbe.
>>
> 
> +1
> 
> I think you can refactor the code to pass all these input as
> arguments instead of a whole skbuff.

I was going to say the same thing, but if you take a look it's not so
simple.

The code currently handles fragmented SKBs just fine, and you'd
therefore have to make a seperate code path for purely linear buffers,
and thus code duplication.

I'm still not sure what's better, to be honest.  Currently I'm leaning
towards allowing the version in this patch set, even though it's a bit
risky this is in the fast path so perhaps warrants such tricks for
performance's sake.

  reply	other threads:[~2014-07-28 22:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 11:27 [PATCH net-next V1 0/2] Helper to find length of headers in an ethernet frame Amir Vadai
2014-07-28 11:28 ` [PATCH net-next V1 1/2] net: Header length compution function Amir Vadai
2014-07-28 14:50   ` Alexander Duyck
2014-07-28 21:26     ` Cong Wang
2014-07-28 22:42       ` David Miller [this message]
2014-07-28 23:08         ` Alexander Duyck
2014-07-28 11:28 ` [PATCH net-next V1 2/2] net/mlx4_en: Copy exact header to SKB linear part Amir Vadai

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=20140728.154211.834824360197491109.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=alexander.h.duyck@intel.com \
    --cc=amirv@mellanox.com \
    --cc=cwang@twopensource.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=idos@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=yevgenyp@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.