From 29c2d4e1587e03a4d7589d045b81f7bea91c283e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 17 Feb 2025 06:03:38 +0900 Subject: [PATCH] network/address: IFA_FLAGS is supported since kernel v3.14 Our kernel base line is now v5.4. --- src/network/networkd-address.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index d0f0282075c..3857aad047e 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -1148,7 +1148,6 @@ static void address_forget(Link *link, Address *address, bool removed_by_us, con } static int address_set_netlink_message(const Address *address, sd_netlink_message *m, Link *link) { - uint32_t flags; int r; assert(address); @@ -1163,12 +1162,8 @@ static int address_set_netlink_message(const Address *address, sd_netlink_messag * flags except tentative flag here unconditionally. Without setting the flag, the template * addresses generated by kernel will not be removed automatically when the main address is * removed. */ - flags = address->flags & ~IFA_F_TENTATIVE; - r = sd_rtnl_message_addr_set_flags(m, flags & 0xff); - if (r < 0) - return r; - - if ((flags & ~0xff) != 0) { + uint32_t flags = address->flags & ~IFA_F_TENTATIVE; + if (flags != 0) { r = sd_netlink_message_append_u32(m, IFA_FLAGS, flags); if (r < 0) return r; @@ -1339,7 +1334,7 @@ int link_drop_ipv6ll_addresses(Link *link) { for (sd_netlink_message *addr = reply; addr; addr = sd_netlink_message_next(addr)) { _cleanup_(address_unrefp) Address *a = NULL; - unsigned char flags, prefixlen; + unsigned char prefixlen; struct in6_addr address; int ifindex; @@ -1352,9 +1347,10 @@ int link_drop_ipv6ll_addresses(Link *link) { } else if (link->ifindex != ifindex) continue; - r = sd_rtnl_message_addr_get_flags(addr, &flags); + uint32_t flags; + r = sd_netlink_message_read_u32(addr, IFA_FLAGS, &flags); if (r < 0) { - log_link_debug_errno(link, r, "rtnl: received address message without valid flags, ignoring: %m"); + log_link_debug_errno(link, r, "rtnl: Failed to read IFA_FLAGS attribute, ignoring: %m"); continue; } @@ -1971,14 +1967,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message, } r = sd_netlink_message_read_u32(message, IFA_FLAGS, &address->flags); - if (r == -ENODATA) { - unsigned char flags; - - /* For old kernels. */ - r = sd_rtnl_message_addr_get_flags(message, &flags); - if (r >= 0) - address->flags = flags; - } else if (r < 0) + if (r < 0) log_link_debug_errno(link, r, "rtnl: failed to read IFA_FLAGS attribute, ignoring: %m"); struct ifa_cacheinfo cinfo; -- 2.47.3