udev-builtin-net_id.c revision c0a43734ca84a3c9170d4a2d7f4d329b9ef47abc
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt This file is part of systemd.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Copyright 2012 Kay Sievers <kay@vrfy.org>
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is free software; you can redistribute it and/or modify it
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt under the terms of the GNU Lesser General Public License as published by
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt the Free Software Foundation; either version 2.1 of the License, or
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt (at your option) any later version.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt systemd is distributed in the hope that it will be useful, but
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt WITHOUT ANY WARRANTY; without even the implied warranty of
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt Lesser General Public License for more details.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt You should have received a copy of the GNU Lesser General Public License
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt along with systemd; If not, see <http://www.gnu.org/licenses/>.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Predictable network interface device names based on:
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * - firmware/bios-provided index numbers for on-board devices
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * - firmware-provided pci-express hotplug slot index number
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt * - physical/geographical location of the hardware
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * - the interface's MAC address
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * Two character prefixes based on the type of interface:
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * en -- ethernet
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * sl -- serial line IP (slip)
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * wl -- wlan
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * ww -- wwan
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Type of names:
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * b<number> -- BCMA bus core number
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt * ccw<name> -- CCW bus group name
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * o<index>[d<dev_port>] -- on-board device index number
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * s<slot>[f<function>][d<dev_port>] -- hotplug slot index number
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * x<MAC> -- MAC address
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * [P<domain>]p<bus>s<slot>[f<function>][d<dev_port>]
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * -- PCI geographical location
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * -- USB port number chain
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * All multi-function PCI devices will carry the [f<function>] number in the
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * device name, including the function 0 device.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * When using PCI geography, The PCI domain is only prepended when it is not 0.
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * For USB devices the full chain of port numbers of hubs is composed. If the
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt * name gets longer than the maximum number of 15 characters, the name is not
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * The usual USB configuration == 1 and interface == 0 values are suppressed.
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt * PCI ethernet card with firmware index "1":
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt * ID_NET_NAME_ONBOARD=eno1
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt * ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * PCI ethernet card in hotplug slot with firmware index number:
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * ID_NET_NAME_MAC=enx000000000466
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * ID_NET_NAME_PATH=enp5s0
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * ID_NET_NAME_SLOT=ens1
a276e6d68606861b552140cbcc003f4af10626fcTom Gundersen * PCI ethernet multi-function card with 2 ports:
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/net/enp2s0f0
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * ID_NET_NAME_MAC=enx78e7d1ea46da
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_PATH=enp2s0f0
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/net/enp2s0f1
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_MAC=enx78e7d1ea46dc
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_PATH=enp2s0f1
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * PCI wlan card:
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlp3s0
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_MAC=wlx0024d7e31130
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_PATH=wlp3s0
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * USB built-in 3G modem:
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.6/net/wwp0s29u1u4i6
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_MAC=wwx028037ec0200
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_PATH=wwp0s29u1u4i6
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * USB Android phone:
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/net/enp0s29u1u2
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt * ID_NET_NAME_MAC=enxd626b3450fb5
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt * ID_NET_NAME_PATH=enp0s29u1u2
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt/* retrieve on-board index number and label from firmware */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktstatic int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt unsigned dev_port = 0;
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt const char *attr;
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt /* ACPI _DSM -- device specific method for naming a PCI or PCI Express device */
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt attr = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt /* SMBIOS type 41 -- Onboard Devices Extended Information */
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt attr = udev_device_get_sysattr_value(names->pcidev, "index");
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* kernel provided multi-device index */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt attr = udev_device_get_sysattr_value(dev, "dev_port");
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt names->pci_onboard_label = udev_device_get_sysattr_value(names->pcidev, "label");
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt/* read the 256 bytes PCI configuration space to check the multi-function bit */
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktstatic bool is_pci_multifunction(struct udev_device *dev) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt filename = strjoina(udev_device_get_syspath(dev), "/config");
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt return false;
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt return false;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt /* bit 0-6 header type, bit 7 multi/single function device */
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt return true;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt return false;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flyktstatic int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt struct udev *udev = udev_device_get_udev(names->pcidev);
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt unsigned domain, bus, slot, func, dev_port = 0;
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt const char *attr;
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4)
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* kernel provided multi-device index */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt attr = udev_device_get_sysattr_value(dev, "dev_port");
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* compose a name based on the raw kernel's PCI bus, slot numbers */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt if (func > 0 || is_pci_multifunction(names->pcidev))
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* ACPI _SUN -- slot user number */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt pci = udev_device_new_from_subsystem_sysname(udev, "subsystem", "pci");
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt snprintf(slots, sizeof(slots), "%s/slots", udev_device_get_syspath(pci));
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt snprintf(str, sizeof(str), "%s/%s/address", slots, dent->d_name);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* match slot address with device by stripping the function */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address)))
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt if (func > 0 || is_pci_multifunction(names->pcidev))
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktstatic int names_pci(struct udev_device *dev, struct netnames *names) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* check if our direct parent is a PCI device with no other bus in-between */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt if (streq_ptr("pci", udev_device_get_subsystem(parent))) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt names->pcidev = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktstatic int names_usb(struct udev_device *dev, struct netnames *names) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface");
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt /* get USB port number chain, configuration, interface */
a9aff3615b430f86bd0a824214d95f634efaf894Patrik Flykt strscpy(name, sizeof(name), udev_device_get_sysname(usbdev));
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt s[0] = '\0';
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt s[0] = '\0';
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* prefix every port number in the chain with "u" */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt l = strpcpyl(&s, sizeof(names->usb_ports), "u", ports, NULL);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* append USB config number, suppress the common config == 1 */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt l = strpcpyl(&s, sizeof(names->usb_ports), "c", config, NULL);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* append USB interface number, suppress the interface == 0 */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flyktstatic int names_bcma(struct udev_device *dev, struct netnames *names) {
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt unsigned int core;
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt bcmadev = udev_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL);
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* bus num:core num */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*u:%u", &core) != 1)
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt /* suppress the common core == 0 */
d1b0afe3653b4316a6361d204169620726d468a0Patrik Flykt snprintf(names->bcma_core, sizeof(names->bcma_core), "b%u", core);
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktstatic int names_ccw(struct udev_device *dev, struct netnames *names) {
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Retrieve the associated CCW device */
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Network devices are always grouped CCW devices */
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt if (!streq_ptr("ccwgroup", udev_device_get_subsystem(cdev)))
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Retrieve bus-ID of the grouped CCW device. The bus-ID uniquely
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * identifies the network device on the Linux on System z channel
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * subsystem. Note that the bus-ID contains lowercase characters.
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Check the length of the bus-ID. Rely on that the kernel provides
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * a correct bus-ID; alternatively, improve this check and parse and
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt * verify each bus-ID part...
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt if (!bus_id_len || bus_id_len < 8 || bus_id_len > 9)
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt /* Store the CCW bus-ID for use as network device name */
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "ccw%s", bus_id);
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt if (rc >= 0 && rc < (int)sizeof(names->ccw_group))
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flyktstatic int names_mac(struct udev_device *dev, struct netnames *names) {
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt const char *s;
f12abb48fc510b8b349c05e35ba048134debaf25Patrik Flykt unsigned int i;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* check for NET_ADDR_PERM, skip random MAC addresses */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt s = udev_device_get_sysattr_value(dev, "addr_assign_type");
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt s = udev_device_get_sysattr_value(dev, "address");
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (sscanf(s, "%x:%x:%x:%x:%x:%x", &a1, &a2, &a3, &a4, &a5, &a6) != 6)
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* skip empty MAC addresses */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt/* IEEE Organizationally Unique Identifier vendor string */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flyktstatic int ieee_oui(struct udev_device *dev, struct netnames *names, bool test) {
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* skip commonly misused 00:00:00 (Xerox) prefix */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt snprintf(str, sizeof(str), "OUI:%02X%02X%02X%02X%02X%02X",
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_hwdb_lookup(dev, NULL, str, NULL, test);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flyktstatic int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool test) {
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt const char *s;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt const char *p;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt unsigned int i;
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* handle only ARPHRD_ETHER and ARPHRD_SLIP devices */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt s = udev_device_get_sysattr_value(dev, "type");
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt switch (i) {
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* skip stacked devices, like VLANs, ... */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt s = udev_device_get_sysattr_value(dev, "ifindex");
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt p = udev_device_get_sysattr_value(dev, "iflink");
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt snprintf(str, sizeof(str), "%sx%02x%02x%02x%02x%02x%02x", prefix,
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_MAC", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* get path names for Linux on System z network devices */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s", prefix, names.ccw_group) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* get PCI based path names, we compose only PCI based paths */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* plain PCI device */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_onboard) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_ONBOARD", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_onboard_label) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_LABEL_ONBOARD", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_path) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_slot) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* USB device */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.usb_ports) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.usb_ports) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt /* Broadcom bus */
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.bcma_core) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.bcma_core) < (int)sizeof(str))
631bbe71298ec892f77f44f94feb612646fe6853Patrik Flykt udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);