Opened 19 years ago

Closed 19 years ago

#1672 closed defect (fixed)

Network card order becomes random when hotplug is removed

Reported by: alexander@… Owned by: Matthew Burgess
Priority: highest Milestone: 6.2
Component: Book Version: udev_update
Severity: major Keywords:
Cc:

Description (last modified by Jeremy Huntwork)

This is a duplicate of http://bugs.debian.org/339951, reported even though hotplug is not removed from the LFS book yet.

To reproduce:

  1. buy two network cards of different brands
  2. compile both drivers as modules in linux-2.6.15-rc6
  3. upgrade udev to 078 with all extras enabled, remove hotplug
  4. Replace the mountkernfs and udev initscripts with the attached ones
  5. Add to udev rules:
    SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware_helper"
    ACTION=="add", MODAILAS=="?*", RUN+="/sbin/modprobe $modalias"
    
  6. Configure some static IP addresses on eth0 and eth1 as the book says
  7. Reboot several times and watch which address is assined to which card. The results may not be stable.

This bug was not visible with hotplug, since it (unlike udev) doesn't run many "modprobe" commands in parallel.

Upstream reaction: WONTFIX, please create udev rules that assign stable interface names based on e.g. MAC addresses or bus positions. It is also a good idea to bring interfaces up from udev rules, this will catch the currently-unhandled "I need to be root to connect to my Sharp Zaurus" annoyance. But please also be careful with firewalling.

This, obviously, applies not only to network cards, but to any device type (e.g. you can also reproduce this numbering instability with two sound cards of different brands).

Attachments (2)

mountkernfs (992 bytes ) - added by alexander@… 19 years ago.
Updated mountkernfs script
udev (2.3 KB ) - added by alexander@… 19 years ago.
Updated udev initscript

Download all attachments as: .zip

Change History (14)

by alexander@…, 19 years ago

Attachment: mountkernfs added

Updated mountkernfs script

comment:1 by alexander@…, 19 years ago

attachments.mimetype: application/octet-streamtext/plain

comment:2 by alexander@…, 19 years ago

attachments.description: Updated mountkenfs scriptUpdated mountkernfs script

by alexander@…, 19 years ago

Attachment: udev added

Updated udev initscript

comment:3 by alexander@…, 19 years ago

Forgot to say that you also have to populate /lib/udev/devices before rebooting:

ln -s /proc/self/fd /lib/udev/devices/fd ln -s /proc/self/fd/0 /lib/udev/devices/stdin ln -s /proc/self/fd/1 /lib/udev/devices/stdout ln -s /proc/self/fd/2 /lib/udev/devices/stderr ln -s /proc/kcore /lib/udev/devices/core mkdir /lib/udev/devices/pts mkdir /lib/udev/devices/shm

comment:4 by alexander@…, 19 years ago

See also http://bugs.debian.org/343659

This minimal udev setup should be explained in the book.

comment:5 by Matthew Burgess, 19 years ago

Summary: Nework card order becomes random when hotplug is removedNetwork card order becomes random when hotplug is removed

Thanks for the report, Alexander.

From that bug report it looks like adding

ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"

to the rules file will fix this (for the NIC variation of this problem anyway), and this reminds me of reading something similar on the linux-hotplug-devel list recently too. Presumably 'SUBSYSTEM=="snd"' will fix soundcards...is 'SUBSYSTEM=="*"' overkill? Will it do what I think it will (i.e. fix this bug for all subsystems), or is it likely to break something else?

Once 2.6.15 is out, I'll be making the changes previously mentioned on lfs-dev and in this bug. We probably won't catch all the bugs in one go, but I'm confident it will be usable for the vast majority of folks almost immediately. The explanations will be woefully inadequate, but I'll endeavour to see them addressed as quickly as possible.

comment:6 by alexander@…, 19 years ago

ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"

No that won't remove the problem. You have to explicitly rename the interfaces and _never_ use the "eth0" and "eth1" names.

comment:7 by alexander@…, 19 years ago

To clarify and summarize:

1) Unconfigured system with hotplug removed and udev upgraded, and with 8139too and e100 network cards, both drivers as modules:

sometimes e100 gets eth0 and 8139too gets eth1, sometimes the other way round. That's because the module loading order is unpredictable. Attempts to rename cards to some stable names using rules like:

SUBSYSTEM=="net", SYSFS{address}=="00:11:22:33:44:55", NAME="homenet"

sometimes work (i.e. the new "homenet" name gets applied to this card) and sometimes fail (i.e. the original "eth0" or "eth1" name sticks).

2) Same system with this rule:

ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"

The 8139too sometimes gets eth0 and sometimes eth1. The same holds for e100. But, a stable name can now be _reliably_ assigned by rules like:

SUBSYSTEM=="net", SYSFS{address}=="00:11:22:33:44:55", NAME="homenet" SUBSYSTEM=="net", SYSFS{address}=="00:ff:ee:dd:cc:bb", NAME="internet"

3) Same system with all three rules.

One card always gets the "homenet" name, and the other card is "internet". One can assign IPs by creating /etc/sysconfig/network-devices/ifconfig.{home,inter}net (instead of ifconfig.eth{0,1}) as the book says.

The module loading order is still unpredictable, but it doesn't matter now.

Proposed changes to the book: upgrade udev and the kernel, remove hotplug, explain how to blacklist unwanted modules in /etc/modprobe.conf, explain how to (and why) rename network interfaces. In the far future, handle network hotplug events so that a Zaurus gets assigned an IP just after it is connected to a USB port.

comment:8 by nathan@…, 19 years ago

Small Change, I want to keep the mounting of /tmp within udev.

comment:9 by Jeremy Huntwork, 19 years ago

Description: modified (diff)
Milestone: 6.2

Formatting of original description and marking for 6.2

comment:10 by Matthew Burgess, 19 years ago

Owner: changed from lfs-book@… to Matthew Burgess
Status: newassigned
Version: SVNudev_update

comment:11 by Matthew Burgess, 19 years ago

How close are we to closing this one. I've a feeling that the chapter07/udev.xml changes that went into r7413 are enough. Alexander, could you confirm please?

comment:12 by alexander@…, 19 years ago

Resolution: fixed
Status: assignedclosed

They should be enough, but, since I don't actually have two network cards, I can't confirm anything except that the rule works for a single card.

Note: See TracTickets for help on using tickets.