netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] devinet: sysctl setup off by one
Date: Tue, 27 May 2008 11:39:00 -0700	[thread overview]
Message-ID: <20080527113900.3039baa1@speedy> (raw)
In-Reply-To: <483A6929.6060905@openvz.org>

On Mon, 26 May 2008 11:39:21 +0400
Pavel Emelyanov <xemul@openvz.org> wrote:

> Stephen Hemminger wrote:
> > It look like the code to setup /proc/sys/net/ipv4/conf/XXX has an off by one bug
> > that causes the last entry (arp_accept) not to be adjusted properly.  This causes
> > changes to the value to occur in the default namespace not the clone? Don't use
> > network namespaces myself, but this looks like a bug.
> > 
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> > 
> > --- a/net/ipv4/devinet.c	2008-05-23 15:23:19.000000000 -0700
> > +++ b/net/ipv4/devinet.c	2008-05-23 15:29:17.000000000 -0700
> > @@ -1466,7 +1466,7 @@ static int __devinet_sysctl_register(str
> >  	if (!t)
> >  		goto out;
> >  
> > -	for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
> > +	for (i = 0; i < ARRAY_SIZE(t->devinet_vars); i++) {
> >  		t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
> >  		t->devinet_vars[i].extra1 = p;
> >  		t->devinet_vars[i].extra2 = net;
> > 
> 
> This off-by-one is required, since the very last element of this array
> is used as a sentinel, that shows sysctl engine when to stop processing 
> the table.
> 
> Look, the sizeof(t->devinet_vars) is __NET_IPV4_CONF_MAX == 22, thus
> entries 0, 1, ... 20 are tables and the 21-st is this sentinel, so the
> initialization of this last entry, whose index is (this_sizeof() - 1),
> is not required.
> 
> Thanks,
> Pavel

okay, so that means there is one extra entry in the vars than needed? which
is harmless.

      reply	other threads:[~2008-05-27 18:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080523153559.156a1fb5@speedy>
2008-05-26  5:51 ` [PATCH] devinet: sysctl setup off by one David Miller
2008-05-26  7:39 ` Pavel Emelyanov
2008-05-27 18:39   ` Stephen Hemminger [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=20080527113900.3039baa1@speedy \
    --to=stephen.hemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@openvz.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).