Skip to content

Commit 902c95a

Browse files
jukkardkalowsk
authored andcommitted
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>
1 parent 976f963 commit 902c95a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

subsys/net/ip/net_if.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4402,6 +4402,11 @@ void net_if_ipv4_acd_failed(struct net_if *iface, struct net_if_addr *ifaddr)
44024402

44034403
void net_if_ipv4_start_acd(struct net_if *iface, struct net_if_addr *ifaddr)
44044404
{
4405+
if ((l2_flags_get(iface) & NET_L2_POINT_TO_POINT) ||
4406+
net_ipv4_is_addr_loopback(&ifaddr->address.in_addr)) {
4407+
return;
4408+
}
4409+
44054410
ifaddr->addr_state = NET_ADDR_TENTATIVE;
44064411

44074412
if (net_if_is_up(iface)) {
@@ -4499,6 +4504,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
44994504
struct net_if_addr *ifaddr = NULL;
45004505
struct net_if_addr_ipv4 *cur;
45014506
struct net_if_ipv4 *ipv4;
4507+
bool do_acd = false;
45024508
int idx;
45034509

45044510
net_if_lock(iface);
@@ -4571,7 +4577,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
45714577
!(l2_flags_get(iface) & NET_L2_POINT_TO_POINT) &&
45724578
!net_ipv4_is_addr_loopback(addr)) {
45734579
/* ACD is started after the lock is released. */
4574-
;
4580+
do_acd = true;
45754581
} else {
45764582
ifaddr->addr_state = NET_ADDR_PREFERRED;
45774583
}
@@ -4584,7 +4590,9 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
45844590

45854591
net_if_unlock(iface);
45864592

4587-
net_if_ipv4_start_acd(iface, ifaddr);
4593+
if (do_acd) {
4594+
net_if_ipv4_start_acd(iface, ifaddr);
4595+
}
45884596

45894597
return ifaddr;
45904598
}

0 commit comments

Comments
 (0)