Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core/ipv4/autoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/core/ipv4/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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 */
}

/**
Expand Down