From b4ed597afe372eb4ee45f2304f37c2a67bb21747 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Wed, 23 Dec 2020 13:03:12 -0600 Subject: [PATCH] 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 --- subsys/net/ip/dhcpv4.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/subsys/net/ip/dhcpv4.c b/subsys/net/ip/dhcpv4.c index 8756847fb9c..dfa0779c07f 100644 --- a/subsys/net/ip/dhcpv4.c +++ b/subsys/net/ip/dhcpv4.c @@ -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)