/* SPDX-License-Identifier: LGPL-2.1+ */
/*
* 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
*
* http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
*
* Two character prefixes based on the type of interface:
* en — Ethernet
* ib — InfiniBand
* sl — serial line IP (slip)
* wl — wlan
* ww — wwan
*
* Type of names:
* b<number> — BCMA bus core number
* c<bus_id> — bus id of a grouped CCW or CCW device,
* with all leading zeros stripped [s390]
* o<index>[n<phys_port_name>|d<dev_port>]
* — on-board device index number
* s<slot>[f<function>][n<phys_port_name>|d<dev_port>]
* — hotplug slot index number
* x<MAC> — MAC address
* [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>]
* — PCI geographical location
* [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
* — USB port number chain
* v<slot> - VIO slot number (IBM PowerVM)
* a<vendor><model>i<instance> — Platform bus ACPI instance id
*
* All multi-function PCI devices will carry the [f<function>] number in the
* device name, including the function 0 device.
*
* SR-IOV virtual devices are named based on the name of the parent interface,
* with a suffix of "v<N>", where <N> is the virtual device number.
*
* When using PCI geography, The PCI domain is only prepended when it is not 0.
*
* 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 "1":
* ID_NET_NAME_ONBOARD=eno1
* ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1
*
* 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
*
* PCI Ethernet multi-function card with 2 ports:
* /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/net/enp2s0f0
* ID_NET_NAME_MAC=enx78e7d1ea46da
* ID_NET_NAME_PATH=enp2s0f0
* /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/net/enp2s0f1
* ID_NET_NAME_MAC=enx78e7d1ea46dc
* ID_NET_NAME_PATH=enp2s0f1
*
* 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
*
* PCI IB host adapter with 2 ports:
* /sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/net/ibp21s0f0
* ID_NET_NAME_PATH=ibp21s0f0
* /sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/net/ibp21s0f1
* ID_NET_NAME_PATH=ibp21s0f1
*
* 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
*
* s390 grouped CCW interface:
* /sys/devices/css0/0.0.0007/0.0.f5f0/group_device/net/encf5f0
* ID_NET_NAME_MAC=enx026d3c00000a
* ID_NET_NAME_PATH=encf5f0
*/
https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L20
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
上面一段是systemd源码的注释
p3s0代表PCI接口的物理位置为(3, 0), 其中横坐标代表bus,纵坐标代表slot
[root@ka1che225 ~]# rpm -qa|grep biosdev
biosdevname-0.7.2-2.el7.x86_64
[root@ka1che225 ~]# rpm -ql biosdevname
/usr/lib/udev/rules.d/71-biosdevname.rules
/usr/sbin/biosdevname
/usr/share/doc/biosdevname-0.7.2
/usr/share/doc/biosdevname-0.7.2/COPYING
/usr/share/doc/biosdevname-0.7.2/README
/usr/share/man/man1/biosdevname.1.gz
[root@ali-1 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp50s0f 0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond2 portid 0894ef73ea6e state UP qlen 1000
link/ether 08:94:ef:73:ea:6e brd ff:ff:ff:ff:ff:ff
3: enp50s0f 1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq portid 0894ef73ea6f state UP qlen 1000
link/ether 08:94:ef:73:ea:6f brd ff:ff:ff:ff:ff:ff
inet6 fe80::a94:efff:fe73:ea6f/64 scope link
valid_lft forever preferred_lft forever
4: enp50s0f 2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq portid 0894ef73ea70 state DOWN qlen 1000
link/ether 08:94:ef:73:ea:70 brd ff:ff:ff:ff:ff:ff
5: enp28s0f 0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
link/ether 90:e2:ba:88:f0:a4 brd ff:ff:ff:ff:ff:ff
6: enp50s0f 3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq portid 0894ef73ea71 state DOWN qlen 1000
link/ether 08:94:ef:73:ea:71 brd ff:ff:ff:ff:ff:ff
7: enp28s0f 1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP qlen 1000
link/ether 90:e2:ba:88:f0:a5 brd ff:ff:ff:ff:ff:ff
8: enp46s0f 0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
link/ether 90:e2:ba:88:f0:a4 brd ff:ff:ff:ff:ff:ff
9: enp46s0f 1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond1 state UP qlen 1000
link/ether 90:e2:ba:88:f0:a5 brd ff:ff:ff:ff:ff:ff