summaryrefslogtreecommitdiffstats
path: root/src/core/cachedhcp.c
diff options
context:
space:
mode:
authorMichael Brown2022-12-22 16:12:34 +0100
committerMichael Brown2022-12-22 16:12:34 +0100
commit7147532c3fbf9a7061e74549f6f920a91ca9a80d (patch)
treeb94bdf57d6379b8a4ac11c09fbb7247e88701f09 /src/core/cachedhcp.c
parent[cachedhcp] Include VLAN tag in filter for applying cached DHCPACK (diff)
downloadipxe-7147532c3fbf9a7061e74549f6f920a91ca9a80d.tar.gz
ipxe-7147532c3fbf9a7061e74549f6f920a91ca9a80d.tar.xz
ipxe-7147532c3fbf9a7061e74549f6f920a91ca9a80d.zip
[cachedhcp] Retain cached DHCPACK after startup if not already consumed
We currently free an unclaimed cached DHCPACK immediately after startup, in order to free up memory. This prevents the cached DHCPACK from being applied to a device that is created after startup, such as a VLAN device created via the "vcreate" command. Retain any unclaimed DHCPACK after startup to allow it to be matched against (and applied to) any device that gets created at runtime. Free the DHCPACK during shutdown if it still remains unclaimed, in order to exit with memory cleanly freed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/cachedhcp.c')
-rw-r--r--src/core/cachedhcp.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c
index ef214662..60213f02 100644
--- a/src/core/cachedhcp.c
+++ b/src/core/cachedhcp.c
@@ -246,31 +246,49 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
}
/**
- * Cached DHCPACK startup function
+ * Cached DHCP packet startup function
*
*/
static void cachedhcp_startup ( void ) {
/* Apply cached ProxyDHCPOFFER, if any */
cachedhcp_apply ( &cached_proxydhcp, NULL );
+ cachedhcp_free ( &cached_proxydhcp );
/* Apply cached PXEBSACK, if any */
cachedhcp_apply ( &cached_pxebs, NULL );
+ cachedhcp_free ( &cached_pxebs );
- /* Free any remaining cached packets */
+ /* Report unclaimed DHCPACK, if any. Do not free yet, since
+ * it may still be claimed by a dynamically created device
+ * such as a VLAN device.
+ */
if ( cached_dhcpack.dhcppkt ) {
DBGC ( colour, "CACHEDHCP %s unclaimed\n",
cached_dhcpack.name );
}
+}
+
+/**
+ * Cached DHCP packet shutdown function
+ *
+ * @v booting System is shutting down for OS boot
+ */
+static void cachedhcp_shutdown ( int booting __unused ) {
+
+ /* Free cached DHCPACK, if any */
+ if ( cached_dhcpack.dhcppkt ) {
+ DBGC ( colour, "CACHEDHCP %s never claimed\n",
+ cached_dhcpack.name );
+ }
cachedhcp_free ( &cached_dhcpack );
- cachedhcp_free ( &cached_proxydhcp );
- cachedhcp_free ( &cached_pxebs );
}
/** Cached DHCPACK startup function */
struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
.name = "cachedhcp",
.startup = cachedhcp_startup,
+ .shutdown = cachedhcp_shutdown,
};
/**