netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATH] dev: reusing unregistered ifindex values in net_device
@ 2010-11-18 15:25 Daniel Turull
  2010-11-18 15:37 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Turull @ 2010-11-18 15:25 UTC (permalink / raw)
  To: netdev; +Cc: Voravit T., Robert Olsson

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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-18 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 15:25 [PATH] dev: reusing unregistered ifindex values in net_device Daniel Turull
2010-11-18 15:37 ` Eric Dumazet
2010-11-18 15:43   ` Daniel Turull
2010-11-18 16:01   ` David Miller
2010-11-18 16:14     ` Stephen Hemminger

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).