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

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

  parent reply	other threads:[~2008-05-26  7:41 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 [this message]
2008-05-27 18:39   ` Stephen Hemminger

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=483A6929.6060905@openvz.org \
    --to=xemul@openvz.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen.hemminger@vyatta.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;
as well as URLs for NNTP newsgroup(s).