Split out the bits which determine ID_NET_DRIVER or DRIVERS into separate udev rules file

Those are not required with systemd-udevd v210 or newer. This way
distros which have a new enough version of udev can skip installing
84-nm-drivers.rules. While at it, don't use absolute paths for sed and
ethtool.
This commit is contained in:
Michael Biebl 2015-08-28 16:30:15 +02:00
parent f67b5deba3
commit 1e03758262
3 changed files with 15 additions and 7 deletions

12
data/84-nm-drivers.rules Normal file
View file

@ -0,0 +1,12 @@
# Do not modify this file, it will get overwritten on updates.
# To override or extend the rules place a file in /etc/udev/rules.d
SUBSYSTEM!="net", GOTO="nm_drivers_end"
ACTION!="add|change", GOTO="nm_drivers_end"
# Determine ID_NET_DRIVER if there's no ID_NET_DRIVER or DRIVERS (old udev?)
ENV{ID_NET_DRIVER}=="?*", GOTO="nm_drivers_end"
DRIVERS=="?*", GOTO="nm_drivers_end"
PROGRAM="/bin/sh -c 'ethtool -i $1 | sed -n s/^driver:\ //p' -- $env{INTERFACE}", RESULT=="?*", ENV{ID_NET_DRIVER}="%c"
LABEL="nm_drivers_end"

View file

@ -1,15 +1,9 @@
# Do not modify this file, it will get overwriten on updates.
# Do not modify this file, it will get overwritten on updates.
# To override or extend the rules place a file in /etc/udev/rules.d
SUBSYSTEM!="net", GOTO="nm_unmanaged_end"
ACTION!="add|change", GOTO="nm_unmanaged_end"
# Determine ID_NET_DRIVER if there's no ID_NET_DRIVER or DRIVERS (old udev?)
ENV{ID_NET_DRIVER}=="?*", GOTO="nm_unmanaged_driver"
DRIVERS=="?*", GOTO="nm_unmanaged_driver"
PROGRAM="/bin/sh -c '/usr/sbin/ethtool -i $1 | /bin/sed -n s/^driver:\ //p' -- $env{INTERFACE}", RESULT=="?*", ENV{ID_NET_DRIVER}="%c"
LABEL="nm_unmanaged_driver"
# VirtualBox host networking. Out-of-tree driver that looks like an ordinary
# Ethernet. No parent device (lives in /virtual/), no support for ethtool
# to identify the driver, MAC address defaults to 08:00:27:, but can be

View file

@ -37,6 +37,7 @@ examples_DATA = server.conf
if WITH_UDEV_DIR
udevrulesdir = $(UDEV_DIR)/rules.d
udevrules_DATA = \
84-nm-drivers.rules \
85-nm-unmanaged.rules
endif
@ -57,6 +58,7 @@ EXTRA_DIST = \
NetworkManager-wait-online-systemd-pre200.service.in \
NetworkManager-dispatcher.service.in \
org.freedesktop.NetworkManager.service.in \
84-nm-drivers.rules \
85-nm-unmanaged.rules \
server.conf.in