You are not logged in.

#1 2017-03-14 08:36:13

Tommylefunk
Member
Registered: 2016-02-03
Posts: 9

udev rules with equal names

Hey there,

I have a Lenovo X1 Yoga Laptop, and two OneLink+ docking stations (one at the office, one at home).
Both of the docking stations have an ethernet interface, and only one of them can be connected at a time.

To name my network devices I created the following udev rules:

cat /etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:50:b6:xx:xx:xx", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="7c:c3:a1:xx:xx:xx", NAME="eth0"

This gives no errors on boot, but the devices are created randomly with eth0 and eth1, so it seems that names can not be duplicate.

As I manage my network with netctl however, this becomes cumbersome as I have to create profiles for both eth0 and eth1.

Do you have any idea if I can somehow manage to always give the connected dock network interface the eth0 name?

Offline

#2 2017-03-14 09:55:55

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: udev rules with equal names

Tommylefunk wrote:

it seems that names can not be duplicate.

I don't think udev would care.

Change eth0 to dock0 and see whether you get dock1 or eth-something when you start swapping docks - maybe there are other rules (in /etc/udev or /lib/udev) which mess things up.

Offline

#3 2017-03-14 14:12:04

Tommylefunk
Member
Registered: 2016-02-03
Posts: 9

Re: udev rules with equal names

Thanks, interesting. I changed the name to dock0, and now still have an eth0 device (the Laptop does not have a direct Ethernet port).

I will check at home if this also works with the second dock and report the results.
Thanks, so far!

Offline

#4 2017-03-14 21:57:57

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: udev rules with equal names

With the device connected, run udevadm test /sys/class/net/eth0 to see what rule files are being loaded and what actions executed. It should also list any errors in rule files. This is only a simulation, it doesn't actually change anything.

And check if your rules contain the real MAC and not x:x:x smile

Last edited by mich41 (2017-03-14 22:01:44)

Offline

#5 2017-03-15 14:38:08

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: udev rules with equal names

Tommylefunk wrote:

Thanks, interesting. I changed the name to dock0, and now still have an eth0 device (the Laptop does not have a direct Ethernet port).

I will check at home if this also works with the second dock and report the results.
Thanks, so far!

Can you provide the output of 'lspci -nnk' without the dock connected and another with one of the docks connected?

If two network adapters show up then that's where I would look first to try to understand why there are two and not just the one provided by the dock(s), unless the docks themselves have two network ports and only one is accessible.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#6 2017-03-15 16:13:41

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules with equal names

Another udev rule could be overriding your NAME assignation.

Either use 99 instead of 10 in the filename, for precedence, or use NAME:= instead of NAME=

Offline

#7 2017-03-16 08:51:42

Tommylefunk
Member
Registered: 2016-02-03
Posts: 9

Re: udev rules with equal names

First of all, thanks for all your help.

I now had the time to check at home and the naming now work perfectly with both named dock0.

For the second unknown network device I ran:

lspci -nnk > a
// disconnect dock
lspci -nnk > b
diff a b

but the diff is empty.

