Hello,
I have a problem renaming 2 USB ethernet interfaces using udev rule. We developed custom Verdin motherboard that is equiped with two ethernet to USB ICs connected to USB hub. After booting the system, two new ethernet interfaces are discovered and enumerated:
Booth interfaces seems stable, but the problem arises after rebooting. Interfaces are enumerated randomly. I wrote /etc/udev/rules.d/70-persistent-net.rules that should enumerate the interfaces and rename them to uppercase basing on interface MAC addresses:
With this I was able to successfully rename the network interface on an Apalis iMX6 with a TorizonCore 6.3 nightly release, but it should work on other releases as well.
It doesn’t help. However I’m running version 5.4. I forgot to post image version:
$ uname -a
Linux verdin-imx8mm-07213994 5.4.193-5.7.2+git.b60d3160fd04 #1-TorizonCore SMP PREEMPT Fri Dec 23 15:47:24 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
Maybe the udev rules are being executed after NetworkManager is already using the interfaces, so udev can’t change the interface names. I was able to rename an external USB WLAN interface on a Verdin iMX8M Plus with TorizonCore 5.7.2 (it has the same kernel version you’re using) by doing the following:
Configure NetworkManager to unmanage the interfaces with the old names:
The permissions are the same as I have on my files, so this shouldn’t be a problem.
I think this issue is more of a udev/systemd/general Linux problem rather than one specifically related to TorizonCore.
Can you try renaming other network devices on the Verdin and see if this last method works with them?
This is udev rule I use to handle the same, random enumeration, issue with 2 CAN interfaces we implemented on our board, however both interfaces are implemented via SPI interface:
SUBSYSTEM!="net", GOTO="my_can_end"
ACTION!="add", GOTO="my_can_end"
# enumerate external CAN as CAN1
DEVPATH=="/devices/platform/soc@0/soc@0:bus@30800000/30820000.spi/spi_master/spi0/spi0.0/net/can?", NAME="CAN1"
# enumerate internal CAN as CAN0
DEVPATH=="/devices/platform/soc@0/soc@0:bus@30800000/30840000.spi/spi_master/spi2/spi2.0/net/can?", NAME="CAN0"
LABEL="my_can_end"
You can try to use another identifier to differentiate between the USB interfaces, such as the udev property ID_PATH, which I think is unique to each USB physical path. You can get this property for each interface by executing
sudo udevadm info /sys/class/net/eth0
sudo udevadm info /sys/class/net/eth1
With this you can put the ID_PATH in the Path property of the .link files in /etc/systemd/network/ e.g.
I tried this, but still no luck. But I wrote this .rules :
SUBSYSTEM!="net", GOTO="my_can_end"
ACTION!="add", GOTO="my_can_end"
# enumerate eth to ETH1
DEVPATH=="/devices/platform/soc@0/soc@0:bus@32c00000/32e50000.usb/ci_hdrc.1/usb2/2-1/2-1.1/2-1.1:1.0/net/eth?", NAME="ETH1"
# enumerate eth as ETH0
DEVPATH=="/devices/platform/soc@0/soc@0:bus@32c00000/32e50000.usb/ci_hdrc.1/usb2/2-1/2-1.2/2-1.2:1.0/net/eth?", NAME="ETH0"
LABEL="my_can_end"
As I can see ID_PATH is analogous to DEVPATH and I managed to apply CAN IF rules using DEVPATH variable. After applying this rules, ethernet interfaces are renamed and after multiple reboots I havent noticed that interfaces switched theirs enumeration.