summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/core/cachedhcp.c
diff options
context:
space:
mode:
authorMichael Brown2013-11-08 13:45:22 +0100
committerMichael Brown2013-11-08 13:45:22 +0100
commitc3d1e7869731c8cccb041ce05ee0ebbb3dc375d5 (patch)
tree83db0c631943bfec85a0062a86ebb29308ffa02c /src/arch/i386/core/cachedhcp.c
parent[cmdline] Generate command option help text automatically (diff)
downloadipxe-c3d1e7869731c8cccb041ce05ee0ebbb3dc375d5.tar.gz
ipxe-c3d1e7869731c8cccb041ce05ee0ebbb3dc375d5.tar.xz
ipxe-c3d1e7869731c8cccb041ce05ee0ebbb3dc375d5.zip
[pxe] Ensure cached DHCPACK is retrieved prior to network device creation
The retrieval of the cached DHCPACK and the creation of network devices are both currently scheduled as STARTUP_NORMAL. It is therefore possible that the cached DHCPACK will not be retrieved in time for cachedhcp_probe() to apply it to the relevant network device. Fix by retrieving the cached DHCPACK at initialisation time rather than at startup time. As an optimisation, an unclaimed cached DHCPACK can be freed immediately after the last network device has been created, rather than waiting until shutdown. Reported-by: Espen Braastad <espen.braastad@redpill-linpro.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/core/cachedhcp.c')
-rw-r--r--src/arch/i386/core/cachedhcp.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/arch/i386/core/cachedhcp.c b/src/arch/i386/core/cachedhcp.c
index b967e9b9..3cac28e7 100644
--- a/src/arch/i386/core/cachedhcp.c
+++ b/src/arch/i386/core/cachedhcp.c
@@ -50,7 +50,7 @@ static struct dhcp_packet *cached_dhcpack;
* Cached DHCPACK startup function
*
*/
-static void cachedhcp_startup ( void ) {
+static void cachedhcp_init ( void ) {
struct dhcp_packet *dhcppkt;
struct dhcp_packet *tmp;
struct dhcphdr *dhcphdr;
@@ -98,13 +98,14 @@ static void cachedhcp_startup ( void ) {
}
/**
- * Cached DHCPACK shutdown function
+ * Cached DHCPACK startup function
*
- * @v booting Shutting down in order to boot
*/
-static void cachedhcp_shutdown ( int booting __unused ) {
+static void cachedhcp_startup ( void ) {
- /* If cached DHCP packet has not yet been claimed, free it */
+ /* If cached DHCP packet was not claimed by any network device
+ * during startup, then free it.
+ */
if ( cached_dhcpack ) {
DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" );
dhcppkt_put ( cached_dhcpack );
@@ -113,9 +114,13 @@ static void cachedhcp_shutdown ( int booting __unused ) {
}
/** Cached DHCPACK initialisation function */
-struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
+struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = {
+ .initialise = cachedhcp_init,
+};
+
+/** Cached DHCPACK startup function */
+struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
.startup = cachedhcp_startup,
- .shutdown = cachedhcp_shutdown,
};
/**