buglwIP - A Lightweight TCP/IP stack - Bugs: bug #47787, DHCP client quits after 256 tries

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #47787: DHCP client quits after 256 tries

Submitter:  Stephen Hersey <shersey>
Submitted:  Tue 26 Apr 2016 02:46:54 PM UTC
   
 
Category:  DHCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.4.1

Tue 26 Apr 2016 06:58:52 PM UTC, comment #1: 

Already fixed in git HEAD

Dirk Ziegelmeier <dziegel>
Group administrator
Tue 26 Apr 2016 02:46:54 PM UTC, original submission:  

There's a weird corner case in LwIP where, if the DHCP client is unable to get a response from a DHCP server after 256 tries, the DHCP retry counter (which is a u8_t) will roll over to zero, and the DHCP timout will stop invoking dhcp_timeout(). This is in a configuration where DHCP is enabled but AUTOIP is not.

Now, most users will never see this, because it normally takes a LONG time to reach 256 tries with the default exponential DHCP  backoff. However, I'm using a modified dhcp.c (attached, search for "S.H." in the text) that reduces the maximum DHCP retry timeout to 10 seconds, because my DHCP client may come up several minutes before the DHCP server does, and it's important that the client get an address quickly once the server finally comes up.

My target hardware is an ARM Cortex-M3 MCU, and the build environment is GCC (Rowley Crossworks 3.5).

To reproduce the failure, attach the LwIP DHCP client system to a PC that has no DHCP server, run Wireshark on the PC, and observe the client's DHCP requests. After 256 tries without a DHCP response, the DHCP client will stop requesting.

My local fix for this failure is to take each occurrence of "dhcp->tries" in dhcp.c and wrap it in a conditional, as: "if (dhcp->tries < 255) { dhcp->tries++; }"

This causes "tries" to saturate at 255 instead of rolling over, and the DHCP client won't stop requesting.

Stephen Hersey <shersey>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #36997:  dhcp.c added by shersey (65KiB - text/x-csrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dziegel (Posted a comment)
  • -email is unavailable- added by shersey (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-26 dziegel StatusNone Fixed
        Open/ClosedOpen Closed
    2016-04-26 shersey Attached File- Added dhcp.c, #36997

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code