diff options
author | Michael Brown | 2009-05-19 16:54:35 +0200 |
---|---|---|
committer | Michael Brown | 2009-05-20 08:56:29 +0200 |
commit | 9119b0c8af15333796e02433677a54e952b1a73d (patch) | |
tree | db8a87af64f451c5e85469361eca12a1176f0f2d | |
parent | [legal] Add FILE_LICENCE declaration to romprefix.S (diff) | |
download | ipxe-9119b0c8af15333796e02433677a54e952b1a73d.tar.gz ipxe-9119b0c8af15333796e02433677a54e952b1a73d.tar.xz ipxe-9119b0c8af15333796e02433677a54e952b1a73d.zip |
[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>
-rw-r--r-- | src/net/udp/dhcp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c index 9c1e09da..851b75e1 100644 --- a/src/net/udp/dhcp.c +++ b/src/net/udp/dhcp.c @@ -335,6 +335,8 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp, char vci[9]; /* "PXEClient" */ int vci_len; int has_pxeclient; + int pxeopts_len; + int has_pxeopts; int8_t priority = 0; uint8_t no_pxedhcp = 0; unsigned long elapsed; @@ -355,8 +357,10 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp, vci, sizeof ( vci ) ); has_pxeclient = ( ( vci_len >= ( int ) sizeof ( vci ) ) && ( strncmp ( "PXEClient", vci, sizeof (vci) ) == 0 )); + pxeopts_len = dhcppkt_fetch ( dhcppkt, DHCP_VENDOR_ENCAP, NULL, 0 ); + has_pxeopts = ( pxeopts_len >= 0 ); if ( has_pxeclient ) - DBGC ( dhcp, " pxe" ); + DBGC ( dhcp, "%s", ( has_pxeopts ? " pxe" : " proxy" ) ); /* Identify priority */ dhcppkt_fetch ( dhcppkt, DHCP_EB_PRIORITY, &priority, @@ -382,7 +386,7 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp, } /* Select as ProxyDHCP offer, if applicable */ - if ( has_pxeclient && ( msgtype == DHCPOFFER ) && + if ( has_pxeclient && ( ! has_pxeopts ) && ( msgtype == DHCPOFFER ) && ( priority >= dhcp->proxy_priority ) ) { dhcp->proxy_server = server_id; dhcp->proxy_priority = priority; |