All of lore.kernel.org
 help / color / mirror / Atom feed
* ifIndex allocation
@ 2006-05-16  6:11 Sven Schnelle
  2006-05-16 16:38 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Schnelle @ 2006-05-16  6:11 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

Hi List,

investigating a problem with an snmp software for linux, i was wondering
why the kernel allocates a new ifindex Number, even if the old one is still
available. For example, if i unload a network driver module, and reload
it, it has a different ifindex.

Looking at the function dev_new_index (line 2620 in net/core/dev.c)
there is a line 'static int ifindex'. Is there any special reason why
this variable is static, and the list is not traversed from the
beginning, so that the first free ifindex will be used?


Best regards,

Sven.

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

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

* Re: ifIndex allocation
  2006-05-16  6:11 ifIndex allocation Sven Schnelle
@ 2006-05-16 16:38 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2006-05-16 16:38 UTC (permalink / raw)
  To: Sven Schnelle; +Cc: netdev

On Tue, 16 May 2006 08:11:01 +0200
"Sven Schnelle" <svens@gmx.de> wrote:

> Hi List,

Redirecting to netdev

> 
> investigating a problem with an snmp software for linux, i was wondering
> why the kernel allocates a new ifindex Number, even if the old one is still
> available. For example, if i unload a network driver module, and reload
> it, it has a different ifindex.

Because when you reload the driver it is effectively a completely new
object.  ifindex is a basically and object id. Ifindices act as soft
references so user space can know about a particular network device
even if name changes or other operations happen.  The reference is soft
because the device can disappear. If the application wants to know about
device removal it can catch the netlink event.


> Looking at the function dev_new_index (line 2620 in net/core/dev.c)
> there is a line 'static int ifindex'. Is there any special reason why
> this variable is static, and the list is not traversed from the
> beginning, so that the first free ifindex will be used?
> 
> 
> Best regards,
> 
> Sven.

It is static because no other code should be looking at it.
It doesn't retraverse from the start because it doesn't want to reuse
an earlier index and confuse an application with a soft reference.

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

end of thread, other threads:[~2006-05-16 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-16  6:11 ifIndex allocation Sven Schnelle
2006-05-16 16:38 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.