udev-rules: only invoke ethtool for existing interfaces
authorBeniamino Galvani <bgalvani@redhat.com>
Thu, 6 Aug 2015 14:57:15 +0000 (16:57 +0200)
committerThomas Haller <thaller@redhat.com>
Tue, 11 Aug 2015 16:31:46 +0000 (18:31 +0200)
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.

data/85-nm-unmanaged.rules

index aefab5c..f8d9509 100644 (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