network: address: do not adjust user specified scope
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Dec 2021 06:18:34 +0000 (15:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Dec 2021 06:25:05 +0000 (15:25 +0900)
This reverts cd1caf30c0bd0d0c6e8df7610c614f52a7345c40.

I cannot remember why such change was made.
At least, the kernel does not refuse to set IPv4 localhost address with
non-host scope, e.g. global.

src/network/networkd-address.c

index 6eea4ff0bda21f82908955e20bb6cc489279a585..f9d21af15818163c72aee9f4655c58c2e9ed5160 100644 (file)
@@ -1916,19 +1916,8 @@ static int address_section_verify(Address *address) {
                 address->label = mfree(address->label);
         }
 
-        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 for localhost address. "
-                                          "Ignoring Scope= setting in the [Address] section from line %u. ",
-                                          address->section->filename, address->section->line);
-
+        if (!address->scope_set && in_addr_is_localhost(address->family, &address->in_addr) > 0)
                 address->scope = RT_SCOPE_HOST;
-        }
 
         if (address->family == AF_INET6 &&
             !FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV6))