netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Subject: Re: [GIT PULL net-next 01/17] ndisc: Fix size calculation for headers.
Date: Wed, 19 Dec 2012 12:08:22 +0900	[thread overview]
Message-ID: <50D12FA6.6040901@linux-ipv6.org> (raw)
In-Reply-To: <20121218.162338.1594192050394527214.davem@davemloft.net>

David Miller wrote:
> From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Date: Tue, 18 Dec 2012 19:52:04 +0900
> 
>> We used to allocate MAX_HEADER bytes more than needed but
>> reserved hlen only (not MAX_HEADER + hlen) and the MAX_HEADER
>> was left behind.
>>
>> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> 
> This change is wrong.
> 
> The MAX_HEADER is being used in order to accomodate any
> possible encapsulation that may occur.

As I tried to explain in the commit message, ndisc_build_skb() does tI would say his:

|        int hlen = LL_RESERVED_SPACE(dev);
:
|        skb = sock_alloc_send_skb(sk,
|                                  (MAX_HEADER + sizeof(struct ipv6hdr) +
|                                   len + hlen + tlen),
|                                  1, &err);
|        if (!skb) {
|                ND_PRINTK(0, err, "ND: %s failed to allocate an skb, err=%d\n",
|                          __func__, err);
|                return NULL;
|        }
|
|        skb_reserve(skb, hlen);

This means, MAX_HEADER has been placed at the TAIL of
the buffer, instead of the HEAD of the buffer, like this.

head        data                   tail                        end
+--------------------------------------------------------------+
+           |                      |          |                |
+--------------------------------------------------------------+
|<- hlen  ->|<---ipv6 packet------>|<--tlen-->|<--MAX_HEADER-->|
|  = LL_
     RESERVED_
     SPACE(dev)

MAX_HEADER will not be used at all and I would say it is waste of
memory.

Or do you expect something like this?

+--------------------------------------------------------------+
+                |           |                      |          |
+--------------------------------------------------------------+
|<--MAX_HEADER-->|<---hlen-->|<---ipv6 packet------>|<--tlen-->|
head                       data                   tail       end

or like this:

+--------------------------------------------------+
+                |                      |          |
+--------------------------------------------------+
|<--MAX_HEADER-->|<---ipv6 packet------>|<--tlen-->|
head           data                   tail       end

If so, we should (re)visit almost all users of
sock_alloc_send_skb() and friends, anyway, I think.

--yoshfuji

  parent reply	other threads:[~2012-12-19  3:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17 20:46 [GIT PULL net-next] NDISC Updates (sender-side clean-up) YOSHIFUJI Hideaki
2012-12-17 22:31 ` David Miller
2012-12-18 10:52 ` [GIT PULL net-next 01/17] ndisc: Fix size calculation for headers YOSHIFUJI Hideaki
2012-12-19  0:23   ` David Miller
2012-12-19  0:24     ` David Miller
2012-12-19  3:00       ` YOSHIFUJI Hideaki
2012-12-19  3:08     ` YOSHIFUJI Hideaki [this message]
2012-12-18 10:52 ` [GIT PULL net-next 02/17] ipv6: Introduce __ip6_hdr() for setting IPv6 header YOSHIFUJI Hideaki
2012-12-18 10:53 ` [GIT PULL net-next 03/17] ndisc: Introduce struct red_msg for redirect message YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 04/17] ndisc: Introduce ndisc_fill_redirect_hdr_option() YOSHIFUJI Hideaki
2012-12-19  3:08   ` YOSHIFUJI Hideaki
2012-12-19 11:47   ` Bjørn Mork
2012-12-19 16:25     ` YOSHIFUJI Hideaki
2012-12-19 17:27       ` YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 05/17] ndisc: Rename and break up __ndisc_send() YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 06/17] ndisc: Introduce ndisc_send_skb_alloc() for sk_buff allocation YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 07/17] ipv6: Move ip6_nd_hdr() to its users' source files YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 08/17] ndisc: Set skb->dev and skb->protocol inside ndisc_alloc_skb() YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 09/17] ndisc: Defer building IPv6 header YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 10/17] ndisc: Reset skb->transport_header inside ndisc_alloc_send_skb() YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 11/17] ndisc: Calculate message body length and option length separately YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 12/17] ndisc: Make ndisc_fill_xxx_option() for sk_buff YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 13/17] ndisc: Calculate checksum and build IPv6 header in __ndisc_send() YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 14/17] ndisc: Concentrate ndisc_send() on sending message YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 15/17] ndisc: Break down ndisc_build_skb() YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 16/17] ndisc: Fill in ND message on skb directly YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 17/17] ndisc: Use return value of __skb_put(), instead of icmp6_hdr() YOSHIFUJI Hideaki

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=50D12FA6.6040901@linux-ipv6.org \
    --to=yoshfuji@linux-ipv6.org \
    --cc=davem@davemloft.net \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).