]> git.ipfire.org Git - thirdparty/systemd.git/commit - man/systemd.net-naming-scheme.xml
udev: net_id: Use devicetree aliases when available
authorSean Anderson <sean.anderson@seco.com>
Tue, 9 Aug 2022 17:38:26 +0000 (13:38 -0400)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Aug 2022 09:15:16 +0000 (11:15 +0200)
commit65c2ad985a8debdf6d7d11fee5b466f280260f4b
tree77a832a92d2e15361926f6cc4b7af3ec8be84545
parentd9c6956ee4c10b76b4ed4ae32550e15a300172f3
udev: net_id: Use devicetree aliases when available

Devicetree firmware contains an "aliases" node, containing various
aliases for devices described by the firmware. For ethernet devices,
these are named "ethernet0", "ethernet1", etc. They provide a convenient
means of numbering ethernet devices, especially on systems with no other
stable number other than the address. In particular, U-Boot already uses
these aliases to name its ethernet devices.

Previously, there have been attempts (such as [1]) to add support for
these aliases to Linux. However, these patches have been rejected
because it is the maintainers' view that naming policy be left to
userspace. Well, systemd is userspace, so here we are.

In terms of implementation, apparently there can be multiple device
trees at once. I have decided to dodge this problem for now, and just
use /proc/device-tree. If it is desired to support multiple device trees
later, then the scheme can be modified to include the device tree's
index. For example, /sys/firmware/devicetree/base2/aliases/ethernet3
might be named enb2d3.

For the moment we only support "ethernetX" aliases. Future patches might
want to also handle "canX" and "wifiX".

It is common on boards with only one ethernet device to use an alias of
just "ethernet". In this case, the index is an implicit 0. In case the
author of the firmware made a mistake, we check to ensure that aliases
of "ethernet" and "ethernet0" do not both exist.

[1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/1399390594-1409-1-git-send-email-boris.brezillon@free-electrons.com/

Closes: #17625
man/systemd.net-naming-scheme.xml
src/shared/netif-naming-scheme.c
src/shared/netif-naming-scheme.h
src/udev/udev-builtin-net_id.c