Some thoughts about network interface naming

A debate about how (and if at all) network interfaces should be labeled by the kernel is currently taking place on the netdev Linux kernel mailing list. Because this is not typically something OpenWrt users are following, I thought it be a good idea to make more users aware of that, as in the end, the argument goes very much around what users are expecting or would like to see. So why not give them a voice?

See whole debate here: https://lore.kernel.org/netdev/20240709124503.pubki5nwjfbedhhy@skbuf/

Quotes:

Why not just not use the 'label' device tree property, and bring
a decent udev implementation into OpenWrt which can handle persistent
naming according to the labels on the box? Even within DSA, it is
considered better practice to use udev rather than 'label'. Not to
mention that once available, udev is a uniform solution for all network
interfaces, unlike 'label'.
Sounds fine generally. Where would you store the device-specific renaming
rules while making sure you don't need to carry the rules for all devices
onto every single device? Would you generate a device-specific rootfs for
each and every device? For obvious reasons this is something we'd very
much like to avoid, as building individual filesystems for ~ 1000 devices
would be insane compared to having a bunch (< 100) of generic filesystems
which some of them fitting a large group (ie. same SoC) of boards.
Most OpenWrt devices out there are based on the same SoCs, so currently
the devices in the popular targets like MT7621 or IPQ40xx all share the
same target-wide kernel and rootfs.

tl;dr: The good thing about the 'label' property is certainly that such
board- specific details are kept in DT, and hence a generic rootfs can
deal with it.

As having the 'label' property applied also for non-DSA netdevs by the
kernel has been rejected we did come up with a simple userland
implementation:

https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=2a25c6ace8d833cf491a66846a0b9e7c5387b8f0

For interfaces added at a later stage at boot, ie. by loading kernel modules
or actual hotplug, we could do the same in a hotplug script.

So yes, dropping support for dealing with the 'label' property in kernel
entirely would also fix it for us, because then we would just always deal
with it in userland (still using the same property in DT, just not applied
by the kernel).

2 thoughts come to my mind.

First there is the focus on the user, which in the case of OpenWrt is
the home user. What does he want? We are debating where to put a fixed
Ethernet interface name, but does the user want it to be fixed?
Like, if I were looking in my system log, I would certainly prefer if I
saw 'Network device 'printer'/'nas'/'pc' link is up' rather than 'eth1',
even if it says 'eth1' on the chassis.

With that in mind, I would say it would be preferable to ship
architecture-wide udev naming rules, which essentially give each
netdev a predictable name according to its SoC position. Then give
the user the possibility to use that udev rule file as a framework
and name the interfaces as he wishes. The OpenWrt wiki for a board can
list a diagram with the correlations between SoC interface names and
chassis labels, in case the user desires to preserve that (the board
will be used on a bench and the labels will always be visible, rather
than being more easily recognizable by their role).

Then there is the fact that we are dealing with low-cost boards with
low-cost/low-effort design. Ilya Lipnitskiy brought forward a case where
the chassis had labeled the ports 'eth0', 'eth1', 'eth2', ..., which is
clearly a design problem since it conflicts with the way in which the
kernel naturally wants to name the devices ('eth0' is the initial name
for the DSA master, but also the chassis label for a DSA user port...
yay...).

I don't honestly think you can/should fix low-effort design.

But, if you insist that putting fixed netdev names in the device tree is
the best option, I suppose that could be considered a low-effort
solution which belongs to the same general theme.

But I don't see why not go low-cost all the way. Since 'label creates
(avoidable) conflicts with DSA, why don't you just name all of them
'openwrt,netdev-name' or something, and proudly own that low-cost
solution as a downstream scheme which needs no kernel support
whatsoever (you parse it from the init scripts as you already do)?
U-Boot also is another example of a project which uses additional device
tree properties for its own purpose.

To me, a custom downstream property openwrt,netdev-name sounds fine, it could be handled entirely in userspace (see link to commit in quoted text above).

Opinions welcome :wink:

It is not openwrt's invention to print labels on ports.

1 Like