Blob Blame History Raw
From 74888db37748c20b144a7cb117fb35f5c9804bcb Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Sat, 25 Oct 2014 17:10:11 +0200
Subject: [PATCH] udev: net_id - correctly name netdevs based on dev_port when
 set

Upstream, dev_id was replaced by dev_port, and the same happened for some kernel
drivers. This logic is not in the RHEL7 kernel, except for one new driver which
uses dev_port, but never used dev_id in the past.

To give proper names to these devices, fall back to using dev_port when dev_id
is not set. This does not affect any existing drivers.

(rhel only)

Resolves: #1155996
---
 src/udev/udev-builtin-net_id.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index b3cb04b..b5b5909 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -36,7 +36,7 @@
  *   o<index>                              -- on-board device index number
  *   s<slot>[f<function>][d<dev_id>]       -- hotplug slot index number
  *   x<MAC>                                -- MAC address
- *   [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>]
+ *   [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>/<dev_port>]
  *                                         -- PCI geographical location
  *   [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
  *                                         -- USB port number chain
@@ -185,8 +185,14 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
 
         /* kernel provided multi-device index */
         attr = udev_device_get_sysattr_value(dev, "dev_id");
-        if (attr)
+        if (attr) {
                 dev_id = strtol(attr, NULL, 16);
+                if (dev_id == 0) {
+                        attr = udev_device_get_sysattr_value(dev, "dev_port");
+                        if (attr)
+                                dev_id = strtol(attr, NULL, 16);
+                }
+        }
 
         /* compose a name based on the raw kernel's PCI bus, slot numbers */
         s = names->pci_path;