anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0371-udev-net_id-correctly-name-netdevs-based-on-dev_port.patch

84b277
From 74888db37748c20b144a7cb117fb35f5c9804bcb Mon Sep 17 00:00:00 2001
84b277
From: Tom Gundersen <teg@jklm.no>
84b277
Date: Sat, 25 Oct 2014 17:10:11 +0200
84b277
Subject: [PATCH] udev: net_id - correctly name netdevs based on dev_port when
84b277
 set
84b277
84b277
Upstream, dev_id was replaced by dev_port, and the same happened for some kernel
84b277
drivers. This logic is not in the RHEL7 kernel, except for one new driver which
84b277
uses dev_port, but never used dev_id in the past.
84b277
84b277
To give proper names to these devices, fall back to using dev_port when dev_id
84b277
is not set. This does not affect any existing drivers.
84b277
84b277
(rhel only)
84b277
84b277
Resolves: #1155996
84b277
---
84b277
 src/udev/udev-builtin-net_id.c | 10 ++++++++--
84b277
 1 file changed, 8 insertions(+), 2 deletions(-)
84b277
84b277
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
84b277
index b3cb04b..b5b5909 100644
84b277
--- a/src/udev/udev-builtin-net_id.c
84b277
+++ b/src/udev/udev-builtin-net_id.c
84b277
@@ -36,7 +36,7 @@
84b277
  *   o<index>                              -- on-board device index number
84b277
  *   s<slot>[f<function>][d<dev_id>]       -- hotplug slot index number
84b277
  *   x<MAC>                                -- MAC address
84b277
- *   [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>]
84b277
+ *   [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>/<dev_port>]
84b277
  *                                         -- PCI geographical location
84b277
  *   [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
84b277
  *                                         -- USB port number chain
84b277
@@ -185,8 +185,14 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
84b277
 
84b277
         /* kernel provided multi-device index */
84b277
         attr = udev_device_get_sysattr_value(dev, "dev_id");
84b277
-        if (attr)
84b277
+        if (attr) {
84b277
                 dev_id = strtol(attr, NULL, 16);
84b277
+                if (dev_id == 0) {
84b277
+                        attr = udev_device_get_sysattr_value(dev, "dev_port");
84b277
+                        if (attr)
84b277
+                                dev_id = strtol(attr, NULL, 16);
84b277
+                }
84b277
+        }
84b277
 
84b277
         /* compose a name based on the raw kernel's PCI bus, slot numbers */
84b277
         s = names->pci_path;