LWIP::get_ip_addr: Prefer IPv4 over IPv6 link local addresses

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.
pull/15423/head
Jookia 2023-05-18 21:56:31 +10:00
parent b5692fd180
commit 06593d3d68
1 changed files with 3 additions and 6 deletions

View File

@ -110,12 +110,6 @@ const ip_addr_t *LWIP::get_ipv6_addr(const struct netif *netif)
return netif_ip_addr6(netif, i);
}
}
for (int i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
return netif_ip_addr6(netif, i);
}
}
#endif
return NULL;
}
@ -164,6 +158,9 @@ const ip_addr_t *LWIP::get_ip_addr(bool any_addr, const struct netif *netif)
pref_ip_addr = get_ipv6_addr(netif);
npref_ip_addr = get_ipv4_addr(netif);
#endif
if (!npref_ip_addr) {
npref_ip_addr = get_ipv6_link_local_addr(netif);
}
#elif LWIP_IPV6
pref_ip_addr = get_ipv6_addr(netif);
#elif LWIP_IPV4