public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] DHCP Client Fix
@ 2007-10-19 14:15 Justin Flammia
  2007-10-28 22:01 ` Wolfgang Denk
  0 siblings, 1 reply; 10+ messages in thread
From: Justin Flammia @ 2007-10-19 14:15 UTC (permalink / raw)
  To: u-boot


I recently upgraded the firmware on some of my old Linksys WRT54G routers (version 5) from firmware version 1.0.6 to firmware version 1.02.2, both of which are released by Linksys and U-Boot was no longer able to get an IP address using DHCP.  However, with the older firmware (version 1.0.6), U-Boot was still able to get an IP through DHCP.

Using a hub and a packet sniffer, I was able to locate the problem.  The U-Boot code will bind to an IP address offered by the DHCP server prematurely and the DHCP server will not respond with an ACK, rendering the system without an IP address.  This is no longer valid when using a Linksys router as DHCP server.  I modified the code to operate the way the Linux DHCP client does by not binding to the offered IP until the DHCP client receives the ACK sent by the server, ending the conversation.  After making the appropriate changes, DCHP service was restored for all flavors of the Linksys firmware that I have available (v 1.02.2 and v1.0.6 for the version 5 router, v8.00.2 for the version 8 router).  It has also been tested on an AirPort Extreme router running DHCP.

Attached is the patch with the code changes that were made. Any feed back would be appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20071019/367760be/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bootp.patch
Type: application/octet-stream
Size: 999 bytes
Desc: bootp.patch
Url : http://lists.denx.de/pipermail/u-boot/attachments/20071019/367760be/attachment.obj 

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [U-Boot-Users] [PATCH] DHCP Client Fix
@ 2007-10-29 14:00 Justin Flammia
  0 siblings, 0 replies; 10+ messages in thread
From: Justin Flammia @ 2007-10-29 14:00 UTC (permalink / raw)
  To: u-boot

Ben,

Just a note...one of the ways that I came up with this solution that is presented in this patch was from observing a Fedora Linux machine and an Apple MacBook Pro interact with the same routers because these computers were able to get an IP address through either Linksys DHCP server consistently.  There were some differences in the data that was included in each of the DHCP negotiation packets but it was the difference you see in the patch that allowed U-Boot to work with the new firmware. After doing some research on DHCP IP assignments, this seemed like a viable solution according to the spec.

Justin


>Wolfgang Denk wrote:
>>Dear Justin,
>>
>>in message <4155D0DA4B6B044891B3F19311C7E7B89C45E4@EXCHANGE1.886llc.local> you wrote:
>>  
>>>I recently upgraded the firmware on some of my old Linksys WRT54G
>>>routers (version 5) from firmware version 1.0.6 to firmware version
>>>1.02.2, both of which are released by Linksys and U-Boot was no longer
>>>able to get an IP address using DHCP.  However, with the older firmware
>>>(version 1.0.6), U-Boot was still able to get an IP through DHCP.
>>>
>>>Using a hub and a packet sniffer, I was able to locate the problem.  The
>>>U-Boot code will bind to an IP address offered by the DHCP server
>>>prematurely and the DHCP server will not respond with an ACK, rendering
>>>    
>>
>>I have to admit that I'm not sure if this is a bug in  U-Boot  or  in
>>the  Linksys  router  (which I have under special observation as they
>>explicitely and intentionally violate the U-Boot GPL).
>>
>>
>>>the system without an IP address.  This is no longer valid when using a
>>>Linksys router as DHCP server.  I modified the code to operate the way
>>>the Linux DHCP client does by not binding to the offered IP until the
>>>DHCP client receives the ACK sent by the server, ending the
>>>conversation.  After making the appropriate changes, DCHP service was
>>>restored for all flavors of the Linksys firmware that I have available
>>>(v 1.02.2 and v1.0.6 for the version 5 router, v8.00.2 for the version 8
>>>router).  It has also been tested on an AirPort Extreme router running
>>>DHCP.
>>>
>>>Attached is the patch with the code changes that were made. Any feed
>>>back would be appreciated.
>>>    
>>>
>>
>>I'm waiting for feedback (or a pull request?) from the network
>>custodian.
>>
>>Ben???
>>
>>
>This looks promising.  I'll provide feedback after doing some testing tomorrow.
>
>regards,
>Ben  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20071029/75d5c9c1/attachment.htm 

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [U-Boot-Users] [PATCH] DHCP Client Fix
@ 2007-10-29 21:40 Justin Flammia
  0 siblings, 0 replies; 10+ messages in thread
From: Justin Flammia @ 2007-10-29 21:40 UTC (permalink / raw)
  To: u-boot

commit e6e505eae94ed721e123e177489291fc4544b7b8
Author: Justin Flammia <jflammia@savantav.com>
Date:   Mon Oct 29 17:19:03 2007 -0400

    Found a bug in the way the DHCP Request packet is built, where the IP address
    that is offered by the server is bound to prematurely. This patch is a fix of
    that bug where the IP address offered by the DHCP server is not used until
    after the DHCP ACK from the server is received.

Signed-off-by: Justin Flammia <jflammia@savantav.com>
---
 net/bootp.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/bootp.c b/net/bootp.c
index 749d3e5..cfe6f8d 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -850,9 +850,9 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
 	bp->bp_secs = htons(get_timer(0) / CFG_HZ);
-	NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
-	NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
-	NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
+	/* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by
+	 * the server yet */
+
 	/*
 	 * RFC3046 requires Relay Agents to discard packets with
 	 * nonzero and offered giaddr
@@ -870,7 +870,9 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
 	/*
 	 * Copy options from OFFER packet if present
 	 */
-	NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
+
+	/* Copy offered IP into the parameters request list */
+	NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
 
 	pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
@@ -980,3 +982,4 @@ void DhcpRequest(void)
 #endif
 
 #endif
+
-- 
1.5.0.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20071029/13441c84/attachment.htm 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-10-29 21:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-19 14:15 [U-Boot-Users] [PATCH] DHCP Client Fix Justin Flammia
2007-10-28 22:01 ` Wolfgang Denk
2007-10-29  2:00   ` Ben Warren
2007-10-29  6:00     ` [U-Boot-Users] Return values from u-boot to standalone application Leonid
2007-10-29 13:34       ` Leonid
2007-10-29 13:46         ` Laurent Pinchart
2007-10-29 14:45           ` Leonid
2007-10-29 19:46             ` [U-Boot-Users] Return values from u-boot to standaloneapplication Leonid
  -- strict thread matches above, loose matches on Subject: below --
2007-10-29 14:00 [U-Boot-Users] [PATCH] DHCP Client Fix Justin Flammia
2007-10-29 21:40 Justin Flammia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox