X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=src%2Fndp.c;h=5e8b5ac04bb8ccb2e98b67c86db45136195421bf;hb=4fda796497a0d7814cfe100a1b0f09955f9b24ce;hp=ae87d956cc3dff52b7740a00d954019e674f9abb;hpb=b4fe0fbfe452e503e689104f093ee32875bc48d3;p=project%2Fodhcpd.git diff --git a/src/ndp.c b/src/ndp.c index ae87d95..5e8b5ac 100644 --- a/src/ndp.c +++ b/src/ndp.c @@ -115,6 +115,7 @@ static void dump_neigh_table(bool proxy) {.ndm_family = AF_INET6, .ndm_flags = (proxy) ? NTF_PROXY : 0} }; send(rtnl_event.uloop.fd, &req, sizeof(req), MSG_DONTWAIT); + odhcpd_process(&rtnl_event); } @@ -131,7 +132,7 @@ int setup_ndp_interface(struct interface *iface, bool enable) iface->ndp_event.uloop.fd = -1; if (!enable || iface->ndp != RELAYD_RELAY) - write(procfd, "0\n", 2); + if (write(procfd, "0\n", 2) < 0) {} dump_neigh = true; } @@ -151,7 +152,7 @@ int setup_ndp_interface(struct interface *iface, bool enable) } if (enable && iface->ndp == RELAYD_RELAY) { - write(procfd, "1\n", 2); + if (write(procfd, "1\n", 2) < 0) {} close(procfd); int sock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6)); @@ -309,18 +310,15 @@ void odhcpd_setup_route(const struct in6_addr *addr, int prefixlen, } // Use rtnetlink to modify kernel routes -static void setup_route(struct in6_addr *addr, struct interface *iface, - bool add) +static void setup_route(struct in6_addr *addr, struct interface *iface, bool add) { char namebuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, addr, namebuf, sizeof(namebuf)); - syslog(LOG_NOTICE, "%s about %s on %s", (add) ? "Learned" : "Forgot", - namebuf, (iface) ? iface->ifname : ""); + syslog(LOG_NOTICE, "%s about %s on %s", + (add) ? "Learned" : "Forgot", namebuf, iface->ifname); - if (!iface || !iface->learn_routes) - return; - - odhcpd_setup_route(addr, 128, iface, NULL, add); + if (iface->learn_routes) + odhcpd_setup_route(addr, 128, iface, NULL, add); } @@ -406,6 +404,7 @@ static void handle_rtnetlink(_unused void *addr, void *data, size_t len, if (nh->nlmsg_type == RTM_NEWNEIGH) { req.ndm.ndm_ifindex = iface->ifindex; send(rtnl_event.uloop.fd, &req, sizeof(req), MSG_DONTWAIT); + setup_route(addr, iface, false); dump_neigh = true; } } else if (add) {