X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-net_id.c;h=e6db2e4798871da81cfc6458843c87dc0748d2ac;hp=94fefc5f9d961bd67c9cd61c2b991512d59e490c;hb=971e7fb62548f2c9c4e32684bb13409e6579dc6a;hpb=0260944060426d54d9ecb40930baad985cbd02a1 diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 94fefc5f9..e6db2e479 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -18,35 +18,63 @@ ***/ /* - * predictable network interface device names based on: + * 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: + * Two character prefixes based on the type of interface: * en -- ethernet * wl -- wlan * ww -- wwan * - * type of names: + * Type of names: * o -- on-board device index number * s[f] -- hotplug slot index number * x -- MAC address * ps[f] -- PCI geographical location + * ps[f][u][...][c][i] + * -- USB port number chain * - * All multi-function devices will carry the [f] number in the + * All multi-function PCI devices will carry the [f] number in the * device name, including the function 0 device. * - * examples: + * For USB devices the full chain of port numbers of hubs is composed. If the + * name gets longer than the maximum number of 15 characters, the name is not + * exported. + * The usual USB configuration == 1 and interface == 0 values are suppressed. + * + * PCI ethernet card with firmware index * ID_NET_NAME_ONBOARD=eno1 + * ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1 + * + * PCI ethernet card + * /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1 + * ID_NET_NAME_MAC=enx000000000466 + * ID_NET_NAME_PATH=enp5s0 + * ID_NET_NAME_SLOT=ens1 + * + * PCI ethernet card in hotplug slot with firmware index number: + * /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1 + * ID_NET_NAME_MAC=enx000000000466 + * ID_NET_NAME_PATH=enp5s0 * ID_NET_NAME_SLOT=ens1 - * ID_NET_NAME_SLOT=ens2f0 - * ID_NET_NAME_SLOT=ens2f1 - * ID_NET_NAME_MAC=enxf0def180d479 - * ID_NET_NAME_PATH=enp0s25 - * ID_NET_NAME_PATH=enp19s3f0 - * ID_NET_NAME_PATH=enp19s3f1 + * + * PCI wlan card: + * /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlp3s0 + * ID_NET_NAME_MAC=wlx0024d7e31130 + * ID_NET_NAME_PATH=wlp3s0 + * + * USB built-in 3G modem: + * /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.6/net/wwp0s29u1u4i6 + * ID_NET_NAME_MAC=wwx028037ec0200 + * ID_NET_NAME_PATH=wwp0s29u1u4i6 + * + * USB Android phone: + * /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/net/enp0s29u1u2 + * ID_NET_NAME_MAC=enxd626b3450fb5 + * ID_NET_NAME_PATH=enp0s29u1u2 */ #include @@ -302,9 +330,9 @@ static int names_mac(struct udev_device *dev, struct netnames *names) { /* IEEE Organizationally Unique Identifier vendor string */ static int ieee_oui(struct udev_device *dev, struct netnames *names, bool test) { - char str[IFNAMSIZ]; + char str[32]; - if (names->mac_valid) + if (!names->mac_valid) return -ENOENT; /* skip commonly misused 00:00:00 (Xerox) prefix */ if (memcmp(names->mac, "\0\0\0", 3) == 0)