From 4ffda995b68dee8bfa6781b4724da1750fb6c3c8 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 29 Aug 2019 19:04:21 +0100 Subject: [PATCH] BSD: Listen for Router -> Host messages via RTM_CHANGE 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/if-bsd.c b/src/if-bsd.c index 83a2f169..ed5041d5 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -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); -- 2.47.2