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

udevd and persistent network rules for USB NICs



Hi,

I have a device with several internal mini PCIe card slots usable
for PCI Express mini modem cards (UMTS, LTE...). These cards
normally are USB cards and get some ethX device name assigned by
Linux, which I don't like. Instead, they should get another name,
for example usb-ethX.

Is it possible to write a udev rule that renames *multiple* eth
devices to usb-eth devices?

The obvious attempt to use something like:

  SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="eth*",
  ....more matching condtions....
  NAME="usb-eth%n"

does not work. The kernel assignes a free eth name, let's say
eth4, udevd renames it via a temporary sequence name, let's say
rename23, to usb-eth4. eth4 is free again.
The second device gets eth4 assigned by kernel, udevd renames it
via a temporary sequence name, let's say rename24 and then
(probably) fails to rename to usb-eth4, because this name already
exists. The result is that the device is called rename24.

This is not the biggest problem. When booting a Debian 7.5
configured with such rules, the initrd (?) hangs at boot after
printing "populating /dev" - presumably because it waits for
renameXX be renamed correctly, which never happens.

Unfortunately there is no udev directive like "%n" but not using
the kernel number but using the next free or any free number.

What so far works best is to manually assign names to the mPCIe
slots, in form of having some 99-persistent-overwrite-all.rules:

  SUBSYSTEM=="net", ACTION=="add",
  DEVPATH=="/devices/pci0000:00/*/usb1/1-2*/net/*",
  NAME="usb-eth1"

because each mPCIe has a distinct DEVPATH.

As a side effect, interestingly an entry is made in
70-persistent-net.rules, which is fortunately overwritten by my
99-persistent-overwrite-all.rules file and thus has no effect.

Now, when it comes to USB pluggable NICs, I could of course use a
similar rule for the DEVPATH of the USB plug, but as soon as an
USB hub with two NICs is connected, the rename24 situation
occures and plugging before power on, it hangs at "populating /dev".

NB: Interestingly, it works when not using any USB rule for the
    USB plugs DEVPATHs. The kernel assignes e.g. eth4, and
    althrough there is no eth4, udev renames it to eth5. I guess
    that could be because the rule generator generates a rule for
    it, uses eth5 which is according to the rules file is the
    next free (as it is the default behavior when not having any
    own rules).

How to use udev to rename devices without risking hanging boot?

Any help, hints or pointers appreciated!

Steffen


Reply to: