netlink: fix triggering of NETEV_ADDR6LIST_CHANGE event
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 26 Nov 2018 13:58:08 +0000 (14:58 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 27 Nov 2018 08:50:41 +0000 (09:50 +0100)
Generate a NETEV_ADDR6LIST_CHANGE event in case the preferred lifetime
makes a transition from deprecated (preferred lifetime not greater than
current timestamp) to not deprecated (preferred lifetime greater than
current timestamp)

Reported-by: Tian Hao <haotia@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/netlink.c

index d2386043a268510109041324849c28bf96a76737..e502be063c6c622be454a5767e2093a1a0bd3166 100644 (file)
@@ -160,6 +160,7 @@ static void refresh_iface_addr6(struct netevent_handler_info *event_info)
        struct odhcpd_ipaddr *addr = NULL;
        struct interface *iface = event_info->iface;
        ssize_t len = netlink_get_interface_addrs(iface->ifindex, true, &addr);
+       time_t now = odhcpd_time();
 
        if (len < 0)
                return;
@@ -167,7 +168,7 @@ static void refresh_iface_addr6(struct netevent_handler_info *event_info)
        bool change = len != (ssize_t)iface->addr6_len;
        for (ssize_t i = 0; !change && i < len; ++i)
                if (!IN6_ARE_ADDR_EQUAL(&addr[i].addr.in6, &iface->addr6[i].addr.in6) ||
-                               (addr[i].preferred > 0) != (iface->addr6[i].preferred > 0) ||
+                               (addr[i].preferred > (uint32_t)now) != (iface->addr6[i].preferred > (uint32_t)now) ||
                                addr[i].valid < iface->addr6[i].valid ||
                                addr[i].preferred < iface->addr6[i].preferred)
                        change = true;