Przeglądaj źródła

[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 lat temu
rodzic
commit
c3d1e78697
1 zmienionych plików z 12 dodań i 7 usunięć
  1. 12
    7
      src/arch/i386/core/cachedhcp.c

+ 12
- 7
src/arch/i386/core/cachedhcp.c Wyświetl plik

@@ -50,7 +50,7 @@ static struct dhcp_packet *cached_dhcpack;
50 50
  * Cached DHCPACK startup function
51 51
  *
52 52
  */
53
-static void cachedhcp_startup ( void ) {
53
+static void cachedhcp_init ( void ) {
54 54
 	struct dhcp_packet *dhcppkt;
55 55
 	struct dhcp_packet *tmp;
56 56
 	struct dhcphdr *dhcphdr;
@@ -98,13 +98,14 @@ static void cachedhcp_startup ( void ) {
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 109
 	if ( cached_dhcpack ) {
109 110
 		DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" );
110 111
 		dhcppkt_put ( cached_dhcpack );
@@ -113,9 +114,13 @@ static void cachedhcp_shutdown ( int booting __unused ) {
113 114
 }
114 115
 
115 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 123
 	.startup = cachedhcp_startup,
118
-	.shutdown = cachedhcp_shutdown,
119 124
 };
120 125
 
121 126
 /**

Ładowanie…
Anuluj
Zapisz