]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
BSD: Listen for Router -> Host messages via RTM_CHANGE
authorRoy Marples <roy@marples.name>
Thu, 29 Aug 2019 18:04:21 +0000 (19:04 +0100)
committerRoy Marples <roy@marples.name>
Thu, 29 Aug 2019 18:04:21 +0000 (19:04 +0100)
If there is a lladdr in the gateway address then the node
has become reachable. If there is no lladdr in the gateway address
then the node is no longer a router.

Unreachable is sent via RTM_DELETE and we ignore the initial
RTM_ADD without a lladdr.

src/if-bsd.c

index 83a2f1694b840eb941e540eed66dc46d80e6864a..ed5041d5b75fb68e01f57260093ee5d491048599 100644 (file)
@@ -1087,9 +1087,17 @@ if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
         */
        if (rt.rt_dest.sa_family == AF_INET6 &&
            rt.rt_flags & RTF_HOST &&
-           (rtm->rtm_type == RTM_DELETE || rt.rt_dflags & RTDF_GATELINK))
-               ipv6nd_neighbour(ctx, &rt.rt_ss_dest.sin6.sin6_addr,
-                   rtm->rtm_type != RTM_DELETE ? IPV6ND_REACHABLE : 0);
+           !(rtm->rtm_type == RTM_ADD && !(rt.rt_dflags & RTDF_GATELINK)))
+       {
+               int flags = 0;
+
+               if (rt.rt_dflags & RTDF_GATELINK)
+                       flags |= IPV6ND_ROUTER;
+               if (rtm->rtm_type != RTM_DELETE)
+                       flags |= IPV6ND_REACHABLE;
+
+               ipv6nd_neighbour(ctx, &rt.rt_ss_dest.sin6.sin6_addr, flags);
+       }
 #endif
 
        rt_recvrt(rtm->rtm_type, &rt, rtm->rtm_pid);