router: skip RA and wait for LINK-LOCAL to be assigned
[project/odhcpd.git] / src / netlink.c
index 4a352a65e4aaab16b5db14b6518998aa26594f6c..0a2da03bbc165c1fb34012e22923cfa98b908f0c 100644 (file)
@@ -386,7 +386,7 @@ static int handle_rtm_addr(struct nlmsghdr *hdr, bool add)
 
                nla_memcpy(&event_info.addr, nla[IFA_ADDRESS], sizeof(event_info.addr));
 
-               if (IN6_IS_ADDR_LINKLOCAL(&event_info.addr) || IN6_IS_ADDR_MULTICAST(&event_info.addr))
+               if (IN6_IS_ADDR_MULTICAST(&event_info.addr))
                        return NL_SKIP;
 
                inet_ntop(AF_INET6, &event_info.addr, buf, sizeof(buf));
@@ -395,6 +395,11 @@ static int handle_rtm_addr(struct nlmsghdr *hdr, bool add)
                        if (iface->ifindex != (int)ifa->ifa_index)
                                continue;
 
+                       if (add && IN6_IS_ADDR_LINKLOCAL(&event_info.addr)) {
+                               iface->have_link_local = true;
+                               return NL_SKIP;
+                       }
+
                        syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr",
                                        buf, iface->name);
 
@@ -625,6 +630,10 @@ static int cb_addr_valid(struct nl_msg *msg, void *arg)
        if (ifa->ifa_flags & IFA_F_DEPRECATED)
                addrs[ctxt->ret].preferred = 0;
 
+       if (ifa->ifa_family == AF_INET6 &&
+           ifa->ifa_flags & IFA_F_TENTATIVE)
+               addrs[ctxt->ret].tentative = true;
+
        ctxt->ret++;
        *(ctxt->addrs) = addrs;