From 600e248f0638aba6c98c16ad930736f7369fc4e5 Mon Sep 17 00:00:00 2001 From: Christoffer Lind Date: Tue, 2 Mar 2021 15:57:42 +0100 Subject: [PATCH] dhcp: generate new xid for DHCP release --- src/core/ipv4/dhcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 6da9cd6b..80d3c3ea 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -1331,6 +1331,7 @@ dhcp_release_and_stop(struct netif *netif) /* create and initialize the DHCP message header */ struct pbuf *p_out; u16_t options_out_len; + dhcp_set_state(dhcp, DHCP_STATE_OFF); p_out = dhcp_create_msg(netif, dhcp, DHCP_RELEASE, &options_out_len); if (p_out != NULL) { struct dhcp_msg *msg_out = (struct dhcp_msg *)p_out->payload; @@ -1350,10 +1351,10 @@ dhcp_release_and_stop(struct netif *netif) /* remove IP address from interface (prevents routing from selecting this interface) */ netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); + } else { + dhcp_set_state(dhcp, DHCP_STATE_OFF); } - dhcp_set_state(dhcp, DHCP_STATE_OFF); - if (dhcp->pcb_allocated != 0) { dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */ dhcp->pcb_allocated = 0;