]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: address: always read address flag from IFA_FLAGS attribute 19839/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jun 2021 12:53:35 +0000 (21:53 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jun 2021 15:13:25 +0000 (00:13 +0900)
Otherwise, update flag become incomplete and the IFA_F_MANAGETEMPADDR flag
will not be stored, thus no temporary addresses will be removed when
networkd requests to remove the main address.

Follow-up for a8481354f0cd2c0855472193d0f57c7a77674969.
Fixes #13218.
Fixes #19838.

src/network/networkd-address.c

index 8e7738f48f905785313012bda0943a65e3ea3585..550e5c7f5acbc7d90d5987a357b2320d7c2e39e8 100644 (file)
@@ -42,17 +42,12 @@ static int address_flags_to_string_alloc(uint32_t flags, int family, char **ret)
         assert(IN_SET(family, AF_INET, AF_INET6));
         assert(ret);
 
-        for (size_t i = 0; i < ELEMENTSOF(map); i++) {
-                if (!FLAGS_SET(flags, map[i].flag))
-                        continue;
-                if (map[i].flag == IFA_F_SECONDARY && family == AF_INET6) {
-                        if (!strextend_with_separator(&str, ",", "temporary"))
-                                return -ENOMEM;
-                } else {
-                        if (!strextend_with_separator(&str, ",", map[i].name))
-                                return -ENOMEM;
-                }
-        }
+        for (size_t i = 0; i < ELEMENTSOF(map); i++)
+                if (flags & map[i].flag &&
+                    !strextend_with_separator(
+                                &str, ",",
+                                map[i].flag == IFA_F_SECONDARY && family == AF_INET6 ? "temporary" : map[i].name))
+                        return -ENOMEM;
 
         *ret = TAKE_PTR(str);
         return 0;
@@ -387,7 +382,7 @@ static int address_add_internal(Link *link, Set **addresses, const Address *in,
                 return r;
 
         /* Consider address tentative until we get the real flags from the kernel */
-        address->flags = IFA_F_TENTATIVE;
+        address->flags |= IFA_F_TENTATIVE;
 
         r = set_ensure_put(addresses, &address_hash_ops, address);
         if (r < 0)
@@ -1263,7 +1258,6 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
         _cleanup_(address_freep) Address *tmp = NULL;
         Link *link = NULL;
         uint16_t type;
-        unsigned char flags;
         Address *address = NULL;
         int ifindex, r;
 
@@ -1331,12 +1325,11 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
                 return 0;
         }
 
-        r = sd_rtnl_message_addr_get_flags(message, &flags);
+        r = sd_netlink_message_read_u32(message, IFA_FLAGS, &tmp->flags);
         if (r < 0) {
                 log_link_warning_errno(link, r, "rtnl: received address message without flags, ignoring: %m");
                 return 0;
         }
-        tmp->flags = flags;
 
         switch (tmp->family) {
         case AF_INET: