net: if: Do not start ACD for localhost or point2point links
When adding IPv4 address to the network interface, there is no need to start ACD procedure for localhost or point-to-point links. The ACD start function would mark the IP address like 127.0.0.1 as tentative and never make it preferred which would then cause issues when selecting the network address for sending. As the ACD start is also called when the network interface comes up, add the localhost and point-to-point link check to ACD start function so that we will avoid ACD checks in this case. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
976f963d13
commit
902c95ab95
1 changed files with 10 additions and 2 deletions
|
@ -4402,6 +4402,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)) {
|
||||
|
@ -4499,6 +4504,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);
|
||||
|
@ -4571,7 +4577,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;
|
||||
}
|
||||
|
@ -4584,7 +4590,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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue