On 23/10/2024 22:58, John Kyle Cronan wrote:
Hi all, This is not an especially serious issue, but maybe I can get to the bottom of it. I was using the Mediatek mt76 wireless driver with one of the newer cards that presents multiple interfaces, one for 2.4g and one for 5g. I noticed that the usual udev setup with systemd was not naming them in a way that makes sense: one is wlp59s0 and the other is wlan0. So I investigated, and found that udev doesn't have access to any information that could distinguish the two interfaces that share the same PCI port path. Here's the issue I opened with the Mediatek maintainer: https://github.com/nbd168/wireless/issues/12 "Systemd assigns the first, wlp59s0, using the path-based name, but then the second one tries to assign its name in the same manner and it conflicts, so it has to fall back to wlan0." I took a look at the kernel sources for this area, as best I can understand them, and made the suggestion to set a netdev phys_port_id attribute uniquely for each interface. That would result in wlp59s0n0 and wlp59s0n1. (There appear to be two other possible methods, though, corresponding to 'f' function and 'd' device port. Unfortunately I never made it that far, trying to learn the implementation details.) I got the response, "the driver is not responsible for managing netdevs and their attributes - that's all handled by the mac80211 stack. What the driver does is register two ieee80211 wiphys on the same PCIe device. There are no separate devices here, because on a PCI level, there is no isolation at all. It really is a single device. The wiphys operate independently from each other, so naturally the auto-created netdevs do so as well. ... Not sure what the solution is here." Is this the 802.11 stack's concern, or the device drivers'? How could udev get the info to distinguish these network interfaces, and which approach is the right one for wireless devices?
Udev is already confused with multiple vifs on a single phy on a single device. It is somewhat mitigated by name_assign_type and manually specifying vif names, but this is really a udev problem, it need to be smarter.
Now there are multiple phy on a single device, and those are the kind of devices that people will want to use with multiple vifs per phy: people mostly use them in access point mode, with maybe multiple SSIDs per band.
For mt76, currently the only reliable way to distinguish the 2.4 GHz phy from the 5/6 GHz phy is that the 2.4 GHz phy is always created first (there are no possible races), so incrementally numbering the default vifs will create a stable output.
Maybe there should be a phy field to locally number the phys of a single device. A bit like phys_port_id for netdevs.