From: Daniel Turull <daniel.turull@gmail.com>
To: netdev@vger.kernel.org
Cc: "Voravit T." <voravit@kth.se>, Robert Olsson <robert@herjulf.net>
Subject: [PATH] dev: reusing unregistered ifindex values in net_device
Date: Thu, 18 Nov 2010 16:25:54 +0100 [thread overview]
Message-ID: <AANLkTinx6Ww4ZwRUTyYD_STPSRsSFck8O=W5yeJSbBs_@mail.gmail.com> (raw)
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;
next reply other threads:[~2010-11-18 15:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-18 15:25 Daniel Turull [this message]
2010-11-18 15:37 ` [PATH] dev: reusing unregistered ifindex values in net_device Eric Dumazet
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='AANLkTinx6Ww4ZwRUTyYD_STPSRsSFck8O=W5yeJSbBs_@mail.gmail.com' \
--to=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;
as well as URLs for NNTP newsgroup(s).