]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
net_id: depending on new udev prop, include/exclude PCI domain from netif names
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Sep 2024 15:07:11 +0000 (17:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Dec 2024 15:37:59 +0000 (16:37 +0100)
src/udev/udev-builtin-net_id.c

index 09c04b9a7fefc7b5a884cbc26a983b688d495af4..01a5dda6af81a6ffd45a47741de036cd5a833499 100644 (file)
@@ -650,7 +650,16 @@ static int get_pci_slot_specifiers(
                  * where the slot makes up the upper 5 bits. */
                 func += slot * 8;
 
-        if (domain > 0 && asprintf(&domain_spec, "P%u", domain) < 0)
+        /* Include the PCI domain in the name if the ID_NET_NAME_INCLUDE_DOMAIN property says so, if it is
+         * set. If it is not set, include it if the domain is non-zero. */
+        r = device_get_property_bool(dev, "ID_NET_NAME_INCLUDE_DOMAIN");
+        if (r < 0) {
+                if (r != -ENOENT)
+                        log_device_warning_errno(dev, r, "Failed to read property \"ID_NET_NAME_INCLUDE_DOMAIN\", ignoring: %m");
+
+                r = domain > 0;
+        }
+        if (r > 0 && asprintf(&domain_spec, "P%u", domain) < 0)
                 return log_oom_debug();
 
         if (asprintf(&bus_and_slot_spec, "p%us%u", bus, slot) < 0)