Skip to content

Commit 68393e0

Browse files
jukkarkartben
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 <[email protected]> (cherry picked from commit 902c95a)
1 parent e3c1159 commit 68393e0

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
@@ -4277,6 +4277,11 @@ void net_if_ipv4_acd_failed(struct net_if *iface, struct net_if_addr *ifaddr)
42774277

42784278
void net_if_ipv4_start_acd(struct net_if *iface, struct net_if_addr *ifaddr)
42794279
{
4280+
if ((l2_flags_get(iface) & NET_L2_POINT_TO_POINT) ||
4281+
net_ipv4_is_addr_loopback(&ifaddr->address.in_addr)) {
4282+
return;
4283+
}
4284+
42804285
ifaddr->addr_state = NET_ADDR_TENTATIVE;
42814286

42824287
if (net_if_is_up(iface)) {
@@ -4374,6 +4379,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
43744379
struct net_if_addr *ifaddr = NULL;
43754380
struct net_if_addr_ipv4 *cur;
43764381
struct net_if_ipv4 *ipv4;
4382+
bool do_acd = false;
43774383
int idx;
43784384

43794385
net_if_lock(iface);
@@ -4446,7 +4452,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
44464452
!(l2_flags_get(iface) & NET_L2_POINT_TO_POINT) &&
44474453
!net_ipv4_is_addr_loopback(addr)) {
44484454
/* ACD is started after the lock is released. */
4449-
;
4455+
do_acd = true;
44504456
} else {
44514457
ifaddr->addr_state = NET_ADDR_PREFERRED;
44524458
}
@@ -4459,7 +4465,9 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface,
44594465

44604466
net_if_unlock(iface);
44614467

4462-
net_if_ipv4_start_acd(iface, ifaddr);
4468+
if (do_acd) {
4469+
net_if_ipv4_start_acd(iface, ifaddr);
4470+
}
44634471

44644472
return ifaddr;
44654473
}

0 commit comments

Comments
 (0)