udev-rules: only invoke ethtool for existing interfaces

ethtool may cause the auto-loading of a kernel module for non-existing
interface-names. Avoid that by checking whether such an interface exists.

This is inherently racy.
This commit is contained in:
Beniamino Galvani 2015-08-06 16:57:15 +02:00 committed by Thomas Haller
parent ab41c13b06
commit 44fee0f6ff

View file

@ -6,7 +6,7 @@ SUBSYSTEM!="net", 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 $env{INTERFACE} |/bin/sed -n s/^driver:\ //p'", RESULT=="?*", ENV{ID_NET_DRIVER}="%c"
PROGRAM="/bin/sh -c 'test -e "/sys/class/net/$env{INTERFACE}" && /usr/sbin/ethtool -i "$env{INTERFACE}" | /bin/sed -n s/^driver:\ //p'", RESULT=="?*", ENV{ID_NET_DRIVER}="%c"
LABEL="nm_unmanaged_driver"
# VirtualBox host networking. Out-of-tree driver that looks like an ordinary