rennefj
Posts: 5
Joined: Thu Aug 24, 2017 8:03 pm

Stretch | Not able to rename network interfaces any more

Thu Aug 24, 2017 8:34 pm

Hi,
after updating to stretch on my Model B renaming my network interfaces is no longer working.
I know that with stretch the Predictable Network Interface Names feature gets enabled, so I am thinking this might have something to do with that. https://www.freedesktop.org/wiki/Softwa ... faceNames/
I have 3 network interfaces, the internal interface and two USB Ethernet interfaces connected to the USB ports.
In Jessie I was using .link files in /etc/systemd/network/ folder to rename the interfaces using the MAC addresse with [Match| and [Link] rules.
This was the only modification and was working fine.
However in stretch that does not work anymore.
I tried updating via apt-get dist-upgrade and also by flashing a fresh stretch image to the SD card.

I have tried everything I can think of:
- Using udevadm info /sys/class/net/eth0 shows that the link file is recognized in ID_NET_LINK_FILE
- I tried to mask the default rules files in /lib/udev/rules.d/ 73-usb-net-by-mac.rules and/or 80-net-setup-link.rules
- I tried to rename the interfaces by providing my own rules file in /etc/udev/rules.d/

Nothing seems to work.
One strange thing that I noticed, the internal interface get renamed with stretch to enxMAC, however the external USB interfaces don't get renamed they stay at eth1 and eth2 even on a fresh install with a stretch disk image. Shouldn't all interfaces get renamed automatically?

Any Ideas?
What I don't know is if I need to update the initrd after any change? I did not need to update it in jessie when adding the .link files there.

RichHaynes
Posts: 44
Joined: Sat Jul 16, 2016 12:23 pm
Location: Stoke-On-Trent

Re: Stretch | Not able to rename network interfaces any more

Fri Aug 25, 2017 5:52 pm

My first thoughts are that the default link file is being applied first:
The first (in lexical order) of the link files that matches a given device is applied. Note that a default file 99-default.link is shipped by the system, any user-supplied .link should hence have a lexically earlier name to be considered at all. https://www.freedesktop.org/software/sy ... escription

I ran in to this issue because "the first of the link files that matches a given device is applied" which meant that even though my two link files (eth0.link and wlan0.link) specifically targeted the MAC address of the devices, the letters "e" and "w" are lexically after the number 9 so the default link file applied and my custom link files were discarded.

Renaming my files 50-eth0.link and 50-wlan0.link fixed it for me. It was slightly frustrating because ive never encountered the lexical ordering in systemd before but since it is inherently linked to udev it kind of makes sense.

Double check you filenames and let me know how you get on.
Main Computer: RPi3
BOINC Server: RPi2
Torrent Box: RPi2 + 2TB WD Green HDD via USB Dock
Web + Email Server: RPi2
Home Automation Server: RPi2 + Edimax EW-7811Un
Decomissioned: 2 x RPi Model B

User avatar
elkberry
Posts: 167
Joined: Wed Dec 28, 2016 9:21 pm

Re: Stretch | Not able to rename network interfaces any more

Fri Aug 25, 2017 7:01 pm

I've found out after a long investigation, see also https://askubuntu.com/q/947519/723098. Someone enabled MAC-based naming with priority in Raspbian without giving much thought to what the kind of hell she or he is going to let loose. Luckily, there's a fix: the impatient reader can skip right to the bottom. The following is an explanation of what went wrong and what the solution is.

Why renaming USB-based network interfaces doesn't work is actually caused by the udev rule /lib/udev/rules.d/73-usb-net-by-mac.rules on Ubuntu/Debian (and thus also Raspbian). The culprit in it is here:

Code: Select all

ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb", NAME=="", \
  ATTR{address}=="?[014589cd]:*", \
  TEST!="/etc/udev/rules.d/80-net-setup-link.rules", \
  TEST!="/etc/systemd/network/99-default.link", \
    IMPORT{builtin}="net_id", NAME="$env{ID_NET_NAME_MAC}"
Notice how this specific rule checks for /etc/udev/rules.d/80-net-setup-link.rules to be present; if it's not, then NAME will be set to a MAC48-based name, and the later default install rule /lib/udev/rules.d/80-net-setup-link.rules will never get a chance to assign NAME. Now that's sad. Again.

In order to enable the ability to assign user-defined names to USB network interfaces, we need to have /etc/udev/rules.d/80-net-setup-link.rules, as this is the rule set 73-usb-net-by-mac.rules checks against before assigning NAME.

This means that simply linking from /etc/udev/rules.d/80-net-setup-link.rules to /lib/udev/rules.d/80-net-setup-link.rules is needed in order to avoid that user-assigned network interface names get ignored any longer.

Code: Select all

sudo ln -s /lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/80-net-setup-link.rules
Reboot. Done.
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

rennefj
Posts: 5
Joined: Thu Aug 24, 2017 8:03 pm

Re: Stretch | Not able to rename network interfaces any more

Sat Aug 26, 2017 6:28 pm

Regarding RichHaynes reply:
I am aware about the (lexical) order in which the link files are applied.
My file is called 11-test.link
I can verify that it gets applied:

Code: Select all

udevadm info /sys/class/net/eth0
E: ID_NET_LINK_FILE=/etc/systemd/network/11-test.link
E: ID_NET_NAME_MAC=enxb123445678
E: INTERFACE=eth0
E: SUBSYSTEM=net
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth0
E: TAGS=:systemd:
E: USEC_INITIALIZED=14126278
But the device is still not renamed.

Regarding elkberry's reply:
I had stumbled upon the mentioned post on askubuntu.com as well.
I have tried that solution, but still after creating the symlink for 80-net-setup-link.rules the devices don't get renamed.

There is one strange thing that I noticed:
I have three network interfaces connected to the Pi.
One is the internal NIC (which is also a bridge chip connected to USB) and two external USB to Ethernet adapters.
When I boot a fresh stretch image (which has the predictable names enabled) only the internal interface gets a predictable name of
enx123456789
the other two interface are not renamed and are still eth1 and eth2.
This is strange, I would expect all interfaces to get the predictable names.

I also tried to opt out of the predicable names by adding the net.ifnames=0 to the boot cmdline. This also did not help.

User avatar
elkberry
Posts: 167
Joined: Wed Dec 28, 2016 9:21 pm

Re: Stretch | Not able to rename network interfaces any more

Sat Aug 26, 2017 7:33 pm

Can you try to run "sudo udevadm test /sys/class/net/..." to see what rules udev takes into consideration? This is a fry-run and should give be a fairly lenghty report, from which you can diagnose the order of rules. It was only this that allowed me to find the 73-usb-net-by-mac.rules culprit.

And yes, that's strange, as all USB-based devices should get the MAC48-based names; at least that happened on my Stretch test install on a 3B with an additional Ethernet USB adapter.

Stretch seems to be a complete mess, network-wise.
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

rennefj
Posts: 5
Joined: Thu Aug 24, 2017 8:03 pm

Re: Stretch | Not able to rename network interfaces any more

Sun Aug 27, 2017 11:07 am

The udevadm test command was a good idea. Something is failing due to permission issues.
Currently I have the configuration as suggested in the askubuntu forum. Symlink for the 80-net-setup-link.rules to /etc/udev/rules.d
Here is an excerpt from the command output for eth0 and eth2:

Code: Select all

udevadm test /sys/class/net/eth0
calling: test
version 232
...
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/11-test.link
Parsed configuration file /etc/systemd/network/10-external.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Skipping overridden file: /lib/udev/rules.d/80-net-setup-link.rules.
...
Reading rules file: /etc/udev/rules.d/80-net-setup-link.rules
...
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'usb_id' /lib/udev/rules.d/75-net-description.rules:8
/sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0: if_class 255 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:8
RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
IMPORT builtin 'path_id' /etc/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /etc/udev/rules.d/80-net-setup-link.rules:9
Config file /etc/systemd/network/11-test.link applies to device eth0
link_config: could not set ethtool features for eth0
Could not set offload features of eth0: Operation not permitted
Could not set Alias, MACAddress or MTU on eth0: Operation not permitted
Could not apply link config to eth0: Operation not permitted
IMPORT builtin 'net_setup_link' returned non-zero

Code: Select all

udevadm test /sys/class/net/eth2
calling: test
version 232
...
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/11-test.link
Parsed configuration file /etc/systemd/network/10-external.link
Skipping overridden file: /lib/udev/rules.d/80-net-setup-link.rules.
Reading rules file: /etc/udev/rules.d/80-net-setup-link.rules
...
Config file /etc/systemd/network/10-external.link applies to device eth2
link_config: could not set ethtool features for eth2
Could not set offload features of eth2: Operation not permitted
NAME 'external-nic' /etc/udev/rules.d/80-net-setup-link.rules:11
RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:56
error changing net interface name 'eth2' to 'external-nic': Operation not permitted
could not rename interface '4' from 'eth2' to 'external-nic': Operation not permitted
...
So now there is the question why do I get these "Operation not permitted" errors?

DirkS
Posts: 9871
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Stretch | Not able to rename network interfaces any more

Sun Aug 27, 2017 11:11 am

rennefj wrote:
Sun Aug 27, 2017 11:07 am
So now there is the question why do I get these "Operation not permitted" errors?
Did you run udevadm as root (as @elkberry indicated)

rennefj
Posts: 5
Joined: Thu Aug 24, 2017 8:03 pm

Re: Stretch | Not able to rename network interfaces any more

Sun Aug 27, 2017 11:33 am

Did you run udevadm as root (as @elkberry indicated)
Good point, of course if forgot. Sorry about that.

Here is the output for eth0 and eth2 with sudo.

Code: Select all

sudo udevadm test /sys/class/net/eth0
calling: test
version 232
...
Found container virtualization none
timestamp of '/etc/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/11-test.link
Parsed configuration file /etc/systemd/network/10-external.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Skipping overridden file: /lib/udev/rules.d/80-net-setup-link.rules.
...
Reading rules file: /lib/udev/rules.d/73-usb-net-by-mac.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-ifupdown.rules
Reading rules file: /etc/udev/rules.d/80-net-setup-link.rules
...
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'usb_id' /lib/udev/rules.d/75-net-description.rules:8
/sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0: if_class 255 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:8
RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
IMPORT builtin 'path_id' /etc/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /etc/udev/rules.d/80-net-setup-link.rules:9
Config file /etc/systemd/network/11-test.link applies to device eth0
RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:56
created db file '/run/udev/data/n2' for '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0'
ACTION=add
DEVPATH=/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0
ID_BUS=usb
ID_MODEL=ec00
ID_MODEL_ENC=ec00
ID_MODEL_FROM_DATABASE=SMSC9512/9514 Fast Ethernet Adapter
ID_MODEL_ID=ec00
ID_NET_DRIVER=smsc95xx
ID_NET_LINK_FILE=/etc/systemd/network/11-test.link
ID_NET_NAME_MAC=enxb827eb1e9bc8
ID_OUI_FROM_DATABASE=Raspberry Pi Foundation
ID_PATH=platform-20980000.usb-usb-0:1.1:1.0
ID_PATH_TAG=platform-20980000_usb-usb-0_1_1_1_0
ID_REVISION=0200
ID_SERIAL=0424_ec00
ID_TYPE=generic
ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
ID_USB_DRIVER=smsc95xx
ID_USB_INTERFACES=:ff00ff:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=0424
ID_VENDOR_ENC=0424
ID_VENDOR_FROM_DATABASE=Standard Microsystems Corp.
ID_VENDOR_ID=0424
IFINDEX=2
INTERFACE=eth0
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth0
TAGS=:systemd:
USEC_INITIALIZED=13547645
run: 'ifupdown-hotplug'
run: '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/eth0 --prefix=/net/ipv4/neigh/eth0 --prefix=/net/ipv6/conf/eth0 --prefix=/net/ipv6/neigh/eth0'
Unload module index
Unloaded link configuration context.

Code: Select all

sudo udevadm test /sys/class/net/eth2
calling: test
version 232
...
Found container virtualization none
timestamp of '/etc/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/11-test.link
Parsed configuration file /etc/systemd/network/10-external.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Skipping overridden file: /lib/udev/rules.d/80-net-setup-link.rules.
...
Reading rules file: /etc/udev/rules.d/80-net-setup-link.rules
...
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'usb_id' /lib/udev/rules.d/75-net-description.rules:8
/sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0: if_class 255 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:8
RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
IMPORT builtin 'path_id' /etc/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /etc/udev/rules.d/80-net-setup-link.rules:9
Config file /etc/systemd/network/10-external.link applies to device eth2
NAME 'external-nic' /etc/udev/rules.d/80-net-setup-link.rules:11
RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:56
error changing net interface name 'eth2' to 'external-nic': Device or resource busy
could not rename interface '4' from 'eth2' to 'external-nic': Device or resource busy
created db file '/run/udev/data/n4' for '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/net/eth2'
ACTION=add
DEVPATH=/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/net/eth2
ID_BUS=usb
ID_MODEL=AX88772C
ID_MODEL_ENC=AX88772C
ID_MODEL_FROM_DATABASE=AX88772B
ID_MODEL_ID=772b
ID_NET_DRIVER=asix
ID_NET_LINK_FILE=/etc/systemd/network/10-external.link
ID_NET_NAME=external-nic
ID_NET_NAME_MAC=enx000ec6f8e7e9
ID_OUI_FROM_DATABASE=ASIX ELECTRONICS CORP.
ID_PATH=platform-20980000.usb-usb-0:1.2:1.0
ID_PATH_TAG=platform-20980000_usb-usb-0_1_2_1_0
ID_REVISION=0002
ID_SERIAL=ASIX_Elec._Corp._AX88772C_000001
ID_SERIAL_SHORT=000001
ID_TYPE=generic
ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
ID_USB_DRIVER=asix
ID_USB_INTERFACES=:ffff00:
ID_USB_INTERFACE_NUM=00
ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
ID_VENDOR=ASIX_Elec._Corp.
ID_VENDOR_ENC=ASIX\x20Elec.\x20Corp.
ID_VENDOR_FROM_DATABASE=ASIX Electronics Corp.
ID_VENDOR_ID=0b95
IFINDEX=4
INTERFACE=eth2
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/external-nic
TAGS=:systemd:
USEC_INITIALIZED=18058959
run: 'ifupdown-hotplug'
run: '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/external-nic --prefix=/net/ipv4/neigh/external-nic --prefix=/net/ipv6/conf/external-nic --prefix=/net/ipv6/neigh/external-nic'
Unload module index
Unloaded link configuration context.
OK, now I see two different things.
For the internal interface, it finds the matching 11-test.link file. But it seems there is no attempt to rename the device based on that rule.
For the eth2 interface, it also finds the matching 10-external.link file. It tries to rename it and gets the "Device or resource busy" error.

I checked the boot logs with sudo journalctl.
And I see the same error message for eth2 during boot an not attempt to rename eth0.
I still don't understand why the devices are treated so differently despite the same configuration.
Yes, eth2 is up and eth0 not, but I should at least try to rename both interfaces.

raisOr
Posts: 1
Joined: Sun Aug 27, 2017 12:00 pm

Re: Stretch | Not able to rename network interfaces any more

Sun Aug 27, 2017 12:32 pm

I can confirm the issues with interface names in stretch.
I have run a couple of tests and I documented them below

image: 2017-08-16-raspbian-stretch-lite.img
setup: copied image onto sd card, added "ssh" and "wpa_supplicant.conf" files to /boot
hardware: raspberry pi zero v1.3 (with a UUGear ZERO4U 4-Port USB Hub board strapped to its back)
usb devices: USB wifi dongle

initial boot (after writing image to sd card)

Code: Select all

root@raspberrypi:/home/pi# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 3  bytes 240 (240.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 240 (240.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlxaabbccddeeff: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xxx.xxx  netmask 255.255.255.0  broadcast 192.168.xxx.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        inet6 xxxx:xx:xxxx:xxxx:xxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x0<global>
        ether aa:bb:cc:dd:ee:ff  txqueuelen 1000  (Ethernet)
        RX packets 152  bytes 20982 (20.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 123  bytes 20862 (20.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
running
root@raspberrypi:/home/pi# udevadm test /sys/class/net/wlxaabbccddeeff
gives

Code: Select all

calling: test
version 232
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          232
file size:         8574469 bytes
header size             80 bytes
strings            1848133 bytes
nodes              6726256 bytes
Load module index
Found container virtualization none
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /lib/udev/rules.d/10-local-rpi.rules
Reading rules file: /lib/udev/rules.d/15-i2c-modprobe.rules
Reading rules file: /lib/udev/rules.d/15-rfkill.rules
Reading rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /lib/udev/rules.d/50-firmware.rules
Reading rules file: /lib/udev/rules.d/50-udev-default.rules
Reading rules file: /lib/udev/rules.d/55-dm.rules
Reading rules file: /lib/udev/rules.d/60-block.rules
Reading rules file: /lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib/udev/rules.d/60-crda.rules
Reading rules file: /lib/udev/rules.d/60-drm.rules
Reading rules file: /lib/udev/rules.d/60-evdev.rules
Reading rules file: /lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib/udev/rules.d/60-serial.rules
Reading rules file: /lib/udev/rules.d/60-triggerhappy.rules
Reading rules file: /lib/udev/rules.d/64-btrfs.rules
Reading rules file: /lib/udev/rules.d/69-libmtp.rules
Reading rules file: /lib/udev/rules.d/70-debian-uaccess.rules
Reading rules file: /lib/udev/rules.d/70-mouse.rules
Reading rules file: /lib/udev/rules.d/70-power-switch.rules
Reading rules file: /lib/udev/rules.d/70-touchpad.rules
Reading rules file: /lib/udev/rules.d/70-uaccess.rules
Reading rules file: /lib/udev/rules.d/71-seat.rules
Reading rules file: /lib/udev/rules.d/73-seat-late.rules
Reading rules file: /lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /lib/udev/rules.d/73-usb-net-by-mac.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-ifupdown.rules
Reading rules file: /lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /lib/udev/rules.d/85-hwclock.rules
Reading rules file: /lib/udev/rules.d/85-regulatory.rules
Reading rules file: /lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /lib/udev/rules.d/90-console-setup.rules
Reading rules file: /lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /etc/udev/rules.d/99-com.rules
Reading rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 196608 bytes tokens (16384 * 12 bytes), 20956 bytes strings
13900 strings (113087 bytes), 11773 de-duplicated (94259 bytes), 2128 trie nodes used
IMPORT builtin 'net_id' /lib/udev/rules.d/73-usb-net-by-mac.rules:13
NAME 'wlxaabbccddeeff' /lib/udev/rules.d/73-usb-net-by-mac.rules:13
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'usb_id' /lib/udev/rules.d/75-net-description.rules:8
/sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0: if_class 255 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:8
RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
IMPORT builtin 'path_id' /lib/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /lib/udev/rules.d/80-net-setup-link.rules:9
Config file /lib/systemd/network/99-default.link applies to device wlxaabbccddeeff
RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:56
created db file '/run/udev/data/n2' for '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/net/wlxaabbccddeeff'
ACTION=add
DEVPATH=/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/net/wlxaabbccddeeff
DEVTYPE=wlan
ID_BUS=usb
ID_MODEL=802.11_n_WLAN
ID_MODEL_ENC=802.11\x20n\x20WLAN
ID_MODEL_FROM_DATABASE=RT5572 Wireless Adapter
ID_MODEL_ID=5572
ID_NET_DRIVER=rt2800usb
ID_NET_LINK_FILE=/lib/systemd/network/99-default.link
ID_NET_NAME_MAC=wlxaabbccddeeff
ID_OUI_FROM_DATABASE=MTN Electronic Co. Ltd
ID_PATH=platform-20980000.usb-usb-0:1.4:1.0
ID_PATH_TAG=platform-20980000_usb-usb-0_1_4_1_0
ID_REVISION=0101
ID_SERIAL=Ralink_802.11_n_WLAN_1.0
ID_SERIAL_SHORT=1.0
ID_TYPE=generic
ID_USB_DRIVER=rt2800usb
ID_USB_INTERFACES=:ffffff:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Ralink
ID_VENDOR_ENC=Ralink
ID_VENDOR_FROM_DATABASE=Ralink Technology, Corp.
ID_VENDOR_ID=148f
IFINDEX=2
INTERFACE=wlxaabbccddeeff
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlxaabbccddeeff
TAGS=:systemd:
USEC_INITIALIZED=17591709
run: 'ifupdown-hotplug'
run: '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/wlxaabbccddeeff --prefix=/net/ipv4/neigh/wlxaabbccddeeff --prefix=/net/ipv6/conf/wlxaabbccddeeff --prefix=/net/ipv6/neigh/wlxaabbccddeeff'
Unload module index
Unloaded link configuration context.
After rebooting (via issuing the "reboot" command)

Code: Select all

root@raspberrypi:/home/pi# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xx.xxx  netmask 255.255.255.0  broadcast 192.168.xxx.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        inet6 xxxx:xx:xxxx:xxxx:xxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x0<global>
        ether aa:bb:cc:dd:ee:ff  txqueuelen 1000  (Ethernet)
        RX packets 165  bytes 21205 (20.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 135  bytes 23193 (22.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
suddenly the interface gets named "wlan0" and running
root@raspberrypi:/home/pi# udevadm test /sys/class/net/wlan0
now gives

Code: Select all

calling: test
version 232
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk ===
tool version:          232
file size:         8574469 bytes
header size             80 bytes
strings            1848133 bytes
nodes              6726256 bytes
Load module index
Found container virtualization none
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /lib/udev/rules.d/10-local-rpi.rules
Reading rules file: /lib/udev/rules.d/15-i2c-modprobe.rules
Reading rules file: /lib/udev/rules.d/15-rfkill.rules
Reading rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /lib/udev/rules.d/50-firmware.rules
Reading rules file: /lib/udev/rules.d/50-udev-default.rules
Reading rules file: /lib/udev/rules.d/55-dm.rules
Reading rules file: /lib/udev/rules.d/60-block.rules
Reading rules file: /lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib/udev/rules.d/60-crda.rules
Reading rules file: /lib/udev/rules.d/60-drm.rules
Reading rules file: /lib/udev/rules.d/60-evdev.rules
Reading rules file: /lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib/udev/rules.d/60-serial.rules
Reading rules file: /lib/udev/rules.d/60-triggerhappy.rules
Reading rules file: /lib/udev/rules.d/64-btrfs.rules
Reading rules file: /lib/udev/rules.d/69-libmtp.rules
Reading rules file: /lib/udev/rules.d/70-debian-uaccess.rules
Reading rules file: /lib/udev/rules.d/70-mouse.rules
Reading rules file: /lib/udev/rules.d/70-power-switch.rules
Reading rules file: /lib/udev/rules.d/70-touchpad.rules
Reading rules file: /lib/udev/rules.d/70-uaccess.rules
Reading rules file: /lib/udev/rules.d/71-seat.rules
Reading rules file: /lib/udev/rules.d/73-seat-late.rules
Reading rules file: /lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /lib/udev/rules.d/73-usb-net-by-mac.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-ifupdown.rules
Reading rules file: /lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /lib/udev/rules.d/85-hwclock.rules
Reading rules file: /lib/udev/rules.d/85-regulatory.rules
Reading rules file: /lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /lib/udev/rules.d/90-console-setup.rules
Reading rules file: /lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /etc/udev/rules.d/99-com.rules
Reading rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 196608 bytes tokens (16384 * 12 bytes), 20956 bytes strings
13900 strings (113087 bytes), 11773 de-duplicated (94259 bytes), 2128 trie nodes used
IMPORT builtin 'net_id' /lib/udev/rules.d/73-usb-net-by-mac.rules:13
NAME 'wlxaabbccddeeff' /lib/udev/rules.d/73-usb-net-by-mac.rules:13
IMPORT builtin 'net_id' /lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'usb_id' /lib/udev/rules.d/75-net-description.rules:8
/sys/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0: if_class 255 protocol 0
IMPORT builtin 'hwdb' /lib/udev/rules.d/75-net-description.rules:8
RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
IMPORT builtin 'path_id' /lib/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /lib/udev/rules.d/80-net-setup-link.rules:9
Config file /lib/systemd/network/99-default.link applies to device wlan0
RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:56
error changing net interface name 'wlan0' to 'wlxaabbccddeeff': Device or resource busy
could not rename interface '2' from 'wlan0' to 'wlxaabbccddeeff': Device or resource busy
created db file '/run/udev/data/n2' for '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/net/wlan0'
ACTION=add
DEVPATH=/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/net/wlan0
DEVTYPE=wlan
ID_BUS=usb
ID_MODEL=802.11_n_WLAN
ID_MODEL_ENC=802.11\x20n\x20WLAN
ID_MODEL_FROM_DATABASE=RT5572 Wireless Adapter
ID_MODEL_ID=5572
ID_NET_DRIVER=rt2800usb
ID_NET_LINK_FILE=/lib/systemd/network/99-default.link
ID_NET_NAME_MAC=wlxaabbccddeeff
ID_OUI_FROM_DATABASE=MTN Electronic Co. Ltd
ID_PATH=platform-20980000.usb-usb-0:1.4:1.0
ID_PATH_TAG=platform-20980000_usb-usb-0_1_4_1_0
ID_REVISION=0101
ID_SERIAL=Ralink_802.11_n_WLAN_1.0
ID_SERIAL_SHORT=1.0
ID_TYPE=generic
ID_USB_DRIVER=rt2800usb
ID_USB_INTERFACES=:ffffff:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Ralink
ID_VENDOR_ENC=Ralink
ID_VENDOR_FROM_DATABASE=Ralink Technology, Corp.
ID_VENDOR_ID=148f
IFINDEX=2
INTERFACE=wlan0
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlxaabbccddeeff
TAGS=:systemd:
USEC_INITIALIZED=16993672
run: 'ifupdown-hotplug'
run: '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/wlxaabbccddeeff --prefix=/net/ipv4/neigh/wlxaabbccddeeff --prefix=/net/ipv6/conf/wlxaabbccddeeff --prefix=/net/ipv6/neigh/wlxaabbccddeeff'
Unload module index
Unloaded link configuration context.
Any further boot (either by issuing "reboot" or a cold-boot) give the same messages as above and the inerface alsways gets named "wlan0".

So even an untouched stretch-system seems to have some kind of an issue when naming the interfaces
error changing net interface name 'wlan0' to 'wlxaabbccddeeff': Device or resource busy
could not rename interface '2' from 'wlan0' to 'wlxaabbccddeeff': Device or resource busy


Since I am building an WiFi-(Repeater)-AccessPoint using
1x USB WiFi Dongle to connect to an existing WiFi network (thats the one I had connected in the above example)
1x USB WiFi Dongle to create a 2.4GHz AP (using hostapd and dnsmasq)
1x USB WiFi Dongle to create a 5GHz AP (using hostapd and dnsmasq)
I need to have persistent network interface names so I can get the iptables rules right.

Building this setup using jessie was no problem (interface names were easily changed using udev rules using mac addresses of the dongles),
I had all steps documented so I wanted to re-do it from scratch using stretch, but networking seems to be somehow broken in stretch...

User avatar
elkberry
Posts: 167
Joined: Wed Dec 28, 2016 9:21 pm

Re: Stretch | Not able to rename network interfaces any more

Sun Aug 27, 2017 8:57 pm

When it comes to systemd-networkd in Stretch, I'm reminded of Monty Python's "Norwegian Blue" sketch: "no Sir, your networking isn't broken. It just, erm, sleeps."
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

rennefj
Posts: 5
Joined: Thu Aug 24, 2017 8:03 pm

Re: Stretch | Not able to rename network interfaces any more

Tue Aug 29, 2017 11:56 am

I think I found the issue and I have a solution that works for me (at least for the most part).
With the stretch release raspbian uses dhcpcd for configuring the network interfaces.
The issue seems to be a race condition between udev and dhcpcd.

During my search I have read somewhere that the dhcpcd seems to grab the interfaces from the kernel as soon as they appear before giving udev a chance to rename them.
When udev tries, this yields the "Device or resource busy" error.
Due to the race conditions this seems to work for the internal interface (at least for me) but not for the external USB Ethernet Adapters.

The solution is to use systemd-networkd instead of dhcpcd.
I have setup networkd according to this post (Variante 5) https://www.elektronik-kompendium.de/si ... 912151.htm
It is in german, but one basically just needs to copy and past the commands for the section with headline Lösung (Variante 5):

Switching to systemd-networkd should give the "predictable network interface names" for all interfaces in stretch (at least it did for all my interfaces).
To manually rename interfaces with a .link rule one needs to either disable the 73-usb-net-by-mac.rules or by creating a symlink to 80-net-setup-link.rules in /etc/udev/rules.d/
This will in both cases disable the automatic renaming by MAC address and only use interface names defined by the user in .link files.

User avatar
DougieLawson
Posts: 35519
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Stretch | Not able to rename network interfaces any more

Tue Aug 29, 2017 6:00 pm

I found the magic difference between Jessie upgraded to Stretch and native Stretch. (Took bloody ages and about ten reboots of the machine I was mucking about with.)

/etc/systemd/network/99-default.link which simply contains this blurb

Code: Select all

# This machine is most likely a virtualized guest, where the old persistent
# network interface mechanism (75-persistent-net-generator.rules) did not work.
# This file disables /lib/systemd/network/99-default.link to avoid
# changing network interface names on upgrade. Please read
# /usr/share/doc/udev/README.Debian.gz about how to migrate to the currently
# supported mechanism.
The existence of that file prevents persistent network names from working.

https://www.freedesktop.org/software/sy ... .link.html
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
elkberry
Posts: 167
Joined: Wed Dec 28, 2016 9:21 pm

Re: Stretch | Not able to rename network interfaces any more

Tue Aug 29, 2017 8:01 pm

Ah, good to know, thanks for tracking this down! This only happens on upgraded Jessie-to-Stretch installations, correct? A fresh stretch shouldn't have that in /etc/systemd/network, and none in /lib/systemd/network either.
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

Return to “Raspbian”