From 6c7e7153bc7ea563cfe569802822fedb02076a8a Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sat, 30 Dec 2017 12:17:24 +0100 Subject: [PATCH] Fix bug #52704: DHCP and bad OFFER Stop timeout only if offer is accepted --- src/core/ipv4/dhcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 821aa651..ebc89174 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -337,6 +337,8 @@ dhcp_handle_offer(struct netif *netif, struct dhcp_msg *msg_in) (void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* obtain the server address */ if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_SERVER_ID)) { + dhcp->request_timeout = 0; /* stop timer */ + ip_addr_set_ip4_u32(&dhcp->server_ip_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_SERVER_ID))); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", ip4_addr_get_u32(ip_2_ip4(&dhcp->server_ip_addr)))); @@ -1835,7 +1837,6 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, /* received a DHCP_OFFER in DHCP_STATE_SELECTING state? */ else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_STATE_SELECTING)) { LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("DHCP_OFFER received in DHCP_STATE_SELECTING state\n")); - dhcp->request_timeout = 0; /* remember offered lease */ dhcp_handle_offer(netif, msg_in); }