fix: when a DHCP lease is obtained, stop autoip to avoid that it overwrites the IP address after conflict resolution

This commit is contained in:
Richard Peters 2024-10-26 07:50:42 +02:00
parent 73fcf72792
commit d77cc49b71
2 changed files with 10 additions and 0 deletions

View File

@ -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);

View File

@ -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 */
}