diff --git a/src/core/ipv4/autoip.c b/src/core/ipv4/autoip.c index 461a00533..e0511ea4b 100644 --- a/src/core/ipv4/autoip.c +++ b/src/core/ipv4/autoip.c @@ -343,6 +343,11 @@ autoip_stop(struct netif *netif) LWIP_ASSERT_CORE_LOCKED(); if (autoip != NULL) { + /* Stop and remove acd */ + if (autoip->state != AUTOIP_STATE_OFF) { + acd_stop(&autoip->acd); + acd_remove(netif, &autoip->acd); + } autoip->state = AUTOIP_STATE_OFF; if (ip4_addr_islinklocal(netif_ip4_addr(netif))) { netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4); diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index 12e00683d..1dfb46244 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -1143,6 +1143,11 @@ dhcp_bind(struct netif *netif) to ensure the callback can use dhcp_supplied_address() */ dhcp_set_state(dhcp, DHCP_STATE_BOUND); +#if LWIP_DHCP_AUTOIP_COOP + /* If autoip was started, stop it to avoid that it sets an ip address after conflict resolution */ + autoip_stop(netif); +#endif /* LWIP_DHCP_AUTOIP_COOP */ + netif_set_addr(netif, &dhcp->offered_ip_addr, &sn_mask, &gw_addr); /* interface is used by routing now that an address is set */ } @@ -1389,6 +1394,11 @@ dhcp_release_and_stop(struct netif *netif) dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */ dhcp->pcb_allocated = 0; } + +#if LWIP_DHCP_AUTOIP_COOP + /* If autoip was started, stop it to avoid that it sets an ip address after conflict resolution */ + autoip_stop(netif); +#endif /* LWIP_DHCP_AUTOIP_COOP */ } /**