Browse Source

Allow DHCP server to instruct gPXE to ignore ProxyDHCP (which will

also avoid waiting for ProxyDHCP offers).

Also reduce the ProxyDHCP timeout, because it's already irritating me.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
b3abf25e3c
2 changed files with 24 additions and 9 deletions
  1. 8
    1
      src/include/gpxe/dhcp.h
  2. 16
    8
      src/net/udp/dhcp.c

+ 8
- 1
src/include/gpxe/dhcp.h View File

@@ -183,6 +183,13 @@ struct job_interface;
183 183
  *
184 184
  */
185 185
 
186
+/** Ignore ProxyDHCP
187
+ *
188
+ * If set to a non-zero value, gPXE will not wait for ProxyDHCP offers
189
+ * and will ignore any ProxyDHCP offers that it receives.
190
+ */
191
+#define DHCP_EB_NO_PROXYDHCP DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb0 )
192
+
186 193
 /** Network device descriptor
187 194
  *
188 195
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
@@ -514,7 +521,7 @@ dhcpopt_put ( struct dhcp_option_block *options ) {
514 521
 }
515 522
 
516 523
 /** Maximum time that we will wait for ProxyDHCP offers */
517
-#define PROXYDHCP_WAIT_TIME ( TICKS_PER_SEC * 2 )
524
+#define PROXYDHCP_WAIT_TIME ( TICKS_PER_SEC * 1 )
518 525
 
519 526
 extern struct list_head dhcp_option_blocks;
520 527
 

+ 16
- 8
src/net/udp/dhcp.c View File

@@ -832,9 +832,10 @@ static int dhcp_deliver_raw ( struct xfer_interface *xfer,
832 832
 	const struct dhcphdr *dhcphdr = data;
833 833
 	struct dhcp_option_block *options;
834 834
 	struct dhcp_option_block **store_options;
835
-	int is_proxy;
836 835
 	unsigned int msgtype;
837 836
 	unsigned long elapsed;
837
+	int is_proxy;
838
+	int ignore_proxy;
838 839
 
839 840
 	/* Check for matching transaction ID */
840 841
 	if ( dhcphdr->xid != dhcp_xid ( dhcp->netdev ) ) {
@@ -878,17 +879,22 @@ static int dhcp_deliver_raw ( struct xfer_interface *xfer,
878 879
 		dhcpopt_put ( options );
879 880
 	}
880 881
 
882
+	/* If we don't yet have a standard DHCP response (i.e. one
883
+	 * with an IP address), then just leave the timer running.
884
+	 */
885
+	if ( ! dhcp->options )
886
+		goto out;
887
+
881 888
 	/* Handle DHCP response */
889
+	ignore_proxy = find_dhcp_num_option ( dhcp->options,
890
+					      DHCP_EB_NO_PROXYDHCP );
882 891
 	switch ( dhcp->state ) {
883 892
 	case DHCPDISCOVER:
884
-		/* If we have received a valid standard DHCP response
885
-		 * (i.e. one with an IP address), and we have allowed
886
-		 * sufficient time for ProxyDHCP reponses, then
887
-		 * transition to making the DHCPREQUEST.
893
+		/* If we have allowed sufficient time for ProxyDHCP
894
+		 * reponses, then transition to making the DHCPREQUEST.
888 895
 		 */
889 896
 		elapsed = ( currticks() - dhcp->start );
890
-		if ( dhcp->options &&
891
-		     ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
897
+		if ( ignore_proxy || ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
892 898
 			stop_timer ( &dhcp->timer );
893 899
 			dhcp->state = DHCPREQUEST;
894 900
 			dhcp_send_request ( dhcp );
@@ -896,9 +902,10 @@ static int dhcp_deliver_raw ( struct xfer_interface *xfer,
896 902
 		break;
897 903
 	case DHCPREQUEST:
898 904
 		/* DHCP finished; register options and exit */
899
-		if ( dhcp->proxy_options )
905
+		if ( dhcp->proxy_options && ( ! ignore_proxy ) ) {
900 906
 			dhcp->register_options ( dhcp->netdev,
901 907
 						 dhcp->proxy_options );
908
+		}
902 909
 		dhcp->register_options ( dhcp->netdev, dhcp->options );
903 910
 		dhcp_finished ( dhcp, 0 );
904 911
 		break;
@@ -906,6 +913,7 @@ static int dhcp_deliver_raw ( struct xfer_interface *xfer,
906 913
 		assert ( 0 );
907 914
 	}
908 915
 
916
+ out:
909 917
 	return 0;
910 918
 
911 919
  out_discard:

Loading…
Cancel
Save