The udev test with 'udevadm test /sys/class/net/enp0s31f6' on the unassigned device gives me:

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:         8801924 bytes
header size             80 bytes
strings            1856372 bytes
nodes              6945472 bytes
Load module index
Found container virtualization none
timestamp of '/etc/systemd/network' changed
timestamp of '/usr/lib/systemd/network' changed
Parsed configuration file /usr/lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /usr/lib/udev/rules.d/10-dm.rules
Reading rules file: /etc/udev/rules.d/10-network.rules
Reading rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules
Reading rules file: /usr/lib/udev/rules.d/13-dm-disk.rules
Reading rules file: /usr/lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /usr/lib/udev/rules.d/40-gphoto.rules
Reading rules file: /usr/lib/udev/rules.d/40-hpet-permissions.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules
Reading rules file: /usr/lib/udev/rules.d/50-udev-default.rules
Reading rules file: /usr/lib/udev/rules.d/51-android.rules
Reading rules file: /usr/lib/udev/rules.d/60-block.rules
Reading rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /usr/lib/udev/rules.d/60-drm.rules
Reading rules file: /usr/lib/udev/rules.d/60-evdev.rules
Reading rules file: /usr/lib/udev/rules.d/60-ffado.rules
Reading rules file: /usr/lib/udev/rules.d/60-pcmcia.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /usr/lib/udev/rules.d/60-rfkill.rules
Reading rules file: /usr/lib/udev/rules.d/60-serial.rules
Reading rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs.rules
Reading rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules
Reading rules file: /usr/lib/udev/rules.d/65-libwacom.rules
Reading rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.rules
Reading rules file: /usr/lib/udev/rules.d/69-libftdi.rules
Reading rules file: /usr/lib/udev/rules.d/69-libmtp.rules
Reading rules file: /usr/lib/udev/rules.d/70-infrared.rules
Reading rules file: /usr/lib/udev/rules.d/70-mouse.rules
Reading rules file: /usr/lib/udev/rules.d/70-power-switch.rules
Reading rules file: /usr/lib/udev/rules.d/70-touchpad.rules
Reading rules file: /usr/lib/udev/rules.d/70-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.rules
Reading rules file: /usr/lib/udev/rules.d/75-net-description.rules
Reading rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /usr/lib/udev/rules.d/78-sound-card.rules
Reading rules file: /usr/lib/udev/rules.d/80-docker.rules
Reading rules file: /usr/lib/udev/rules.d/80-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /usr/lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /usr/lib/udev/rules.d/80-udisks2.rules
Reading rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /usr/lib/udev/rules.d/90-libinput-model-quirks.rules
Reading rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /usr/lib/udev/rules.d/90-vconsole.rules
Reading rules file: /usr/lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-csr.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /usr/lib/udev/rules.d/99-fuse3.rules
Reading rules file: /usr/lib/udev/rules.d/99-systemd.rules
rules contain 196608 bytes tokens (16384 * 12 bytes), 25539 bytes strings
17178 strings (139406 bytes), 14797 de-duplicated (116249 bytes), 2382 trie nodes used
IMPORT builtin 'net_id' /usr/lib/udev/rules.d/75-net-description.rules:6
IMPORT builtin 'hwdb' /usr/lib/udev/rules.d/75-net-description.rules:12
IMPORT builtin 'path_id' /usr/lib/udev/rules.d/80-net-setup-link.rules:5
IMPORT builtin 'net_setup_link' /usr/lib/udev/rules.d/80-net-setup-link.rules:9
Config file /usr/lib/systemd/network/99-default.link applies to device enp0s31f6
link_config: could not set ethtool features for enp0s31f6
Could not set offload features of enp0s31f6: Operation not permitted
RUN '/usr/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /usr/lib/udev/rules.d/99-systemd.rules:51
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1f.6/net/enp0s31f6
ID_BUS=pci
ID_MODEL_FROM_DATABASE=Ethernet Connection I219-LM
ID_MODEL_ID=0x156f
ID_NET_DRIVER=e1000e
ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
ID_NET_NAME_MAC=enx54ee75ad88c7
ID_NET_NAME_PATH=enp0s31f6
ID_OUI_FROM_DATABASE=Wistron InfoComm(Kunshan)Co.,Ltd.
ID_PATH=pci-0000:00:1f.6
ID_PATH_TAG=pci-0000_00_1f_6
ID_PCI_CLASS_FROM_DATABASE=Network controller
ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
ID_VENDOR_FROM_DATABASE=Intel Corporation
ID_VENDOR_ID=0x8086
IFINDEX=4
INTERFACE=enp0s31f6
SUBSYSTEM=net
SYSTEMD_ALIAS=/sys/subsystem/net/devices/enp0s31f6
TAGS=:systemd:
USEC_INITIALIZED=3550379
run: '/usr/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/enp0s31f6 --prefix=/net/ipv4/neigh/enp0s31f6 --prefix=/net/ipv6/conf/enp0s31f6 --prefix=/net/ipv6/neigh/enp0s31f6'
Unload module index
Unloaded link configuration context.

So from that I interpret that this is some network controller on the motherboard that maybe somehow can be connected with an accessory adapter?

Offline

Board footer

Powered by FluxBB