ndp: deregister netlink event socket for non recoverable errors
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 10 Feb 2017 09:57:34 +0000 (10:57 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 10 Feb 2017 10:02:31 +0000 (11:02 +0100)
Deregister netlink event socket in case of error different
from ENOBUFS or failure to set netlink rx buffer size

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/ndp.c
src/odhcpd.c
src/odhcpd.h

index c6e4eda50f13eb3e1fc31870d51fceffc9e7fea5..427547dad9995899d54ac341bd0c36cc32bb017c 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -539,13 +539,17 @@ static void catch_rtnl_err(struct odhcpd_event *e, int error)
        struct event_socket *ev_sock = container_of(e, struct event_socket, ev);
 
        if (error != ENOBUFS)
-               return;
+               goto err;
 
        /* Double netlink event buffer size */
        ev_sock->sock_bufsize *= 2;
 
        if (nl_socket_set_buffer_size(ev_sock->sock, ev_sock->sock_bufsize, 0))
-               return;
+               goto err;
 
        dump_addr_table();
+       return;
+
+err:
+       odhcpd_deregister(e);
 }
index 2b0ea985c1c308c428af73cd352f0580b3289640..ed96178ba48de3140833d49524a7463343536987 100644 (file)
@@ -566,6 +566,12 @@ int odhcpd_register(struct odhcpd_event *event)
                        ((event->handle_error) ? ULOOP_ERROR_CB : 0));
 }
 
+int odhcpd_deregister(struct odhcpd_event *event)
+{
+       event->uloop.cb = NULL;
+       return uloop_fd_delete(&event->uloop);
+}
+
 void odhcpd_process(struct odhcpd_event *event)
 {
        odhcpd_receive_packets(&event->uloop, 0);
index 393194cab2ec8a342b26d00bdc972ab880063e03..fb78ec0eee7812ac1fbe557c3e0797c853e19da2 100644 (file)
@@ -188,6 +188,7 @@ extern struct list_head interfaces;
 
 // Exported main functions
 int odhcpd_register(struct odhcpd_event *event);
+int odhcpd_deregister(struct odhcpd_event *event);
 void odhcpd_process(struct odhcpd_event *event);
 
 struct nl_sock *odhcpd_create_nl_socket(int protocol);