aboutgitcodebugslistschat
path: root/netlink.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-05-22 17:22:32 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-05-22 23:21:09 +0200
commit3f917b326b1a29a8dad85031e268616e8f06d6e2 (patch)
tree8ca37770bf901d00b2d78964e96e8e7f7c8002be /netlink.c
parentcc801fb38f46157b83060b96ee99fa1669a6f42d (diff)
downloadpasst-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar.gz
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar.bz2
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar.lz
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar.xz
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.tar.zst
passt-3f917b326b1a29a8dad85031e268616e8f06d6e2.zip
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 <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'netlink.c')
-rw-r--r--netlink.c5
1 files changed, 3 insertions, 2 deletions
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;