Procházet zdrojové kódy

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 před 18 roky
rodič
revize
b3abf25e3c
2 změnil soubory, kde provedl 24 přidání a 9 odebrání
  1. 8
    1
      src/include/gpxe/dhcp.h
  2. 16
    8
      src/net/udp/dhcp.c

+ 8
- 1
src/include/gpxe/dhcp.h Zobrazit soubor

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
 /** Network device descriptor
193
 /** Network device descriptor
187
  *
194
  *
188
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
195
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
514
 }
521
 }
515
 
522
 
516
 /** Maximum time that we will wait for ProxyDHCP offers */
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
 extern struct list_head dhcp_option_blocks;
526
 extern struct list_head dhcp_option_blocks;
520
 
527
 

+ 16
- 8
src/net/udp/dhcp.c Zobrazit soubor

832
 	const struct dhcphdr *dhcphdr = data;
832
 	const struct dhcphdr *dhcphdr = data;
833
 	struct dhcp_option_block *options;
833
 	struct dhcp_option_block *options;
834
 	struct dhcp_option_block **store_options;
834
 	struct dhcp_option_block **store_options;
835
-	int is_proxy;
836
 	unsigned int msgtype;
835
 	unsigned int msgtype;
837
 	unsigned long elapsed;
836
 	unsigned long elapsed;
837
+	int is_proxy;
838
+	int ignore_proxy;
838
 
839
 
839
 	/* Check for matching transaction ID */
840
 	/* Check for matching transaction ID */
840
 	if ( dhcphdr->xid != dhcp_xid ( dhcp->netdev ) ) {
841
 	if ( dhcphdr->xid != dhcp_xid ( dhcp->netdev ) ) {
878
 		dhcpopt_put ( options );
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
 	/* Handle DHCP response */
888
 	/* Handle DHCP response */
889
+	ignore_proxy = find_dhcp_num_option ( dhcp->options,
890
+					      DHCP_EB_NO_PROXYDHCP );
882
 	switch ( dhcp->state ) {
891
 	switch ( dhcp->state ) {
883
 	case DHCPDISCOVER:
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
 		elapsed = ( currticks() - dhcp->start );
896
 		elapsed = ( currticks() - dhcp->start );
890
-		if ( dhcp->options &&
891
-		     ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
897
+		if ( ignore_proxy || ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
892
 			stop_timer ( &dhcp->timer );
898
 			stop_timer ( &dhcp->timer );
893
 			dhcp->state = DHCPREQUEST;
899
 			dhcp->state = DHCPREQUEST;
894
 			dhcp_send_request ( dhcp );
900
 			dhcp_send_request ( dhcp );
896
 		break;
902
 		break;
897
 	case DHCPREQUEST:
903
 	case DHCPREQUEST:
898
 		/* DHCP finished; register options and exit */
904
 		/* DHCP finished; register options and exit */
899
-		if ( dhcp->proxy_options )
905
+		if ( dhcp->proxy_options && ( ! ignore_proxy ) ) {
900
 			dhcp->register_options ( dhcp->netdev,
906
 			dhcp->register_options ( dhcp->netdev,
901
 						 dhcp->proxy_options );
907
 						 dhcp->proxy_options );
908
+		}
902
 		dhcp->register_options ( dhcp->netdev, dhcp->options );
909
 		dhcp->register_options ( dhcp->netdev, dhcp->options );
903
 		dhcp_finished ( dhcp, 0 );
910
 		dhcp_finished ( dhcp, 0 );
904
 		break;
911
 		break;
906
 		assert ( 0 );
913
 		assert ( 0 );
907
 	}
914
 	}
908
 
915
 
916
+ out:
909
 	return 0;
917
 	return 0;
910
 
918
 
911
  out_discard:
919
  out_discard:

Načítá se…
Zrušit
Uložit