Re: [PATCH net-next v1 4/4] usbnet: add support for label from device tree

Sergey Ryazanov
2022-02-03T02:20:42Z

Hello Greg,

if I may be allowed, I would like to make a couple of points about
specifying network interface names in DT. As in previous mail, not to
defend this particular patch, but to talk about names assignment in
general.

I may be totally wrong, so consider my words as a request for
discussion. I have been thinking about an efficient way for network
device names assignment for routers with a fixed configuration and
have always come to a conclusion that DT is a good place for names
storage. Recent DSA capability to assign names from labels and this
patch by Oleksij show that I am not alone.

On Fri, Jan 28, 2022 at 3:34 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> And again, pick your names in userspace, embedded is not "special" here.

Embedded is not a special case, but fixed configuration is.

> You can do persistant network device names in a very trivial shell
> script if needed, we used to do it that way 18 years ago :)

Network device name is not a solely userspace entity. It is part of
the interface between the kernel and userspace software.

Sure, persistent names can be established with a userspace script. But
this implies the device renaming, which is a complex and race prone
task. Once I even found a comment in the kernel code that only network
devices could be renamed and this is a headache. As for userspace, it
is possible to workaround the device renaming issues. But this
requires a lot of code in many programs and sometimes even special
conventions on a programs interaction. E.g. consider a case where a
service would like to bind to a network interface, which is in the
middle of renaming by udev. On the other hand, we have the kernel that
could provide predictable names from the beginning for all software on
a host. So this is a desired option.

As for DT, this is an excellent database with perfectly established
relations to hardware configuration. And if we try to implement a
userspace storage with the network device names, then we will just
duplicate the DT in the userspace, as already was mentioned by
Oleksij. To me, implementation of a names database in userspace looks
more like reinventing the DT (wheel) than adding device names to the
DT.

To summarize, we (developers of embedded software) have two related needs:
1) the need for persistent names provided by the kernel,
2) using the DT as a source of persistent names for (1).

Greg, what do you think about device names storing in DeviceTree in
the above context? Does it still make no sense?

--
Sergey