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.
|