Skip to content

Commit 6b56f1c

Browse files
authored
LWIP::get_ip_addr: Prefer IPv4 over IPv6 link local addresses (ARMmbed#161)
When IPv6 is prefered it will choose a link local address on a network that lacks IPv6 over a working IPv4 network, breaking networking. Change this behaviour to prefer a link local address only as a last resort. This also changes LWIP::get_ipv6_addr to not return link local addresses. Use get_ipv6_link_local_addr instead for this.
1 parent 3f7d67c commit 6b56f1c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

connectivity/lwipstack/source/lwip_tools.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ const ip_addr_t *LWIP::get_ipv6_addr(const struct netif *netif)
110110
return netif_ip_addr6(netif, i);
111111
}
112112
}
113-
114-
for (int i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
115-
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
116-
return netif_ip_addr6(netif, i);
117-
}
118-
}
119113
#endif
120114
return NULL;
121115
}
@@ -164,6 +158,9 @@ const ip_addr_t *LWIP::get_ip_addr(bool any_addr, const struct netif *netif)
164158
pref_ip_addr = get_ipv6_addr(netif);
165159
npref_ip_addr = get_ipv4_addr(netif);
166160
#endif
161+
if (!npref_ip_addr) {
162+
npref_ip_addr = get_ipv6_link_local_addr(netif);
163+
}
167164
#elif LWIP_IPV6
168165
pref_ip_addr = get_ipv6_addr(netif);
169166
#elif LWIP_IPV4

0 commit comments

Comments
 (0)