chiark / gitweb /
net-util: match on the driver as exposed by ethtool if DRIVER not set
authorTom Gundersen <teg@jklm.no>
Fri, 21 Feb 2014 21:29:25 +0000 (22:29 +0100)
committerTom Gundersen <teg@jklm.no>
Fri, 21 Feb 2014 21:59:29 +0000 (22:59 +0100)
Also fix a copy-paste error that broke matching on interface name.

man/systemd-networkd.service.xml
man/udev.xml
src/network/networkd-netdev.c
src/network/networkd-network.c
src/shared/net-util.c
src/shared/net-util.h
src/udev/net/link-config.c

index 026536ebd94560e30e39a2c9ffa503faae2a9138..2517efc4a79c6ffe19faeb2b5897f8bef096bf7c 100644 (file)
                                         <listitem>
                                                 <para>The driver currently bound to the device, as
                                                 exposed by the udev property <literal>DRIVER</literal>
-                                                of its parent device.
-                                                </para>
+                                                of its parent device, or if that is not set the driver
+                                                as exposed by <literal>ethtool -i</literal> of the
+                                                device itself.</para>
                                         </listitem>
                                 </varlistentry>
                                 <varlistentry>
index 0e75715887088686f6f135ed6b4b2d62b7c47f97..ae7dc61b03ec5c3cd57cf8b531e1d4230e362f3a 100644 (file)
           <term><varname>Driver=</varname></term>
           <listitem>
             <para>The driver currently bound to the device, as exposed by the
-            udev property <literal>DRIVER</literal> of its parent device.</para>
+            udev property <literal>DRIVER</literal> of its parent device, or if
+            that is not set the driver as exposed by <literal>ethtool -i</literal>
+            of the device itself.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index c3bda6da84d56ef491e8183b1727f38276e1e9d5..05f21fa87426272c08c51c695063ec73569a597e 100644 (file)
@@ -366,7 +366,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
         if (net_match_config(NULL, NULL, NULL, NULL, NULL,
                              netdev->match_host, netdev->match_virt,
                              netdev->match_kernel, netdev->match_arch,
-                             NULL, NULL, NULL, NULL, NULL) <= 0)
+                             NULL, NULL, NULL, NULL, NULL, NULL) <= 0)
                 return 0;
 
         r = hashmap_put(netdev->manager->netdevs, netdev->name, netdev);
index 2e68bec2e745a520b24aa105e1ade33092d4efa1..14fa92aeaf62d6cce055ef23439696f5a3927c1c 100644 (file)
@@ -181,6 +181,7 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) {
                                         udev_device_get_sysattr_value(device, "address"),
                                         udev_device_get_property_value(device, "ID_PATH"),
                                         udev_device_get_driver(udev_device_get_parent(device)),
+                                        udev_device_get_property_value(device, "ID_NET_DRIVER"),
                                         udev_device_get_devtype(device),
                                         udev_device_get_sysname(device))) {
                         log_debug("%s: found matching network '%s'",
index a8a2c44bae570bae7be5ae985aed3e73ddf59c15..50cfa2c3f3a5a791f903859167523ebda43da131 100644 (file)
@@ -42,6 +42,7 @@ bool net_match_config(const struct ether_addr *match_mac,
                       Condition *match_arch,
                       const char *dev_mac,
                       const char *dev_path,
+                      const char *dev_parent_driver,
                       const char *dev_driver,
                       const char *dev_type,
                       const char *dev_name) {
@@ -64,13 +65,17 @@ bool net_match_config(const struct ether_addr *match_mac,
         if (match_path && (!dev_path || fnmatch(match_path, dev_path, 0)))
                 return 0;
 
-        if (match_driver && !streq_ptr(match_driver, dev_driver))
-                return 0;
+        if (match_driver) {
+                if (dev_parent_driver && !streq(match_driver, dev_parent_driver))
+                        return 0;
+                else if (!streq_ptr(match_driver, dev_driver))
+                        return 0;
+        }
 
         if (match_type && !streq_ptr(match_type, dev_type))
                 return 0;
 
-        if (match_name && (!dev_path || fnmatch(match_name, dev_name, 0)))
+        if (match_name && (!dev_name || fnmatch(match_name, dev_name, 0)))
                 return 0;
 
         return 1;
index 908fb22ffa31bea32b297e04a39913b3ffb9e07b..99479e1f5cbe32f2a5a31e405540a4a1362501a4 100644 (file)
@@ -38,6 +38,7 @@ bool net_match_config(const struct ether_addr *match_mac,
                       Condition *match_arch,
                       const char *dev_mac,
                       const char *dev_path,
+                      const char *dev_parent_driver,
                       const char *dev_driver,
                       const char *dev_type,
                       const char *dev_name);
index 40b1d7f7bc84ceb4316f24c193df8ab0033c314c..92d248fc6b2b714b6c16bbaa72c5083ad0049bf4 100644 (file)
@@ -247,6 +247,7 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
                                      udev_device_get_sysattr_value(device, "address"),
                                      udev_device_get_property_value(device, "ID_PATH"),
                                      udev_device_get_driver(udev_device_get_parent(device)),
+                                     udev_device_get_property_value(device, "ID_NET_DRIVER"),
                                      udev_device_get_devtype(device),
                                      NULL)) {
                         log_debug("Config file %s applies to device %s",