- add ? "Added" : "Deleted", ipbuf, iface->ifname);
- }
-}
-
-void setup_ping6(struct in6_addr *addr, struct interface *iface)
-{
- struct interface *c;
-
- list_for_each_entry(c, &interfaces, head) {
- if (iface == c || c->ndp != RELAYD_RELAY ||
- c->external == true)
- continue;
-
- ping6(addr, c);
- }
-}
-
-static struct in6_addr last_solicited;
-
-static void handle_rtnl_event(struct odhcpd_event *e)
-{
- struct event_socket *ev_sock = container_of(e, struct event_socket, ev);
-
- nl_recvmsgs_default(ev_sock->sock);
-}
-
-
-// Handler for neighbor cache entries from the kernel. This is our source
-// to learn and unlearn hosts on interfaces.
-static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
-{
- struct nlmsghdr *hdr = nlmsg_hdr(msg);
- struct in6_addr *addr = NULL;
- struct interface *iface = NULL;
- bool add = false;
- char ipbuf[INET6_ADDRSTRLEN];
-
- switch (hdr->nlmsg_type) {
- case RTM_NEWROUTE:
- case RTM_DELROUTE: {
- struct rtmsg *rtm = nlmsg_data(hdr);
-
- if (!nlmsg_valid_hdr(hdr, sizeof(*rtm)) ||
- rtm->rtm_family != AF_INET6)
- return NL_SKIP;
-
- if (rtm->rtm_dst_len == 0) {
- syslog(LOG_INFO, "Raising SIGUSR1 due to default route change");
- raise(SIGUSR1);
- }
- return NL_OK;
- }
-
- case RTM_NEWADDR:
- add = true;
- case RTM_DELADDR: {
- struct ifaddrmsg *ifa = nlmsg_data(hdr);
- struct nlattr *nla[__IFA_MAX];
-
- if (!nlmsg_valid_hdr(hdr, sizeof(*ifa)) ||
- ifa->ifa_family != AF_INET6)
- return NL_SKIP;
-
- iface = odhcpd_get_interface_by_index(ifa->ifa_index);
- if (!iface)
- return NL_SKIP;
-
- nlmsg_parse(hdr, sizeof(*ifa), nla, __IFA_MAX - 1, NULL);
- if (!nla[IFA_ADDRESS])
- return NL_SKIP;
-
- addr = nla_data(nla[IFA_ADDRESS]);
- if (!addr || IN6_IS_ADDR_LINKLOCAL(addr) ||
- IN6_IS_ADDR_MULTICAST(addr))
- return NL_SKIP;
-
- inet_ntop(AF_INET6, addr, ipbuf, sizeof(ipbuf));
- syslog(LOG_DEBUG, "Netlink %s %s%%%s", true ? "newaddr" : "deladdr",
- ipbuf, iface->ifname);
-
- check_addr_updates(iface);
-
- if (iface->ndp != RELAYD_RELAY)
- break;
-
- /* handle the relay logic below */
- setup_addr_for_relaying(addr, iface, add);
-
- if (!add)
- dump_neigh_table(false);
- break;