]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cachedhcp] Automatically open network device matching cached DHCPACK
authorMichael Brown <mcb30@ipxe.org>
Thu, 26 Feb 2026 13:11:57 +0000 (13:11 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 26 Feb 2026 13:11:57 +0000 (13:11 +0000)
It is unintuitive to have to include an "ifopen" at the start of an
autoexec.ipxe script.  Provide a mechanism for upper-layer drivers to
mark a network device to be opened automatically upon registration,
and do so for the device to which the cached DHCPACK is applied.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/cachedhcp.c
src/include/ipxe/netdevice.h
src/net/netdevice.c

index 3f6564efd3d6580cc79b297cdfdb687afdc95215..21cb382ada9ec28aa029dc37bcf0181e9fe8c026 100644 (file)
@@ -171,6 +171,9 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache,
                settings = netdev_settings ( netdev );
                DBGC ( colour, "CACHEDHCP %s is for %s\n",
                       cache->name, netdev->name );
+
+               /* Mark network device to be opened automatically */
+               netdev->state |= NETDEV_AUTO_OPEN;
        }
 
        /* Register settings */
index 62f0dd1f76b9260b3c600ca31983a101db9305db..ebd54658ba0a6d7230abd12f8cc5d9705b6a74ce 100644 (file)
@@ -461,6 +461,9 @@ struct net_device {
 /** Network device must be polled even when closed */
 #define NETDEV_INSOMNIAC 0x0040
 
+/** Network device should be opened automatically */
+#define NETDEV_AUTO_OPEN 0x0080
+
 /** Link-layer protocol table */
 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
 
index 0af916ff5c2fe9bde7df4386af0a5504bd20a442..af0debd5af3e2072450907a1b46197cd45fb86e4 100644 (file)
@@ -836,6 +836,10 @@ int register_netdev ( struct net_device *netdev ) {
                }
        }
 
+       /* Attempt to open device automatically, if applicable */
+       if ( netdev->state & NETDEV_AUTO_OPEN )
+               netdev_open ( netdev );
+
        return 0;
 
  err_probe: