network: do not remove localhost address

Managing loopback interfaces by networkd is not recommended, but supporeted.
Even such spurious situation, do not drop the localhost addresses.
This commit is contained in:
Yu Watanabe
2022-02-01 11:30:37 +09:00
parent 259c65f36c
commit b69bfa4305
3 changed files with 18 additions and 0 deletions
+4
View File
@@ -854,6 +854,10 @@ int link_drop_foreign_addresses(Link *link) {
if (address->family == AF_INET6 && in6_addr_is_link_local(&address->in_addr.in6))
continue;
/* Do not remove localhost address (127.0.0.1 and ::1) */
if (link->flags & IFF_LOOPBACK && in_addr_is_localhost_one(address->family, &address->in_addr) > 0)
continue;
/* Ignore addresses we configured. */
if (address->source != NETWORK_CONFIG_SOURCE_FOREIGN)
continue;