public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Daniel Turull <daniel.turull@gmail.com>
Cc: netdev@vger.kernel.org, "Voravit T." <voravit@kth.se>,
	Robert Olsson <robert@herjulf.net>
Subject: Re: [PATH] dev: reusing unregistered ifindex values in net_device
Date: Thu, 18 Nov 2010 16:37:08 +0100	[thread overview]
Message-ID: <1290094628.2781.195.camel@edumazet-laptop> (raw)
In-Reply-To: <AANLkTinx6Ww4ZwRUTyYD_STPSRsSFck8O=W5yeJSbBs_@mail.gmail.com>

Le jeudi 18 novembre 2010 à 16:25 +0100, Daniel Turull a écrit :
> When a new index is going to be assigned in register_netdevice,
> the dev_new_index starts to search possible values from the last index
> given to a device although there might be some free ifindex that has been
> previously unregistered.  This behaviour may create gap(s) in the ifindex list.
> 
> This patch checks for unused values from 1 and gives to the new device the
> first available value. This limits the maximum ifindex to a smaller value.
> 
> The ifindex will still be unique since the old value is no longer in use.
> 
> Reported-by: Voravit Tanyingyong  <voravit@kth.se>
> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
> 
> ---
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 381b8e2..a7babab 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -4871,7 +4871,7 @@ int dev_ioctl(struct net *net, unsigned int cmd,
> void __user *arg)
>   */
>  static int dev_new_index(struct net *net)
>  {
> -	static int ifindex;
> +	int ifindex;
>  	for (;;) {
>  		if (++ifindex <= 0)
>  			ifindex = 1;
> --

NACK

Two bugs 

1) ifindex is not initialized : you'll be suprised of random values

2) ifindex should not be reused. You'll be surprised so applications can
break. SNMP comes to mind.




  reply	other threads:[~2010-11-18 15:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 15:25 [PATH] dev: reusing unregistered ifindex values in net_device Daniel Turull
2010-11-18 15:37 ` Eric Dumazet [this message]
2010-11-18 15:43   ` Daniel Turull
2010-11-18 16:01   ` David Miller
2010-11-18 16:14     ` 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=1290094628.2781.195.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=daniel.turull@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=robert@herjulf.net \
    --cc=voravit@kth.se \
    /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