From: Yu Watanabe Date: Mon, 7 Jun 2021 12:53:35 +0000 (+0900) Subject: network: address: always read address flag from IFA_FLAGS attribute X-Git-Tag: v249-rc1~79^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0828a38605975b68c14c9194a1ee2c5c2ff7038f;p=thirdparty%2Fsystemd.git network: address: always read address flag from IFA_FLAGS attribute 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. --- diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 8e7738f48f9..550e5c7f5ac 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -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: