소스 검색

[dhcp] Clarify language surrounding ProxyDHCP

Remove the lazy assumption that ProxyDHCP == "DHCP with option 60 set
to PXEClient", and explicitly separate the notion of ProxyDHCP from
the notion of packets containing PXE options.
tags/v0.9.7
Michael Brown 15 년 전
부모
커밋
3f814f08e5
2개의 변경된 파일56개의 추가작업 그리고 55개의 파일을 삭제
  1. 5
    5
      src/include/gpxe/dhcp.h
  2. 51
    50
      src/net/udp/dhcp.c

+ 5
- 5
src/include/gpxe/dhcp.h 파일 보기

@@ -25,8 +25,8 @@ struct dhcp_pxe_boot_menu_item;
25 25
 /** BOOTP/DHCP client port */
26 26
 #define BOOTPC_PORT 68
27 27
 
28
-/** ProxyDHCP server port */
29
-#define PROXYDHCP_PORT 4011
28
+/** PXE server port */
29
+#define PXE_PORT 4011
30 30
 
31 31
 /** Construct a tag value for an encapsulated option
32 32
  *
@@ -207,12 +207,12 @@ struct dhcp_pxe_boot_menu_item;
207 207
  *
208 208
  */
209 209
 
210
-/** Ignore ProxyDHCP
210
+/** Skip PXE DHCP protocol extensions such as ProxyDHCP
211 211
  *
212 212
  * If set to a non-zero value, gPXE will not wait for ProxyDHCP offers
213
- * and will ignore any ProxyDHCP offers that it receives.
213
+ * and will ignore any PXE-specific DHCP offers that it receives.
214 214
  */
215
-#define DHCP_EB_NO_PROXYDHCP DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb0 )
215
+#define DHCP_EB_NO_PXEDHCP DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb0 )
216 216
 
217 217
 /** Network device descriptor
218 218
  *

+ 51
- 50
src/net/udp/dhcp.c 파일 보기

@@ -340,14 +340,16 @@ struct dhcp_session {
340 340
 	 * (e.g. @c DHCPDISCOVER).
341 341
 	 */
342 342
 	enum dhcp_session_state state;
343
-	/** DHCPOFFER obtained during DHCPDISCOVER */
343
+	/** DHCPOFFER obtained during DHCPDISCOVER containing IP address */
344 344
 	struct dhcp_settings *dhcpoffer;
345
-	/** ProxyDHCPOFFER obtained during DHCPDISCOVER */
346
-	struct dhcp_settings *proxydhcpoffer;
347
-	/** DHCPACK obtained during DHCPREQUEST */
345
+	/** DHCPOFFER obtained during DHCPDISCOVER containing "PXEClient" */
346
+	struct dhcp_settings *pxedhcpoffer;
347
+	/** DHCPACK obtained during DHCPREQUEST containing IP address */
348 348
 	struct dhcp_settings *dhcpack;
349
-	/** ProxyDHCPACK obtained during ProxyDHCPREQUEST */
350
-	struct dhcp_settings *proxydhcpack;
349
+	/** DHCPACK obtained during DHCPREQUEST or ProxyDHCPREQUEST
350
+	 * containing "PXEClient"
351
+	 */
352
+	struct dhcp_settings *pxedhcpack;
351 353
 	/** BootServerDHCPACK obtained during BootServerDHCPREQUEST */
352 354
 	struct dhcp_settings *bsdhcpack;
353 355
 	/** Retransmission timer */
@@ -367,9 +369,9 @@ static void dhcp_free ( struct refcnt *refcnt ) {
367 369
 
368 370
 	netdev_put ( dhcp->netdev );
369 371
 	dhcpset_put ( dhcp->dhcpoffer );
370
-	dhcpset_put ( dhcp->proxydhcpoffer );
372
+	dhcpset_put ( dhcp->pxedhcpoffer );
371 373
 	dhcpset_put ( dhcp->dhcpack );
372
-	dhcpset_put ( dhcp->proxydhcpack );
374
+	dhcpset_put ( dhcp->pxedhcpack );
373 375
 	dhcpset_put ( dhcp->bsdhcpack );
374 376
 	free ( dhcp );
375 377
 }
