summaryrefslogtreecommitdiffstats
path: root/src/shared/netif-naming-scheme.c
diff options
context:
space:
mode:
authorSean Anderson <sean.anderson@seco.com>2022-08-09 19:38:26 +0200
committerLennart Poettering <lennart@poettering.net>2022-08-12 11:15:16 +0200
commit65c2ad985a8debdf6d7d11fee5b466f280260f4b (patch)
tree77a832a92d2e15361926f6cc4b7af3ec8be84545 /src/shared/netif-naming-scheme.c
parentMerge pull request #24280 from mrc0mmand/fix-semaphore (diff)
downloadsystemd-65c2ad985a8debdf6d7d11fee5b466f280260f4b.tar.xz
systemd-65c2ad985a8debdf6d7d11fee5b466f280260f4b.zip
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
Diffstat (limited to 'src/shared/netif-naming-scheme.c')
-rw-r--r--src/shared/netif-naming-scheme.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c
index e95072e048..18748e5376 100644
--- a/src/shared/netif-naming-scheme.c
+++ b/src/shared/netif-naming-scheme.c
@@ -24,6 +24,7 @@ static const NamingScheme naming_schemes[] = {
{ "v249", NAMING_V249 },
{ "v250", NAMING_V250 },
{ "v251", NAMING_V251 },
+ { "v252", NAMING_V252 },
/* … add more schemes here, as the logic to name devices is updated … */
EXTRA_NET_NAMING_MAP