odhcpd: display correct default log level in usage text
[project/odhcpd.git] / src / ndp.c
index c6e4eda..5866588 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -328,8 +328,8 @@ static void setup_route(struct in6_addr *addr, struct interface *iface, bool add
 static int prefixcmp(const void *va, const void *vb)
 {
        const struct odhcpd_ipaddr *a = va, *b = vb;
 static int prefixcmp(const void *va, const void *vb)
 {
        const struct odhcpd_ipaddr *a = va, *b = vb;
-       uint32_t a_pref = ((a->addr.s6_addr[0] & 0xfe) != 0xfc) ? a->preferred : 1;
-       uint32_t b_pref = ((b->addr.s6_addr[0] & 0xfe) != 0xfc) ? b->preferred : 1;
+       uint32_t a_pref = IN6_IS_ADDR_ULA(&a->addr) ? 1 : a->preferred;
+       uint32_t b_pref = IN6_IS_ADDR_ULA(&b->addr) ? 1 : b->preferred;
        return (a_pref < b_pref) ? 1 : (a_pref > b_pref) ? -1 : 0;
 }
 
        return (a_pref < b_pref) ? 1 : (a_pref > b_pref) ? -1 : 0;
 }
 
@@ -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)
        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))
 
        /* 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();
 
        dump_addr_table();
+       return;
+
+err:
+       odhcpd_deregister(e);
 }
 }