router: fix invalid router lifetime
[project/odhcpd.git] / src / router.c
index e3a9aa9..51fd954 100644 (file)
@@ -321,7 +321,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                }
        }
 
-       if (maxvalid && !iface->default_router && adv.h.nd_ra_router_lifetime) {
+       if (!maxvalid && !iface->default_router && adv.h.nd_ra_router_lifetime) {
                syslog(LOG_WARNING, "A default route is present but there is no public prefix "
                                "on %s thus we don't announce a default route!", iface->ifname);
                adv.h.nd_ra_router_lifetime = 0;
@@ -437,7 +437,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
 
        minival = (maxival * 3) / 4;
        if (adv.h.nd_ra_router_lifetime)
-               adv.h.nd_ra_router_lifetime = htons(maxvalid);
+               adv.h.nd_ra_router_lifetime = htons(maxvalid / 1000);
 
        odhcpd_urandom(&msecs, sizeof(msecs));
        msecs = (labs(msecs) % (maxival - minival)) + minival;