espressif / esp-lwip

Fork of lwIP (https://savannah.nongnu.org/projects/lwip/) with ESP-IDF specific patches
Other
79 stars 126 forks source link

dhcp_set_cb() is lost on a timed out DHCP lease renewal (IDFGH-5498) #32

Closed pho closed 2 years ago

pho commented 3 years ago

On a DHCP lease renewal failure, the lwIP does a dhcp_release_and_stop() and then a dhcp_start() https://github.com/espressif/esp-lwip/blob/2.1.2-esp/src/core/ipv4/dhcp.c#L462

The call to dhcp_start() zeroes the dhcp struct, thus removing the dhcp_set_cb() callback, and even though the interface can obtain a new IP when the dhcp server comes back, it never notifies the app again https://github.com/espressif/esp-lwip/blob/2.1.2-esp/src/core/ipv4/dhcp.c#L850

david-cermak commented 3 years ago

Thanks @pho for reporting this issue, indeed the dhcp_cb pointer should be restored after we dhcp_release_and_stop() and dhcp_start() again.

Please find the WIP patch attached below dhcp-Restore-dhcp_cb-on-restart-after-dhcp_release_a.patch.txt