From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Borzenkov Date: Sun, 09 Apr 2006 18:00:49 +0000 Subject: Re: net interface renaming issue (+fix?) Message-Id: <200604092200.51452.arvidjaar@mail.ru> List-Id: References: <20060409192140.73644723@eusebe> In-Reply-To: <20060409192140.73644723@eusebe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 09 April 2006 21:21, Thomas de Grenier de Latour wrote: > Hi, > > I'm running Gentoo Linux, a 2.6.16-ck kernel, and udev-0.89-r2, and > have had hard time with network interfaces renaming through udev > rules. The first thing i've tried were rules like this one: > > SUBSYSTEM="net", KERNEL="eth*", SYSFS{address}="00:0d:60:12:75:0a", > NAME="lan" > > Plus this one from the standard early rules: > > ACTION="add", SUBSYSTEM="net", WAIT_FOR_SYSFS="address" > > It doesn't work when i "modprobe e1000" (my ethernet driver): > .... > udevd[21612]: udev_event_run: seq 956 forked, pid [21816], 'add' 'net', 0 > seconds old udevd-event[21816]: wait_for_sysfs: file > '/sys/class/net/eth0/address' appeared after 0 loops udevd-event[21816]: > udev_rules_get_name: no node name set, will use kernel name 'eth0' .... > But if i later do a "echo add > /sys/class/net/eth0/uevent", then > interface is properly renamed. It also works fine if i start with > the module initialy not loaded, and then trigger the uevent on the > corresponding pci device (will load the module, etc.) > There appears to be race between creating 'address' and getting (usable) value. See below. [...] > > So i wonder, maybe such a rule should be added to the standard early > ones? It should maybe use more checks though, to be sure there is > actually a driver to wait. Something like ENV{PHYSDEVPATH}="?*" > and/or ENV{PHYSDEVDRIVER}="?*". > You probably get reply that they are obsolete and should not be used in new rules :) [...] > Or is "address" being added to sysfs with no useful value yet the real > issue, and my rule only an ugly workround? > Seems so. net/core/net-syfs.c:dev_isalive(): return dev->reg_state = NETREG_REGISTERED; net/core/net-syfs.c:show_address(): if (dev_isalive(net)) ret = format_addr(buf, net->dev_addr, net->addr_len); net/core/dev.c:netdev_run_todo(): err = netdev_register_sysfs(dev); if (err) printk(KERN_ERR "%s: failed sysfs registration (%d)\n", dev->name, err); dev->reg_state = NETREG_REGISTERED; break; So basically there is a window between net device appearing in sysfs and 'address' returning usable value. To test you could move dev->reg_state assignment before netdev_register_sysfs call; if this helps it makes sense ask on net list if this is safe change. - -andrey -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFEOUvTR6LMutpd94wRAg+nAKCXnI9mrChpQ9TAz4VVQhSaP/MQjgCfbX6n 5lcJ30K1qpTtbxISei6pN9I=Rwsc -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel