chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7e15bd3
)
udev: hwdb - fix OUI lookup
author
Kay Sievers
<kay@vrfy.org>
Sun, 2 Dec 2012 01:00:57 +0000
(
02:00
+0100)
committer
Kay Sievers
<kay@vrfy.org>
Sun, 2 Dec 2012 01:00:57 +0000
(
02:00
+0100)
src/udev/udev-builtin-net_id.c
patch
|
blob
|
history
diff --git
a/src/udev/udev-builtin-net_id.c
b/src/udev/udev-builtin-net_id.c
index bc6ca212db1441c228c9f56763bdb087e23158d5..fd84e6e24fbc9c21f045f997a77b6bc24792e4df 100644
(file)
--- a/
src/udev/udev-builtin-net_id.c
+++ b/
src/udev/udev-builtin-net_id.c
@@
-18,18
+18,27
@@
***/
/*
***/
/*
- * prefixes:
+ * predictable network interface device names based on:
+ * - firmware/bios-provided index numbers for on-board devices
+ * - firmware-provided pci-express hotplug slot index number
+ * - physical/geographical location of the hardware
+ * - the interface's MAC address
+ *
+ * two character prefixes based on the type of interface:
* en -- ethernet
* wl -- wlan
* ww -- wwan
*
* en -- ethernet
* wl -- wlan
* ww -- wwan
*
- * types:
- * o<index> -- on-board device index
- * s<slot>[f<function>] -- hotplug slot number
+ * type
of name
s:
+ * o<index> -- on-board device index
number
+ * s<slot>[f<function>] -- hotplug slot
index
number
* x<MAC> -- MAC address
* x<MAC> -- MAC address
- * p<bus>s<slot>[f<function>] -- PCI/physical location
+ * p<bus>s<slot>[f<function>] -- PCI geographical location
+ *
+ * All multi-function devices will carry the [f<function>] number in the
+ * device name, including the function 0 device.
*
*
- * example:
+ * example
s
:
* ID_NET_NAME_ONBOARD=eno1
* ID_NET_NAME_SLOT=ens1
* ID_NET_NAME_SLOT=ens2f0
* ID_NET_NAME_ONBOARD=eno1
* ID_NET_NAME_SLOT=ens1
* ID_NET_NAME_SLOT=ens2f0
@@
-82,6
+91,7
@@
static int dev_pci_onboard(struct udev_device *dev, struct udev_device *parent,
return 0;
}
return 0;
}
+/* read the 256 bytes PCI configuration space to check for multi-function */
static bool is_pci_singlefunction(struct udev_device *dev) {
char filename[256];
FILE *f;
static bool is_pci_singlefunction(struct udev_device *dev) {
char filename[256];
FILE *f;
@@
-215,8
+225,10
@@
static int dev_mac(struct udev_device *dev, const char *prefix, bool test) {
return -EINVAL;
/* add IEEE Organizationally Unique Identifier */
return -EINVAL;
/* add IEEE Organizationally Unique Identifier */
- snprintf(str, sizeof(str), "OUI:%X%X%X", a1, a2, a3);
- udev_builtin_hwdb_lookup(dev, str, test);
+ if (a1 + a2 + a3 > 0) {
+ snprintf(str, sizeof(str), "OUI:%02X%02X%02X", a1, a2, a3);
+ udev_builtin_hwdb_lookup(dev, str, test);
+ }
snprintf(str, sizeof(str), "%sx%02x%02x%02x%02x%02x%02x", prefix, a1, a2, a3, a4, a5, a6);
return udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str);
snprintf(str, sizeof(str), "%sx%02x%02x%02x%02x%02x%02x", prefix, a1, a2, a3, a4, a5, a6);
return udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str);