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