[systemd-commits] 2 commits - man/systemd-networkd.service.xml man/udev.xml src/shared src/udev

Tom Gundersen tomegun at kemper.freedesktop.org
Sat Jan 4 06:15:50 PST 2014


 man/systemd-networkd.service.xml |    3 +--
 man/udev.xml                     |    3 +--
 src/shared/net-util.c            |    2 +-
 src/udev/udev-builtin-net_id.c   |   37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 40 insertions(+), 5 deletions(-)

New commits:
commit e3d563346c4237af23335cc6904e0662efdf62ad
Author: Tom Gundersen <teg at jklm.no>
Date:   Sat Jan 4 14:43:45 2014 +0100

    udev: net_id - handle virtio buses
    
    This was already supported in path_id, so should be uncontroversial.

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index b91ca9d..c322056 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -101,6 +101,7 @@ enum netname_type{
         NET_PCI,
         NET_USB,
         NET_BCMA,
+        NET_VIRTIO,
 };
 
 struct netnames {
@@ -118,6 +119,8 @@ struct netnames {
         char usb_ports[IFNAMSIZ];
 
         char bcma_core[IFNAMSIZ];
+
+        char virtio_core[IFNAMSIZ];
 };
 
 /* retrieve on-board index number and label from firmware */
@@ -344,6 +347,25 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) {
         return 0;
 }
 
+static int names_virtio(struct udev_device *dev, struct netnames *names) {
+        struct udev_device *virtdev;
+        unsigned int core;
+
+        virtdev = udev_device_get_parent_with_subsystem_devtype(dev, "virtio", NULL);
+        if (!virtdev)
+                return -ENOENT;
+
+        /* core num */
+        if (sscanf(udev_device_get_sysname(virtdev), "virtio%u", &core) != 1)
+                return -EINVAL;
+        /* suppress the common core == 0 */
+        if (core > 0)
+                snprintf(names->virtio_core, sizeof(names->virtio_core), "v%u", core);
+
+        names->type = NET_VIRTIO;
+        return 0;
+}
+
 static int names_mac(struct udev_device *dev, struct netnames *names) {
         const char *s;
         unsigned int i;
@@ -497,6 +519,21 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
                 goto out;
         }
 
+        /* virtio bus */
+        err = names_virtio(dev, &names);
+        if (err >= 0 && names.type == NET_VIRTIO) {
+                char str[IFNAMSIZ];
+
+                if (names.pci_path[0])
+                        if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.virtio_core) < (int)sizeof(str))
+                                udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
+
+                if (names.pci_slot[0])
+                        if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.virtio_core) < (int)sizeof(str))
+                                udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
+                goto out;
+        }
+
 out:
         return EXIT_SUCCESS;
 }

commit d69b12ac8aed834e4a8220d19c6895ef04c73679
Author: Tom Gundersen <teg at jklm.no>
Date:   Sat Jan 4 04:22:06 2014 +0100

    Revert "net-util: add support for Type=ethernet"
    
    This reverts commit 4cd1214db6cf4b262e8ce6381bc710091b375c96.
    
    This may still be fixed in the kernel, revert this for now until
    we see how it all shakes out.

diff --git a/man/systemd-networkd.service.xml b/man/systemd-networkd.service.xml
index f34471c..57be335 100644
--- a/man/systemd-networkd.service.xml
+++ b/man/systemd-networkd.service.xml
@@ -146,8 +146,7 @@
                                         <term><varname>Type</varname></term>
                                         <listitem>
                                                 <para>The device type, as exposed by the udev property
-                                                <literal>DEVTYPE</literal>, or <literal>ethernet</literal>
-                                                to match devices without a <literal>DEVTYPE</literal>.</para>
+                                                <literal>DEVTYPE</literal>.</para>
                                         </listitem>
                                 </varlistentry>
                                 <varlistentry>
diff --git a/man/udev.xml b/man/udev.xml
index 0bcb911..32a520e 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -793,8 +793,7 @@
         <varlistentry>
           <term><varname>Type</varname></term>
           <listitem>
-            <para>The device type, as exposed by the udev property <literal>DEVTYPE</literal>, or
-            <literal>ethernet</literal> to match a device without a <literal>DEVTYPE</literal>.</para>
+            <para>The device type, as exposed by the udev property <literal>DEVTYPE</literal>.</para>
           </listitem>
         </varlistentry>
       </variablelist>
diff --git a/src/shared/net-util.c b/src/shared/net-util.c
index 85278e5..8f8cfc9 100644
--- a/src/shared/net-util.c
+++ b/src/shared/net-util.c
@@ -49,7 +49,7 @@ bool net_match_config(const struct ether_addr *match_mac,
         if (match_driver && !streq_ptr(match_driver, dev_driver))
                 return 0;
 
-        if (match_type && !streq_ptr(match_type, dev_type) && !(streq(match_type, "ethernet") && !dev_type))
+        if (match_type && !streq_ptr(match_type, dev_type))
                 return 0;
 
         if (match_name && !streq_ptr(match_name, dev_name))



More information about the systemd-commits mailing list