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

Submitted by:  Stephen Hersey <shersey>
Submitted on:  Tue 26 Apr 2016 02:46:54 PM UTC  
 
Category: DHCPSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned 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>
Project Member
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>

 

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
  • -unavailable- added by dziegel (Posted a comment)
  • -unavailable- added by shersey (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 26 Apr 2016 06:58:52 PM UTCdziegelStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 26 Apr 2016 02:46:54 PM UTCsherseyAttached File-=>Added dhcp.c, #36997

    Back to the top


    Powered by Savane 3.1-cleanup1