소스 검색

[DHCP] Fix DHCP state confusion.

DHCP code was using an incorrect check for whether to construct a
DHCPDISCOVER or DHCPREQUEST packet.
tags/v0.9.4
Michael Brown 16 년 전
부모
커밋
7234f91bf8
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5
    2
      src/net/udp/dhcp.c

+ 5
- 2
src/net/udp/dhcp.c 파일 보기

@@ -622,7 +622,7 @@ static int dhcp_send_request ( struct dhcp_session *dhcp ) {
622 622
 		.netdev = dhcp->netdev,
623 623
 	};
624 624
 	struct io_buffer *iobuf;
625
-	struct dhcp_packet *dhcpoffer;
625
+	struct dhcp_packet *dhcpoffer = NULL;
626 626
 	struct dhcp_packet dhcppkt;
627 627
 	int rc;
628 628
 	
@@ -643,7 +643,10 @@ static int dhcp_send_request ( struct dhcp_session *dhcp ) {
643 643
 		return -ENOMEM;
644 644
 
645 645
 	/* Create DHCP packet in temporary buffer */
646
-	dhcpoffer = ( dhcp->response ? &dhcp->response->dhcppkt : NULL );
646
+	if ( dhcp->state == DHCPREQUEST ) {
647
+		assert ( dhcp->response );
648
+		dhcpoffer = &dhcp->response->dhcppkt;
649
+	}
647 650
 	if ( ( rc = create_dhcp_request ( &dhcppkt, dhcp->netdev,
648 651
 					  dhcpoffer, iobuf->data,
649 652
 					  iob_tailroom ( iobuf ) ) ) != 0 ) {

Loading…
취소
저장