[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#403706: Udev sometimes forgets to RUN a program when renaming network interface

To Marco d'Itri: this testcase may explain at least a fraction of Debian bug #403706 (because in Debian ifup is run, essentially, from udev rules), 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 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 should look into a custom empty virtual network (e.g., /dev/vmnet2 - the intention is to simulate a useless network card looking into nowhere). The other card should use host-only or NAT networking (the intention is that it gets its IP address via DHCP).

2) Install Debian Etch into this virtual machine from the CD. Select eth1 as the primary network interface. Do not update the system, because this would trigger the update-initramfs script and break the testcase! (the testcase relies on the fact that udev not in initramfs has to swap the two network interfaces at step 6)

This installation procedure creates the following files:

# 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

# 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=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:d8:39:6e", NAME="eth1"

# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:d8:39:64", NAME="eth0"

3) Create the file /etc/udev/rules.d/z49_debug.rules with the following contents:

SUBSYSTEM=="net", ACTION=="add", RUN+="/bin/sh -c 'echo FOUND NETWORK 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, 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 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 becomes eth1). The intention is, as you may have guessed, is to swap the names, so that the used card becomes eth0, and the useless one is eth1. The 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 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 eth0. And of course, the network is not up, because udev forgot to run net.agent for the new eth0. Bug!

While it took us some special preparations to trigger this bug with two identical network cards, I guess that this will happen by itself with 50% probability if the network cards are not identical, due to random module 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" interfaces.

Alexander E. Patrakov

Reply to: