router: advertise removed addresses as invalid in 3 consecutive RAs
[project/odhcpd.git] / src / odhcpd.c
index 4b8e5898d450bc661e0f4d29b48dfff1f35a101c..9797507db27fc2f00569de3507f57f11683643c1 100644 (file)
@@ -43,8 +43,6 @@
 #include <libubox/uloop.h>
 #include "odhcpd.h"
 
-
-
 static int ioctl_sock = -1;
 static int urandom_fd = -1;
 
@@ -141,8 +139,8 @@ int main(int argc, char **argv)
 int odhcpd_get_interface_config(const char *ifname, const char *what)
 {
        char buf[64];
-       const char *sysctl_pattern = "/proc/sys/net/ipv6/conf/%s/%s";
-       snprintf(buf, sizeof(buf), sysctl_pattern, ifname, what);
+       
+       snprintf(buf, sizeof(buf), "/proc/sys/net/ipv6/conf/%s/%s", ifname, what);
 
        int fd = open(buf, O_RDONLY);
        if (fd < 0)
@@ -255,6 +253,9 @@ int odhcpd_get_interface_dns_addr(const struct interface *iface, struct in6_addr
        time_t now = odhcpd_time();
        ssize_t m = -1;
 
+       if (!iface->dns_service)
+               return -1;
+
        for (size_t i = 0; i < iface->addr6_len; ++i) {
                if (iface->addr6[i].valid <= (uint32_t)now)
                        continue;
@@ -440,7 +441,7 @@ int odhcpd_urandom(void *data, size_t len)
 time_t odhcpd_time(void)
 {
        struct timespec ts;
-       syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts);
+       clock_gettime(CLOCK_MONOTONIC, &ts);
        return ts.tv_sec;
 }