From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Alexander E. Patrakov" Date: Fri, 05 Jan 2007 12:30:00 +0000 Subject: Udev sometimes forgets to RUN a program when renaming network Message-Id: <459E44C8.1080204@ums.usu.ru> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org To Marco d'Itri: this testcase may explain at least a fraction of Debian bu= g=20 #403706 (because in Debian ifup is run, essentially, from udev rules),=20 that's why the CC. Udev version is 0.100-2.3. Also reproducible with 0.103-= 1. To repeat the steps below, you need a Debian Etch installation CD, and=20 VMware Server. QEMU may be able to reproduce this too, but it is untested. 1) Create a virtual machine with two network cards. The first of them shoul= d=20 look into a custom empty virtual network (e.g., /dev/vmnet2 - the intention= =20 is to simulate a useless network card looking into nowhere). The other card= =20 should use host-only or NAT networking (the intention is that it gets its I= P=20 address via DHCP). 2) Install Debian Etch into this virtual machine from the CD. Select eth1 a= s=20 the primary network interface. Do not update the system, because this would= =20 trigger the update-initramfs script and break the testcase! (the testcase=20 relies on the fact that udev not in initramfs has to swap the two network=20 interfaces at step 6) This installation procedure creates the following files: /etc/network/interfaces: # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth1 iface eth1 inet dhcp /etc/udev/rules.d/z25_persistent-net.rules: # This file was automatically generated by the /lib/udev/write_net_rules # program, probably run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single line. # PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM=3D"net", DRIVERS=3D"?*", ATTRS{address}=3D"00:0c:29:d8:39:6e",=20 NAME=3D"eth1" # PCI device 0x1022:0x2000 (pcnet32) SUBSYSTEM=3D"net", DRIVERS=3D"?*", ATTRS{address}=3D"00:0c:29:d8:39:64",=20 NAME=3D"eth0" 3) Create the file /etc/udev/rules.d/z49_debug.rules with the following=20 contents: SUBSYSTEM=3D"net", ACTION=3D"add", RUN+=3D"/bin/sh -c 'echo FOUND NETWORK=20 INTERFACE %k >/dev/console'" 4) Reboot the system, watch how it prints that it found eth1, eth0 and lo. = So far so good. Note that the renaming rules above are not really triggered= ,=20 because these two network cards are PCI cards served by the same module. 5) Now edit /etc/network/interfaces so that it mentions eth0 instead of=20 eth1, and edit /etc/udev/rules.d/z25_persistent-net.rules by swapping eth0 = and eth1 (so that 00:0c:29:d8:39:6e becomes eth0 and 00:0c:29:d8:39:64=20 becomes eth1). The intention is, as you may have guessed, is to swap the=20 names, so that the used card becomes eth0, and the useless one is eth1. The= =20 consequence is that the renaming rules become essential. 6) Reboot. This time it prints the message: udevd-event[2669]: rename_netif: error changing net interface name=20 eth1_rename to eth0: No such device (but "ifconfig -a" shows that the 00:0c:29:d8:39:6e card does become eth0) Then it prints a message that it found eth1 and lo, and no message about=20 eth0. And of course, the network is not up, because udev forgot to run=20 net.agent for the new eth0. Bug! While it took us some special preparations to trigger this bug with two=20 identical network cards, I guess that this will happen by itself with 50%=20 probability if the network cards are not identical, due to random module=20 loading order. 7) This time, repeat step (5), using names "used" and "unused" for the two = interfaces, reboot and watch how udev finds the "used", "unused" and "lo"=20 interfaces. --=20 Alexander E. Patrakov ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=DEVD= EV _______________________________________________ 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