You are not logged in.

#1 2016-03-08 16:12:10

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

[SOLVED] Predictable network interface names and custom udev rules

Hello,

I'm updating my custom udev rules that enable some power saving settings. I have this rule for network devices, which is called `50-powersave-net.rules` and gets placed into `/usr/lib/udev/rules.d/` by my PKGBUILD.

# Disable Wake-on-LAN
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/usr/bin/ethtool -s %k wol d"

# Disable ethernet ports
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/usr/bin/ip link set dev %k down"

# Enable powersaving on all wireless devices
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*", RUN+="/usr/bin/iw dev %k set power_save on"

I am aware of systemd's predictable network interface names that, according to the wiki, get applied by `/usr/lib/udev/rules.d/80-net-setup-link.rules`. Udev parses its rules files in lexicographical order, so as far as I know my power save rule should trigger before the devices are renamed. This does not seem to be the case however, because upon startup I can find the following entries in my journal:

systemd-udevd[241]: Process '/usr/bin/ip link set dev eth0 down' failed with exit code 1.
systemd-udevd[253]: Process '/usr/bin/iw dev wlan0 set power_save on' failed with exit code 237.

(I'm not sure why, but the `ethtool` command seems to work, I'm also not sure what exit code 237 is exactly). Indeed, if I rename the `eth*` entries to `enp*` and the `wlan*` entry to `wlp*`, these error messages disappear. Obviously things would work this way, but I'm just curious as to what is going on. It would be great if someone could point me into the right direction!

Last edited by Unia (2016-03-09 11:27:36)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#2 2016-03-09 00:38:59

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: [SOLVED] Predictable network interface names and custom udev rules

My experiments found ethtool always seems to exit with a 0 status ("success") even if you give an invalid device.

As the udev man page points out, the RUN commands are executed after all the rules have been processed.

80-net-setup-link.rules executes a builtin program to determine the predictable name and sets the NAME property. It does not specify any commands to "RUN".

My guess (i.e. I haven't checked the source code and could be totally wrong), is that the kernel name has already changed to the predictable name by the time your RUN commands are executed.

Offline

#3 2016-03-09 11:26:27

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [SOLVED] Predictable network interface names and custom udev rules

ukhippo wrote:

As the udev man page points out, the RUN commands are executed after all the rules have been processed.

80-net-setup-link.rules executes a builtin program to determine the predictable name and sets the NAME property. It does not specify any commands to "RUN".

My guess (i.e. I haven't checked the source code and could be totally wrong), is that the kernel name has already changed to the predictable name by the time your RUN commands are executed.

That does make sense indeed. None of this can be found in "Writing udev rules" which is linked to by the Arch wiki -- but it remains completely my own fault for not checking udev's man page...

I will update said wiki to add this information EDIT: Done.

Last edited by Unia (2016-03-09 11:39:36)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

Board footer

Powered by FluxBB