net: dhcp: fix timeout on entry to bound state

When a renewal occurs the client enters RENEWING, sends a request,
then sets a short timeout (about 4 s) for the response.  In the common
case the response will arrive immediately, which will trigger an
attempt to reset the timer with T1 which is generally large.

However the check for updating the timer performs the update only if
the new deadline is closer than the currently set one.  Thus the timer
fires at the time the RENEWING request would have been retransmitted,
and only then updates to the correct deadline (T1) for the current
machine state.

Remove the extra timeout by unconditionally setting the timeout to the
new value.

This works when there is one interface; it could be wrong if there
were multiple interfaces one of which had a closer deadline, but
multiple interfaces are mishandled anyway and will be fixed next.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-12-23 13:03:12 -06:00 committed by Jukka Rissanen
parent 65183422c7
commit b4ed597afe

View File

@ -421,12 +421,7 @@ fail:
static void dhcpv4_update_timeout_work(uint32_t timeout)
{
if (!k_delayed_work_remaining_get(&timeout_work) ||
(MSEC_PER_SEC * timeout) <
k_delayed_work_remaining_get(&timeout_work)) {
k_delayed_work_cancel(&timeout_work);
k_delayed_work_submit(&timeout_work, K_SECONDS(timeout));
}
k_delayed_work_submit(&timeout_work, K_SECONDS(timeout));
}
static void dhcpv4_enter_selecting(struct net_if *iface)