瀏覽代碼

[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 年之前
父節點
當前提交
9119b0c8af
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6
    2
      src/net/udp/dhcp.c

+ 6
- 2
src/net/udp/dhcp.c 查看文件

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

Loading…
取消
儲存