|
|
803fb7 |
From 74b66951fcd54e6ab51023f60cc021fe355be1a8 Mon Sep 17 00:00:00 2001
|
|
|
803fb7 |
From: Tom Gundersen <teg@jklm.no>
|
|
|
803fb7 |
Date: Sat, 25 Oct 2014 17:10:11 +0200
|
|
|
803fb7 |
Subject: [PATCH] udev: net_id - correctly name netdevs based on dev_port when
|
|
|
803fb7 |
set
|
|
|
803fb7 |
|
|
|
803fb7 |
Upstream, dev_id was replaced by dev_port, and the same happened for some kernel
|
|
|
803fb7 |
drivers. This logic is not in the RHEL7 kernel, except for one new driver which
|
|
|
803fb7 |
uses dev_port, but never used dev_id in the past.
|
|
|
803fb7 |
|
|
|
803fb7 |
To give proper names to these devices, fall back to using dev_port when dev_id
|
|
|
803fb7 |
is not set. This does not affect any existing drivers.
|
|
|
803fb7 |
|
|
|
803fb7 |
(rhel only)
|
|
|
803fb7 |
|
|
|
803fb7 |
Resolves: #1155996
|
|
|
803fb7 |
|
|
|
803fb7 |
Conflicts:
|
|
|
803fb7 |
src/udev/udev-builtin-net_id.c
|
|
|
803fb7 |
|
|
|
803fb7 |
Conflicts:
|
|
|
803fb7 |
src/udev/udev-builtin-net_id.c
|
|
|
803fb7 |
---
|
|
|
803fb7 |
src/udev/udev-builtin-net_id.c | 26 ++++++++++++++++----------
|
|
|
803fb7 |
1 file changed, 16 insertions(+), 10 deletions(-)
|
|
|
803fb7 |
|
|
|
803fb7 |
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
|
|
|
803fb7 |
index 37ff1b800..99caa0a2a 100644
|
|
|
803fb7 |
--- a/src/udev/udev-builtin-net_id.c
|
|
|
803fb7 |
+++ b/src/udev/udev-builtin-net_id.c
|
|
|
803fb7 |
@@ -38,7 +38,7 @@
|
|
|
803fb7 |
* o<index> -- on-board device index number
|
|
|
803fb7 |
* s<slot>[f<function>][d<dev_port>] -- hotplug slot index number
|
|
|
803fb7 |
* x<MAC> -- MAC address
|
|
|
803fb7 |
- * [P<domain>]p<bus>s<slot>[f<function>][d<dev_port>]
|
|
|
803fb7 |
+ * [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>/<dev_port>]
|
|
|
803fb7 |
* -- PCI geographical location
|
|
|
803fb7 |
* [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
|
|
|
803fb7 |
* -- USB port number chain
|
|
|
803fb7 |
@@ -169,7 +169,7 @@ static bool is_pci_multifunction(struct udev_device *dev) {
|
|
|
803fb7 |
|
|
|
803fb7 |
static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
|
|
|
803fb7 |
struct udev *udev = udev_device_get_udev(names->pcidev);
|
|
|
803fb7 |
- unsigned domain, bus, slot, func, dev_port = 0;
|
|
|
803fb7 |
+ unsigned domain, bus, slot, func, dev_id = 0;
|
|
|
803fb7 |
size_t l;
|
|
|
803fb7 |
char *s;
|
|
|
803fb7 |
const char *attr;
|
|
|
803fb7 |
@@ -183,9 +183,15 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
|
|
|
803fb7 |
return -ENOENT;
|
|
|
803fb7 |
|
|
|
803fb7 |
/* kernel provided multi-device index */
|
|
|
803fb7 |
- attr = udev_device_get_sysattr_value(dev, "dev_port");
|
|
|
803fb7 |
- if (attr)
|
|
|
803fb7 |
- dev_port = strtol(attr, NULL, 10);
|
|
|
803fb7 |
+ attr = udev_device_get_sysattr_value(dev, "dev_id");
|
|
|
803fb7 |
+ if (attr) {
|
|
|
803fb7 |
+ dev_id = strtol(attr, NULL, 16);
|
|
|
803fb7 |
+ if (dev_id == 0) {
|
|
|
803fb7 |
+ attr = udev_device_get_sysattr_value(dev, "dev_port");
|
|
|
803fb7 |
+ if (attr)
|
|
|
803fb7 |
+ dev_id = strtol(attr, NULL, 16);
|
|
|
803fb7 |
+ }
|
|
|
803fb7 |
+ }
|
|
|
803fb7 |
|
|
|
803fb7 |
/* compose a name based on the raw kernel's PCI bus, slot numbers */
|
|
|
803fb7 |
s = names->pci_path;
|
|
|
803fb7 |
@@ -194,9 +200,9 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
|
|
|
803fb7 |
l = strpcpyf(&s, l, "P%u", domain);
|
|
|
803fb7 |
l = strpcpyf(&s, l, "p%us%u", bus, slot);
|
|
|
803fb7 |
if (func > 0 || is_pci_multifunction(names->pcidev))
|
|
|
803fb7 |
- l = strpcpyf(&s, l, "f%u", func);
|
|
|
803fb7 |
- if (dev_port > 0)
|
|
|
803fb7 |
- l = strpcpyf(&s, l, "d%u", dev_port);
|
|
|
803fb7 |
+ l = strpcpyf(&s, l, "f%d", func);
|
|
|
803fb7 |
+ if (dev_id > 0)
|
|
|
803fb7 |
+ l = strpcpyf(&s, l, "d%d", dev_id);
|
|
|
803fb7 |
if (l == 0)
|
|
|
803fb7 |
names->pci_path[0] = '\0';
|
|
|
803fb7 |
|
|
|
803fb7 |
@@ -245,8 +251,8 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
|
|
|
803fb7 |
l = strpcpyf(&s, l, "s%d", hotplug_slot);
|
|
|
803fb7 |
if (func > 0 || is_pci_multifunction(names->pcidev))
|
|
|
803fb7 |
l = strpcpyf(&s, l, "f%d", func);
|
|
|
803fb7 |
- if (dev_port > 0)
|
|
|
803fb7 |
- l = strpcpyf(&s, l, "d%d", dev_port);
|
|
|
803fb7 |
+ if (dev_id > 0)
|
|
|
803fb7 |
+ l = strpcpyf(&s, l, "d%d", dev_id);
|
|
|
803fb7 |
if (l == 0)
|
|
|
803fb7 |
names->pci_path[0] = '\0';
|
|
|
803fb7 |
}
|