]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: Add DeviceTree-based names for WLAN devices 39060/head
authordramforever <dramforever@live.com>
Fri, 19 Sep 2025 13:52:00 +0000 (21:52 +0800)
committerdramforever <dramforever@live.com>
Tue, 23 Sep 2025 19:13:32 +0000 (03:13 +0800)
Add support for generating names like wldN based on DeviceTree aliases.

DeviceTree alias names follow de facto conventions. As of writing, there
are so far two ways WLAN devices are represented in DeviceTree aliases
in upstream Linux DTS files:

- Firstly, as wifi0, used for example in t600x-j314-j316.dtsi
- Secondly, as ethernet0 or ethernet1, used for example in
  sun8i-q8-common.dtsi, with a comment saying the reason is to "Make
  u-boot set mac-address for wifi without an eeprom"

Therefore for prefix "wl", try alias_prefix "wifi" first, and if that
was not found, fall back to alias_prefix "ethernet"

Since this is a naming scheme change, also gate this behind
NAMING_DEVICETREE_ALIASES_WLAN and NAMING_V259, and document this
change.

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

index d21b858a5d436f7b47ae614d78eaa115c25852a2..9211e25aa17f2a94e9d79869ee2cc1a6e732b288 100644 (file)
           <xi:include href="version-info.xml" xpointer="v258"/>
           </listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><constant>v259</constant></term>
+
+          <listitem><para>The naming scheme based on devicetree aliases was extended to support WLAN devices.</para>
+
+          <xi:include href="version-info.xml" xpointer="v259"/>
+          </listitem>
+        </varlistentry>
       </variablelist>
 
     <para>Note that <constant>latest</constant> may be used to denote the latest scheme known (to this
index afa5b9d842f0a1a87f20700432dd41301f50e717..df16e69fb69c8b10bff21f2673c93197795f312f 100644 (file)
@@ -29,6 +29,7 @@ static const NamingScheme naming_schemes[] = {
         { "v255", NAMING_V255 },
         { "v257", NAMING_V257 },
         { "v258", NAMING_V258 },
+        { "v259", NAMING_V259 },
         /* … add more schemes here, as the logic to name devices is updated … */
 
         EXTRA_NET_NAMING_MAP
index 18696726c3d326b54e5cc506d34be2b229f2e561..504ffec5357bebc4871483c419baf497403841f6 100644 (file)
@@ -42,6 +42,7 @@ typedef enum NamingSchemeFlags {
         NAMING_FIRMWARE_NODE_SUN         = 1 << 18, /* Use firmware_node/sun to get PCI slot number */
         NAMING_DEVICETREE_PORT_ALIASES   = 1 << 19, /* Include aliases of OF nodes of a netdev itself, not just its parent. See PR #33958. */
         NAMING_USE_INTERFACE_PROPERTY    = 1 << 20, /* Use INTERFACE udev property, rather than sysname, when no renaming is requested. */
+        NAMING_DEVICETREE_ALIASES_WLAN   = 1 << 21, /* Generate names from devicetree aliases for WLAN devices */
 
         /* And now the masks that combine the features above */
         NAMING_V238 = 0,
@@ -63,6 +64,7 @@ typedef enum NamingSchemeFlags {
         NAMING_V255 = NAMING_V254 & ~NAMING_BRIDGE_MULTIFUNCTION_SLOT,
         NAMING_V257 = NAMING_V255 | NAMING_FIRMWARE_NODE_SUN | NAMING_DEVICETREE_PORT_ALIASES,
         NAMING_V258 = NAMING_V257 | NAMING_USE_INTERFACE_PROPERTY,
+        NAMING_V259 = NAMING_V258 | NAMING_DEVICETREE_ALIASES_WLAN,
 
         EXTRA_NET_NAMING_SCHEMES
 
index fd80538638e0855e2029b8efb7e04a430ea56e3e..0724de8241a2d9b22de88798db51376ef299476f 100644 (file)
@@ -910,7 +910,13 @@ static int names_devicetree(UdevEvent *event, const char *prefix) {
 
         if (streq(prefix, "en"))
                 r = names_devicetree_alias_prefix(event, prefix, "ethernet");
-        else
+        else if (naming_scheme_has(NAMING_DEVICETREE_ALIASES_WLAN) &&
+                 streq(prefix, "wl")) {
+                r = names_devicetree_alias_prefix(event, prefix, "wifi");
+                /* Sometimes DeviceTrees have WLAN devices with alias ethernetN, fall back to those */
+                if (r == 0)
+                        r = names_devicetree_alias_prefix(event, prefix, "ethernet");
+        } else
                 return -EOPNOTSUPP; /* Unsupported interface type */
         if (r < 0)
                 return r;