Browse Source

[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>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
c3d1e78697
1 changed files with 12 additions and 7 deletions
  1. 12
    7
      src/arch/i386/core/cachedhcp.c

+ 12
- 7
src/arch/i386/core/cachedhcp.c View File

50
  * Cached DHCPACK startup function
50
  * Cached DHCPACK startup function
51
  *
51
  *
52
  */
52
  */
53
-static void cachedhcp_startup ( void ) {
53
+static void cachedhcp_init ( void ) {
54
 	struct dhcp_packet *dhcppkt;
54
 	struct dhcp_packet *dhcppkt;
55
 	struct dhcp_packet *tmp;
55
 	struct dhcp_packet *tmp;
56
 	struct dhcphdr *dhcphdr;
56
 	struct dhcphdr *dhcphdr;
98
 }
98
 }
99
 
99
 
100
 /**
100
 /**
101
- * Cached DHCPACK shutdown function
101
+ * Cached DHCPACK startup function
102
  *
102
  *
103
- * @v booting		Shutting down in order to boot
104
  */
103
  */
105
-static void cachedhcp_shutdown ( int booting __unused ) {
104
+static void cachedhcp_startup ( void ) {
106
 
105
 
107
-	/* If cached DHCP packet has not yet been claimed, free it */
106
+	/* If cached DHCP packet was not claimed by any network device
107
+	 * during startup, then free it.
108
+	 */
108
 	if ( cached_dhcpack ) {
109
 	if ( cached_dhcpack ) {
109
 		DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" );
110
 		DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" );
110
 		dhcppkt_put ( cached_dhcpack );
111
 		dhcppkt_put ( cached_dhcpack );
113
 }
114
 }
114
 
115
 
115
 /** Cached DHCPACK initialisation function */
116
 /** Cached DHCPACK initialisation function */
116
-struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
117
+struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = {
118
+	.initialise = cachedhcp_init,
119
+};
120
+
121
+/** Cached DHCPACK startup function */
122
+struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
117
 	.startup = cachedhcp_startup,
123
 	.startup = cachedhcp_startup,
118
-	.shutdown = cachedhcp_shutdown,
119
 };
124
 };
120
 
125
 
121
 /**
126
 /**

Loading…
Cancel
Save