]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: Extend persistent naming support to MCTP interfaces
authorJeremy Kerr <jk@codeconstruct.com.au>
Fri, 11 Jul 2025 01:34:05 +0000 (09:34 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 18 Dec 2025 09:54:51 +0000 (10:54 +0100)
Now that we have Management Component Transport Protocol (MCTP) transports
available over USB, it would be helpful to apply udev's persistent
naming rules to MCTP interfaces, to follow the USB hub/port topology.

Enable persistent naming for ARPHRD_MCTP-type devices, using a "mc" name
prefix, and add appropriate definitions for the v260 naming sheme.

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 9211e25aa17f2a94e9d79869ee2cc1a6e732b288..1a024a0c305db2367531565a4c2d73bf85516a9e 100644 (file)
             <entry><constant>ww</constant></entry>
             <entry>Wireless wide area network (WWAN)</entry>
           </row>
+          <row>
+            <entry><constant>mc</constant></entry>
+            <entry>Management Component Transport Protocol (MCTP)</entry>
+          </row>
         </tbody>
       </tgroup>
     </table>
           <xi:include href="version-info.xml" xpointer="v259"/>
           </listitem>
         </varlistentry>
+
+        <varlistentry>
+          <term><constant>v260</constant></term>
+
+          <listitem><para>MCTP interfaces are now assigned persistent names, using a <constant>mc</constant>
+          prefix.</para>
+
+          <xi:include href="version-info.xml" xpointer="v260"/>
+          </listitem>
+        </varlistentry>
       </variablelist>
 
     <para>Note that <constant>latest</constant> may be used to denote the latest scheme known (to this
index df16e69fb69c8b10bff21f2673c93197795f312f..607094eecfd296846561a0734e5878a28bf1dd88 100644 (file)
@@ -30,6 +30,7 @@ static const NamingScheme naming_schemes[] = {
         { "v257", NAMING_V257 },
         { "v258", NAMING_V258 },
         { "v259", NAMING_V259 },
+        { "v260", NAMING_V260 },
         /* … add more schemes here, as the logic to name devices is updated … */
 
         EXTRA_NET_NAMING_MAP
index 8448c4e9572e2a8a50cd333c49a2920f0c7db688..a25b707b1c95e87dda85b8295ce657c68cb88d61 100644 (file)
@@ -43,6 +43,7 @@ typedef enum NamingSchemeFlags {
         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 */
+        NAMING_MCTP                      = 1 << 22, /* Use "mc" prefix for MCTP devices */
 
         /* And now the masks that combine the features above */
         NAMING_V238 = 0,
@@ -65,6 +66,7 @@ typedef enum NamingSchemeFlags {
         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,
+        NAMING_V260 = NAMING_V259 | NAMING_MCTP,
 
         EXTRA_NET_NAMING_SCHEMES
 
index a41ecb1d43c2a8b238053efaea2cf74f090f4d04..d93849f332603024e48faf40fca3cb59585a670b 100644 (file)
@@ -1307,7 +1307,7 @@ static int get_ifname_prefix(sd_device *dev, const char **ret) {
         if (r < 0)
                 return r;
 
-        /* handle only ARPHRD_ETHER, ARPHRD_SLIP and ARPHRD_INFINIBAND devices */
+        /* handle only ARPHRD_ETHER, ARPHRD_SLIP, ARPHRD_INFINIBAND, and ARPHDR_MCTP devices */
         switch (iftype) {
         case ARPHRD_ETHER: {
                 if (device_is_devtype(dev, "wlan") > 0)
@@ -1329,6 +1329,13 @@ static int get_ifname_prefix(sd_device *dev, const char **ret) {
                 *ret = "sl";
                 return 0;
 
+        case ARPHRD_MCTP:
+                if (!naming_scheme_has(NAMING_MCTP))
+                        return -EOPNOTSUPP;
+
+                *ret = "mc";
+                return 0;
+
         default:
                 return -EOPNOTSUPP;
         }