Browse Source

[dhcp] Perform ProxyDHCP only if we do not already have PXE options

This prevents gPXE from wasting time attempting to contact a ProxyDHCP
server on port 4011 if the DHCP response already contains the relevant
PXE options.  This behaviour is hinted at (though not explicitly
specified) in the PXE spec, and seems to match what the Intel client
does.

Suggested-by: Simon Kelley <simon@thekelleys.org.uk>
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
9119b0c8af
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/net/udp/dhcp.c

+ 6
- 2
src/net/udp/dhcp.c View File

335
 	char vci[9]; /* "PXEClient" */
335
 	char vci[9]; /* "PXEClient" */
336
 	int vci_len;
336
 	int vci_len;
337
 	int has_pxeclient;
337
 	int has_pxeclient;
338
+	int pxeopts_len;
339
+	int has_pxeopts;
338
 	int8_t priority = 0;
340
 	int8_t priority = 0;
339
 	uint8_t no_pxedhcp = 0;
341
 	uint8_t no_pxedhcp = 0;
340
 	unsigned long elapsed;
342
 	unsigned long elapsed;
355
 				  vci, sizeof ( vci ) );
357
 				  vci, sizeof ( vci ) );
356
 	has_pxeclient = ( ( vci_len >= ( int ) sizeof ( vci ) ) &&
358
 	has_pxeclient = ( ( vci_len >= ( int ) sizeof ( vci ) ) &&
357
 			  ( strncmp ( "PXEClient", vci, sizeof (vci) ) == 0 ));
359
 			  ( strncmp ( "PXEClient", vci, sizeof (vci) ) == 0 ));
360
+	pxeopts_len = dhcppkt_fetch ( dhcppkt, DHCP_VENDOR_ENCAP, NULL, 0 );
361
+	has_pxeopts = ( pxeopts_len >= 0 );
358
 	if ( has_pxeclient )
362
 	if ( has_pxeclient )
359
-		DBGC ( dhcp, " pxe" );
363
+		DBGC ( dhcp, "%s", ( has_pxeopts ? " pxe" : " proxy" ) );
360
 
364
 
361
 	/* Identify priority */
365
 	/* Identify priority */
362
 	dhcppkt_fetch ( dhcppkt, DHCP_EB_PRIORITY, &priority,
366
 	dhcppkt_fetch ( dhcppkt, DHCP_EB_PRIORITY, &priority,
382
 	}
386
 	}
383
 
387
 
384
 	/* Select as ProxyDHCP offer, if applicable */
388
 	/* Select as ProxyDHCP offer, if applicable */
385
-	if ( has_pxeclient && ( msgtype == DHCPOFFER ) &&
389
+	if ( has_pxeclient && ( ! has_pxeopts ) && ( msgtype == DHCPOFFER ) &&
386
 	     ( priority >= dhcp->proxy_priority ) ) {
390
 	     ( priority >= dhcp->proxy_priority ) ) {
387
 		dhcp->proxy_server = server_id;
391
 		dhcp->proxy_server = server_id;
388
 		dhcp->proxy_priority = priority;
392
 		dhcp->proxy_priority = priority;

Loading…
Cancel
Save