Skip to content
Merged
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
7 changes: 6 additions & 1 deletion subsys/net/ip/ipv4_autoconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,18 @@ void net_ipv4_autoconf_start(struct net_if *iface)
void net_ipv4_autoconf_reset(struct net_if *iface)
{
struct net_if_config *cfg;
struct net_if_addr *ifaddr;
struct net_if *ret;

cfg = net_if_get_config(iface);
if (!cfg) {
return;
}

net_if_ipv4_addr_rm(iface, &cfg->ipv4auto.requested_ip);
ifaddr = net_if_ipv4_addr_lookup(&cfg->ipv4auto.requested_ip, &ret);
if (ifaddr != NULL && ret == iface) {
net_if_ipv4_addr_rm(iface, &cfg->ipv4auto.requested_ip);
}

NET_DBG("Autoconf reset for %p", iface);
}
Expand Down
12 changes: 10 additions & 2 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -4277,6 +4277,11 @@ void net_if_ipv4_acd_failed(struct net_if *iface, struct net_if_addr *ifaddr)

void net_if_ipv4_start_acd(struct net_if *iface, struct net_if_addr *ifaddr)
{
if ((l2_flags_get(iface) & NET_L2_POINT_TO_POINT) ||
net_ipv4_is_addr_loopback(&ifaddr->address.in_addr)) {
return;
}

ifaddr->addr_state = NET_ADDR_TENTATIVE;

if (net_if_is_up(iface)) {
Expand Down Expand Up @@ -4374,6 +4379,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
struct net_if_addr *ifaddr = NULL;
struct net_if_addr_ipv4 *cur;
struct net_if_ipv4 *ipv4;
bool do_acd = false;
int idx;

net_if_lock(iface);
Expand Down Expand Up @@ -4446,7 +4452,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
!(l2_flags_get(iface) & NET_L2_POINT_TO_POINT) &&
!net_ipv4_is_addr_loopback(addr)) {
/* ACD is started after the lock is released. */
;
do_acd = true;
} else {
ifaddr->addr_state = NET_ADDR_PREFERRED;
}
Expand All @@ -4459,7 +4465,9 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,

net_if_unlock(iface);

net_if_ipv4_start_acd(iface, ifaddr);
if (do_acd) {
net_if_ipv4_start_acd(iface, ifaddr);
}

return ifaddr;
}
Expand Down
Loading