@@ -586,7 +588,7 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
586 588
 static int dhcp_tx ( struct dhcp_session *dhcp ) {
587 589
 	static struct sockaddr_in dest = {
588 590
 		.sin_family = AF_INET,
589
-		.sin_port = htons ( PROXYDHCP_PORT ),
591
+		.sin_port = htons ( PXE_PORT ),
590 592
 	};
591 593
 	static struct sockaddr_in src = {
592 594
 		.sin_family = AF_INET,
@@ -624,11 +626,11 @@ static int dhcp_tx ( struct dhcp_session *dhcp ) {
624 626
 		break;
625 627
 	case DHCP_STATE_PROXYREQUEST:
626 628
 		assert ( dhcp->dhcpoffer );
627
-		assert ( dhcp->proxydhcpoffer );
629
+		assert ( dhcp->pxedhcpoffer );
628 630
 		assert ( dhcp->dhcpack );
629 631
 		msgtype = DHCPREQUEST;
630 632
 		ciaddr = dhcp->dhcpoffer->dhcppkt.dhcphdr->yiaddr;
631
-		dhcppkt_fetch ( &dhcp->proxydhcpoffer->dhcppkt,
633
+		dhcppkt_fetch ( &dhcp->pxedhcpoffer->dhcppkt,
632 634
 				DHCP_SERVER_IDENTIFIER, &dest.sin_addr,
633 635
 				sizeof ( dest.sin_addr ) );
634 636
 		meta.dest = ( struct sockaddr * ) &dest;
@@ -638,16 +640,16 @@ static int dhcp_tx ( struct dhcp_session *dhcp ) {
638 640
 		break;
639 641
 	case DHCP_STATE_BSREQUEST:
640 642
 		assert ( dhcp->dhcpoffer );
641
-		assert ( dhcp->proxydhcpoffer );
643
+		assert ( dhcp->pxedhcpoffer );
642 644
 		assert ( dhcp->dhcpack );
643
-		assert ( dhcp->proxydhcpack );
645
+		assert ( dhcp->pxedhcpack );
644 646
 		msgtype = DHCPREQUEST;
645 647
 		ciaddr = dhcp->dhcpoffer->dhcppkt.dhcphdr->yiaddr;
646
-		dhcppkt_fetch ( &dhcp->proxydhcpack->dhcppkt,
648
+		dhcppkt_fetch ( &dhcp->pxedhcpack->dhcppkt,
647 649
 				DHCP_PXE_BOOT_SERVER_MCAST,
648 650
 				&dest.sin_addr, sizeof ( dest.sin_addr ) );
649 651
 		meta.dest = ( struct sockaddr * ) &dest;
650
-		dhcppkt_fetch ( &dhcp->proxydhcpack->dhcppkt,
652
+		dhcppkt_fetch ( &dhcp->pxedhcpack->dhcppkt,
651 653
 				DHCP_PXE_BOOT_MENU, &menu_item.type,
652 654
 				sizeof ( menu_item.type ) );
653 655
 		assert ( dest.sin_addr.s_addr );
@@ -744,21 +746,21 @@ static void dhcp_next_state ( struct dhcp_session *dhcp ) {
744 746
 		dhcp_set_state ( dhcp, DHCP_STATE_REQUEST );
745 747
 		break;
746 748
 	case DHCP_STATE_REQUEST:
747
-		if ( dhcp->proxydhcpoffer ) {
748
-			/* Store DHCPACK as ProxyDHCPACK.  This
749
-			 * handles the case in which the DHCP server
750
-			 * itself responds with "PXEClient" and PXE
751
-			 * options but there is no actual ProxyDHCP
752
-			 * server resident on the machine.
749
+		if ( dhcp->pxedhcpoffer ) {
750
+			/* Store DHCPACK as PXEDHCPACK.  This handles
751
+			 * the case in which the DHCP server itself
752
+			 * responds with "PXEClient" and PXE options
753
+			 * but there is no ProxyDHCP server resident
754
+			 * on the machine.
753 755
 			 */
754
-			dhcp->proxydhcpack = dhcpset_get ( dhcp->dhcpack );
756
+			dhcp->pxedhcpack = dhcpset_get ( dhcp->dhcpack );
755 757
 			dhcp_set_state ( dhcp, DHCP_STATE_PROXYREQUEST );
756 758
 			break;
757 759
 		}
758 760
 		/* Fall through */
759 761
 	case DHCP_STATE_PROXYREQUEST:
760
-		if ( dhcp->proxydhcpack ) {
761
-			dhcppkt_fetch ( &dhcp->proxydhcpack->dhcppkt,
762
+		if ( dhcp->pxedhcpack ) {
763
+			dhcppkt_fetch ( &dhcp->pxedhcpack->dhcppkt,
762 764
 					DHCP_PXE_BOOT_SERVER_MCAST,
763 765
 					&bs_mcast, sizeof ( bs_mcast ) );
764 766
 			if ( bs_mcast.s_addr ) {
@@ -827,7 +829,7 @@ static void dhcp_rx_dhcpoffer ( struct dhcp_session *dhcp,
827 829
 	struct in_addr server_id = { 0 };
828 830
 	char vci[9]; /* "PXEClient" */
829 831
 	int len;
830
-	uint8_t ignore_proxy = 0;
832
+	uint8_t ignore_pxe = 0;
831 833
 	unsigned long elapsed;
832 834
 
833 835
 	/* Check for presence of DHCP server ID */
@@ -849,26 +851,25 @@ static void dhcp_rx_dhcpoffer ( struct dhcp_session *dhcp,
849 851
 	}
850 852
 
851 853
 	/* If there is a "PXEClient" vendor class ID, it's a
852
-	 * ProxyDHCPOFFER.  Note that it could be both a normal
853
-	 * DHCPOFFER and a ProxyDHCPOFFER.
854
+	 * PXEDHCPOFFER.  Note that it could be both a normal
855
+	 * DHCPOFFER and a PXEDHCPOFFER.
854 856
 	 */
855 857
 	len = dhcppkt_fetch ( &dhcpoffer->dhcppkt, DHCP_VENDOR_CLASS_ID,
856 858
 			      vci, sizeof ( vci ) );
857 859
 	if ( ( server_id.s_addr != 0 ) &&
858 860
 	     ( len >= ( int ) sizeof ( vci ) ) &&
859 861
 	     ( strncmp ( "PXEClient", vci, sizeof ( vci ) ) == 0 ) ) {
860
-		DBGC ( dhcp, "DHCP %p DHCPOFFER %p from %s is a "
861
-		       "ProxyDHCPOFFER\n",
862
+		DBGC ( dhcp, "DHCP %p DHCPOFFER %p from %s has PXE options\n",
862 863
 		       dhcp, dhcpoffer, inet_ntoa ( server_id ) );
863 864
 		dhcp_store_dhcpoffer ( dhcp, dhcpoffer,
864
-				       &dhcp->proxydhcpoffer );
865
+				       &dhcp->pxedhcpoffer );
865 866
 	}
866 867
 
867 868
 	/* We can transition to making the DHCPREQUEST when we have a
868 869
 	 * valid DHCPOFFER, and either:
869 870
 	 *
870
-	 *  o  The DHCPOFFER instructs us to not wait for ProxyDHCP, or
871
-	 *  o  We have a valid ProxyDHCPOFFER, or
871
+	 *  o  The DHCPOFFER instructs us to ignore PXEDHCPOFFERs, or
872
+	 *  o  We have a valid PXEDHCPOFFER, or
872 873
          *  o  We have allowed sufficient time for ProxyDHCPOFFERs.
873 874
 	 */
874 875
 
@@ -876,20 +877,20 @@ static void dhcp_rx_dhcpoffer ( struct dhcp_session *dhcp,
876 877
 	if ( ! dhcp->dhcpoffer )
877 878
 		return;
878 879
 
879
-	/* If the DHCPOFFER instructs us to ignore ProxyDHCP, discard
880
-	 * any ProxyDHCPOFFER
880
+	/* If the DHCPOFFER instructs us to ignore PXEDHCP, discard
881
+	 * any PXEDHCPOFFER
881 882
 	 */
882
-	dhcppkt_fetch ( &dhcp->dhcpoffer->dhcppkt, DHCP_EB_NO_PROXYDHCP,
883
-			&ignore_proxy, sizeof ( ignore_proxy ) );
884
-	if ( ignore_proxy && dhcp->proxydhcpoffer ) {
885
-		DBGC ( dhcp, "DHCP %p discarding ProxyDHCPOFFER\n", dhcp );
886
-		dhcpset_put ( dhcp->proxydhcpoffer );
887
-		dhcp->proxydhcpoffer = NULL;
883
+	dhcppkt_fetch ( &dhcp->dhcpoffer->dhcppkt, DHCP_EB_NO_PXEDHCP,
884
+			&ignore_pxe, sizeof ( ignore_pxe ) );
885
+	if ( ignore_pxe && dhcp->pxedhcpoffer ) {
886
+		DBGC ( dhcp, "DHCP %p discarding PXEDHCPOFFER\n", dhcp );
887
+		dhcpset_put ( dhcp->pxedhcpoffer );
888
+		dhcp->pxedhcpoffer = NULL;
888 889
 	}
889 890
 
890 891
 	/* If we can't yet transition to DHCPREQUEST, do nothing */
891 892
 	elapsed = ( currticks() - dhcp->start );
892
-	if ( ! ( ignore_proxy || dhcp->proxydhcpoffer ||
893
+	if ( ! ( ignore_pxe || dhcp->pxedhcpoffer ||
893 894
 		 ( elapsed > PROXYDHCP_WAIT_TIME ) ) )
894 895
 		return;
895 896
 
@@ -978,11 +979,11 @@ static void dhcp_rx_proxydhcpack ( struct dhcp_session *dhcp,
978 979
 	int rc;
979 980
 
980 981
 	/* Verify server ID matches, if present */
981
-	assert ( dhcp->proxydhcpoffer != NULL );
982
+	assert ( dhcp->pxedhcpoffer != NULL );
982 983
 	if ( ( rc = dhcppkt_fetch ( &proxydhcpack->dhcppkt,
983 984
 				    DHCP_SERVER_IDENTIFIER, &ack_server_id,
984 985
 				    sizeof ( ack_server_id ) ) ) > 0 ) {
985
-		dhcppkt_fetch ( &dhcp->proxydhcpoffer->dhcppkt,
986
+		dhcppkt_fetch ( &dhcp->pxedhcpoffer->dhcppkt,
986 987
 				DHCP_SERVER_IDENTIFIER, &offer_server_id,
987 988
 				sizeof ( offer_server_id ) );
988 989
 		if ( offer_server_id.s_addr != ack_server_id.s_addr ) {
@@ -996,9 +997,9 @@ static void dhcp_rx_proxydhcpack ( struct dhcp_session *dhcp,
996 997
 	/* Rename settings */
997 998
 	proxydhcpack->settings.name = PROXYDHCP_SETTINGS_NAME;
998 999
 
999
-	/* Record ProxyDHCPACK */
1000
-	dhcpset_put ( dhcp->proxydhcpack );
1001
-	dhcp->proxydhcpack = dhcpset_get ( proxydhcpack );
1000
+	/* Record ProxyDHCPACK as PXEDHCPACK */
1001
+	dhcpset_put ( dhcp->pxedhcpack );
1002
+	dhcp->pxedhcpack = dhcpset_get ( proxydhcpack );
1002 1003
 
1003 1004
 	/* Register settings */
1004 1005
 	if ( ( rc = dhcp_store_dhcpack ( dhcp, proxydhcpack, NULL ) ) != 0 )
@@ -1012,7 +1013,7 @@ static void dhcp_rx_proxydhcpack ( struct dhcp_session *dhcp,
1012 1013
  * Handle received BootServerDHCPACK
1013 1014
  *
1014 1015
  * @v dhcp		DHCP session
1015
- * @v bsdhcpack	Received BootServerDHCPACK
1016
+ * @v bsdhcpack		Received BootServerDHCPACK
1016 1017
  */
1017 1018
 static void dhcp_rx_bsdhcpack ( struct dhcp_session *dhcp,
1018 1019
 				struct dhcp_settings *bsdhcpack ) {
@@ -1021,7 +1022,7 @@ static void dhcp_rx_bsdhcpack ( struct dhcp_session *dhcp,
1021 1022
 	/* Rename settings */
1022 1023
 	bsdhcpack->settings.name = BSDHCP_SETTINGS_NAME;
1023 1024
 
1024
-	/* Record ProxyDHCPACK */
1025
+	/* Record BootServerDHCPACK */
1025 1026
 	assert ( dhcp->bsdhcpack == NULL );
1026 1027
 	dhcp->bsdhcpack = dhcpset_get ( bsdhcpack );
1027 1028
 
@@ -1107,12 +1108,12 @@ static int dhcp_deliver_iob ( struct xfer_interface *xfer,
1107 1108
 		break;
1108 1109
 	case DHCP_STATE_PROXYREQUEST:
1109 1110
 		if ( ( msgtype == DHCPACK ) &&
1110
-		     ( src_port == htons ( PROXYDHCP_PORT ) ) )
1111
+		     ( src_port == htons ( PXE_PORT ) ) )
1111 1112
 			dhcp_rx_proxydhcpack ( dhcp, dhcpset );
1112 1113
 		break;
1113 1114
 	case DHCP_STATE_BSREQUEST:
1114 1115
 		if ( ( msgtype == DHCPACK ) &&
1115
-		     ( src_port == htons ( PROXYDHCP_PORT ) ) )
1116
+		     ( src_port == htons ( PXE_PORT ) ) )
1116 1117
 			dhcp_rx_bsdhcpack ( dhcp, dhcpset );
1117 1118
 		break;
1118 1119
 	default:

Loading…
취소
저장