From: Yu Watanabe Date: Sun, 4 Oct 2020 01:57:03 +0000 (+0900) Subject: network: always use RT_SCOPE_HOST for IPv4 loopback addresses X-Git-Tag: v247-rc1~117^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd1caf30c0bd0d0c6e8df7610c614f52a7345c40;p=thirdparty%2Fsystemd.git network: always use RT_SCOPE_HOST for IPv4 loopback addresses For IPv6 case, use RT_SCOPE_HOST only when scope is not explicitly specified. --- diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 000f8cfa932..58d2ffe3f2c 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -1867,8 +1867,19 @@ static int address_section_verify(Address *address) { address->section->filename, address->section->line); } - if (!address->scope_set && in_addr_is_localhost(address->family, &address->in_addr) > 0) + if (in_addr_is_localhost(address->family, &address->in_addr) > 0 && + (address->family == AF_INET || !address->scope_set)) { + /* For IPv4, scope must be always RT_SCOPE_HOST. + * For IPv6, use RT_SCOPE_HOST only when it is not explicitly specified. */ + + if (address->scope_set && address->scope != RT_SCOPE_HOST) + log_warning_errno(SYNTHETIC_ERRNO(EINVAL), + "%s: non-host scope is set in the [Address] section from line %u. " + "Ignoring Scope= setting.", + address->section->filename, address->section->line); + address->scope = RT_SCOPE_HOST; + } if (!FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV6)) address->flags |= IFA_F_NODAD;