From 3f917b326b1a29a8dad85031e268616e8f06d6e2 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 22 May 2024 17:22:32 +1000 Subject: netlink, test: Ignore deprecated addresses When we retrieve or copy host addresses we can include deprecated addresses, which is not what we want. Adjust our logic to exclude them. Similarly our tests can retrieve deprecated addresses, so exclude them there too. I hit this in practice because my router sometimes temporarily advertises an fd00:: prefix before the real delegated IPv6 prefix. The deprecated address can hang around for some time messing up my tests. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'netlink.c') diff --git a/netlink.c b/netlink.c index b1c0cce..d3bea68 100644 --- a/netlink.c +++ b/netlink.c @@ -696,7 +696,7 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t af, struct rtattr *rta; size_t na; - if (ifa->ifa_index != ifi) + if (ifa->ifa_index != ifi || ifa->ifa_flags & IFA_F_DEPRECATED) continue; for (rta = IFA_RTA(ifa), na = IFA_PAYLOAD(nh); RTA_OK(rta, na); @@ -833,7 +833,8 @@ int nl_addr_dup(int s_src, unsigned int ifi_src, ifa = (struct ifaddrmsg *)NLMSG_DATA(nh); if (rc < 0 || ifa->ifa_scope == RT_SCOPE_LINK || - ifa->ifa_index != ifi_src) + ifa->ifa_index != ifi_src || + ifa->ifa_flags & IFA_F_DEPRECATED) continue; ifa->ifa_index = ifi_dst; -- cgit v1.2.3