Thread (105 messages) 105 messages, 21 authors, 2009-11-11

Re: PATCH: Network Device Naming mechanism and policy

From: Bryan Kadzban <hidden>
Date: 2009-10-19 16:14:38

Possibly related (same subject, not in this thread)

Narendra_K@Dell.com wrote:
quoted
quoted
quoted
quoted
And how would the regular file look like in terms of holding
 ifindex of the interface, which can be passed to
libnetdevname.
I can't think of anything we need to store in the regular file.
If we have the kernel name for the device, we can look up the
ifindex in /sys. Correct me if I'm wrong, but storing it
ourselves seems redundant.
But the name of a netdev can change whereas its ifindex never
does. Identifying netdevs by name would require additional work
to update the links when a netdev is renamed and would still be
prone to race conditions.  This is why Narendra and Matt were
proposing to
store the
quoted
ifindex in the node all along...
Matt, Ben and I talked about a few other possibilities on IRC. The
one I like the most at the moment is an idea Ben had to creat dummy
files named after the ifindex. Then, use symlinks for the kernel
name and the various by-$property subdirectories. This means the
KOBJ events will need to expose the ifindex.
I suppose the KOBJ events already expose the ifindex of a network 
interface. The file "/sys/class/net/ethN/uevent" contains
INTERFACE=ethN and IFINDEX=n already. But it looks like udev doesn't
use it in any way.
Right; it could simply do the equivalent of:

touch /dev/netdev/$env{IFINDEX}

instead of its normal mknod(2), and then do normal SYMLINK processing.
That last part is what would link /dev/netdev/by-name/$env{INTERFACE} to
that device, along with /dev/netdev/by-mac/*, /dev/netdev/by-path/*,
etc., etc., in as many different ways as people want to add rules.

(Or /dev/net/by-* instead of netdev; I'm mostly ambivalent about the
first-level directory under /dev.  Looks like libnetdevname requires
/dev/netdev though.)
For example, with the kernel patch the "/sys/class/net/ethN/uevent" 
contains in addition to the above details, MAJOR=M and MINOR=m which
the udev knows how to make use of with a rule like

SUBSYSTEM=="net", KERNEL!="tun", NAME="netdev/%k", MODE="0600".
And if the only point is to get the ifindex via stat(2) on the resulting
symlinks, but people don't like device files, then why not get the
ifindex via readlink(2) (and a bit of string parsing, and a strtol(3) or
strtoul(3) call) instead?  :-)

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help