[PATCH 1/3] dhcp: fix request packet's requested IP option

Eric Bénard eric at eukrea.com
Wed Jan 28 15:37:32 PST 2015


In the request packet, we are supposed to copy the IP that the DHCP server
provided in the offer packet so that dhcp_extended can fill the option 50.
There is actually an error in barebox as the pointer to the packet currently
built is used as the source instead of the pointer to the offer packet.
With this patch, barebox now sends a request packet which includes the right
requested IP in option 50.

Signed-off-by: Eric Bénard <eric at eukrea.com>
---
 net/dhcp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 9551d60..78440dd 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -579,7 +579,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)
 	/*
 	 * Copy options from OFFER packet if present
 	 */
-	net_copy_ip(&OfferedIP, &bp->bp_yiaddr);
+	net_copy_ip(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, net_dhcp_server_ip,
 				OfferedIP);
 
@@ -745,9 +745,7 @@ static int do_dhcp(int argc, char *argv[])
 	ret = net_udp_bind(dhcp_con, PORT_BOOTPC);
 	if (ret)
 		goto out1;
-
 	net_set_ip(0);
-
 	dhcp_start = get_time_ns();
 	ret = bootp_request(); /* Basically same as BOOTP */
 	if (ret)
-- 
1.9.3




More information about the barebox mailing list