From 269a58f18597aedec31c439e34cdaea47229dda3 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 13 Jun 2023 21:03:34 +0800 Subject: [PATCH] lower the dhcp discover and request retry backoff time --- src/core/ipv4/dhcp.c | 6 +++--- test/unit/lwipopts.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index f8b467b3..60e21aa4 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -131,7 +131,7 @@ static inline u32_t timeout_from_offered(u32_t lease, u32_t min, u32_t max) #define DHCP_CALC_TIMEOUT_FROM_OFFERED_T2_REBIND(dhcp) timeout_from_offered((dhcp)->offered_t2_rebind, 0, 0xffff) #define DHCP_NEXT_TIMEOUT_THRESHOLD ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS) -#define DHCP_REQUEST_TIMEOUT_SEQUENCE(state, tries) (u16_t)(( (tries) < 6 ? 1 << (tries) : 60) * 1000) +#define DHCP_REQUEST_TIMEOUT_SEQUENCE(tries) ((u16_t)(((tries) < 6 ? 1 << (tries) : 60) * 1000)) #endif /* DHCP_DEFINE_CUSTOM_TIMEOUTS */ @@ -476,7 +476,7 @@ dhcp_select(struct netif *netif) if (dhcp->tries < 255) { dhcp->tries++; } - msecs = DHCP_REQUEST_TIMEOUT_SEQUENCE(DHCP_STATE_REQUESTING, dhcp->tries); + msecs = DHCP_REQUEST_TIMEOUT_SEQUENCE(dhcp->tries); dhcp->request_timeout = (u16_t)((msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_select(): set request timeout %"U16_F" msecs\n", msecs)); ESP_LWIP_DHCP_FINE_TIMER_START_ONCE(netif, dhcp); @@ -1141,7 +1141,7 @@ dhcp_discover(struct netif *netif) autoip_start(netif); } #endif /* LWIP_DHCP_AUTOIP_COOP */ - msecs = DHCP_REQUEST_TIMEOUT_SEQUENCE(DHCP_STATE_SELECTING, dhcp->tries); + msecs = DHCP_REQUEST_TIMEOUT_SEQUENCE(dhcp->tries); dhcp->request_timeout = (u16_t)((msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); ESP_LWIP_DHCP_FINE_TIMER_START_ONCE(netif, dhcp); diff --git a/test/unit/lwipopts.h b/test/unit/lwipopts.h index fc4b573c..c619e98e 100644 --- a/test/unit/lwipopts.h +++ b/test/unit/lwipopts.h @@ -102,9 +102,7 @@ #define DHCP_DEFINE_CUSTOM_TIMEOUTS 1 #define DHCP_COARSE_TIMER_SECS (1) #define DHCP_NEXT_TIMEOUT_THRESHOLD (3) -#define DHCP_REQUEST_TIMEOUT_SEQUENCE(state, tries) (state == DHCP_STATE_REQUESTING ? \ - (uint16_t)(1 * 1000) : \ - (uint16_t)(((tries) < 6 ? 1 << (tries) : 60) * 250)) +#define DHCP_REQUEST_TIMEOUT_SEQUENCE(tries) ((uint16_t)(((tries) < 5 ? 1 << (tries) : 16) * 250)) #include static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)