ndp: more fixes
authorSteven Barth <steven@midlink.org>
Fri, 17 Oct 2014 11:14:47 +0000 (13:14 +0200)
committerSteven Barth <steven@midlink.org>
Fri, 17 Oct 2014 11:14:47 +0000 (13:14 +0200)
README
src/config.c
src/ndp.c
src/odhcpd.c
src/odhcpd.h

diff --git a/README b/README
index b86df25fd32f88be8360fca006a9d36ddd9476ad..0d38e822c55ff9f9d051c2909e113deb3263db47 100644 (file)
--- a/README
+++ b/README
@@ -104,7 +104,6 @@ ra_preference       string  medium                  Route(r) preference
                [medium|high|low]
 ndproxy_routing        bool    1                       Learn routes from NDP
 ndproxy_slave  bool    0                       NDProxy external slave
-ndproxy_static list                            Static NDProxy prefixes
 
 
 Sections of type host (static leases)
index ea690661b7d2e45d6c25c60760d725f8a2ab6afe..5fbb921d0bc68ad0b7057fca806ca254927755de 100644 (file)
@@ -717,5 +717,8 @@ void odhcpd_run(void)
 
        odhcpd_reload();
        uloop_run();
+
+       while (!list_empty(&interfaces))
+               close_interface(list_first_entry(&interfaces, struct interface, head));
 }
 
index ae87d956cc3dff52b7740a00d954019e674f9abb..45bb9db4e1daf9eedc5f09aba6dea37e508682e1 100644 (file)
--- 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);
 }
 
 
@@ -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 : "<pending>");
+       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) {
index b8651ddd621155584b741ab344dbba2d67c566e9..0edf63ef4a06fa08e6bb5b16771f0aeac6794d11 100644 (file)
@@ -49,6 +49,12 @@ static int rtnl_seq = 0;
 static int urandom_fd = -1;
 
 
+static void sighandler(_unused int signal)
+{
+       uloop_end();
+}
+
+
 int main()
 {
        openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
@@ -71,6 +77,8 @@ int main()
                return 4;
 
        signal(SIGUSR1, SIG_IGN);
+       signal(SIGINT, sighandler);
+       signal(SIGTERM, sighandler);
 
        if (init_router())
                return 4;
@@ -377,6 +385,11 @@ int odhcpd_register(struct odhcpd_event *event)
        return uloop_fd_add(&event->uloop, ULOOP_READ);
 }
 
+void odhcpd_process(struct odhcpd_event *event)
+{
+       odhcpd_receive_packets(&event->uloop, 0);
+}
+
 void odhcpd_urandom(void *data, size_t len)
 {
        read(urandom_fd, data, len);
index 91c4f94def9b12c445a3a1e85dbb4af813b93072..c0e509db3f8e7465ebc08b3bdafb68161517b818 100644 (file)
@@ -179,6 +179,7 @@ extern struct list_head interfaces;
 // Exported main functions
 int odhcpd_open_rtnl(void);
 int odhcpd_register(struct odhcpd_event *event);
+void odhcpd_process(struct odhcpd_event *event);
 
 ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest,
                struct iovec *iov, size_t iov_len,