network: address: also adjust scope when address is link local address
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Dec 2021 06:23:32 +0000 (15:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Dec 2021 06:25:19 +0000 (15:25 +0900)
But again only when Scope= is not explicitly specified.

src/network/networkd-address.c

index f9d21af15818163c72aee9f4655c58c2e9ed5160..618c278abfce2deca1557273e6ebe9e8a913bae4 100644 (file)
@@ -1916,8 +1916,12 @@ static int address_section_verify(Address *address) {
                 address->label = mfree(address->label);
         }
 
-        if (!address->scope_set && in_addr_is_localhost(address->family, &address->in_addr) > 0)
-                address->scope = RT_SCOPE_HOST;
+        if (!address->scope_set) {
+                if (in_addr_is_localhost(address->family, &address->in_addr) > 0)
+                        address->scope = RT_SCOPE_HOST;
+                else if (in_addr_is_link_local(address->family, &address->in_addr) > 0)
+                        address->scope = RT_SCOPE_LINK;
+        }
 
         if (address->family == AF_INET6 &&
             !FLAGS_SET(address->duplicate_address_detection, ADDRESS_FAMILY_IPV6))