summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-01 16:51:02 +0200
committerTom Gundersen <teg@jklm.no>2015-04-01 22:56:27 +0200
commitc0a43734ca84a3c9170d4a2d7f4d329b9ef47abc (patch)
treef4f034e3a9f75b243945d9a6643e77d286ef1a0c
parent16f948cb208f1db9a1665f07ac9b22e416dc19d4 (diff)
udev: net_id - support multi-port enpo* device names
I'd argue that having firmware labels for such devices makes no sense, but they exist, so make sure we handle them as best as we can.
-rw-r--r--src/udev/udev-builtin-net_id.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index 71f3a5970f..0f5b11d4d1 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -35,7 +35,7 @@
* Type of names:
* b<number> -- BCMA bus core number
* ccw<name> -- CCW bus group name
- * o<index> -- on-board device index number
+ * o<index>[d<dev_port>] -- on-board device index number
* s<slot>[f<function>][d<dev_port>] -- hotplug slot index number
* x<MAC> -- MAC address
* [P<domain>]p<bus>s<slot>[f<function>][d<dev_port>]
@@ -128,22 +128,39 @@ struct netnames {
/* retrieve on-board index number and label from firmware */
static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
- const char *index;
+ unsigned dev_port = 0;
+ size_t l;
+ char *s;
+ const char *attr;
int idx;
/* ACPI _DSM -- device specific method for naming a PCI or PCI Express device */
- index = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
+ attr = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
/* SMBIOS type 41 -- Onboard Devices Extended Information */
- if (!index)
- index = udev_device_get_sysattr_value(names->pcidev, "index");
- if (!index)
+ if (!attr)
+ attr = udev_device_get_sysattr_value(names->pcidev, "index");
+ if (!attr)
return -ENOENT;
- idx = strtoul(index, NULL, 0);
+
+ idx = strtoul(attr, NULL, 0);
if (idx <= 0)
return -EINVAL;
- snprintf(names->pci_onboard, sizeof(names->pci_onboard), "o%d", idx);
+
+ /* kernel provided multi-device index */
+ attr = udev_device_get_sysattr_value(dev, "dev_port");
+ if (attr)
+ dev_port = strtol(attr, NULL, 10);
+
+ s = names->pci_onboard;
+ l = sizeof(names->pci_onboard);
+ l = strpcpyf(&s, l, "o%d", idx);
+ if (dev_port > 0)
+ l = strpcpyf(&s, l, "d%d", dev_port);
+ if (l == 0)
+ names->pci_onboard[0] = '\0';
names->pci_onboard_label = udev_device_get_sysattr_value(names->pcidev, "label");
+
return 0;
}