router:
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 12 Apr 2019 13:47:29 +0000 (15:47 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 12 Apr 2019 13:53:11 +0000 (15:53 +0200)
src/router.c

index 9055367e0b00cd75b32d956d64129e649557f8b7..053b9e88df16b68bb86f7b61da4a9ad4703a1d10 100644 (file)
@@ -542,6 +542,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
        /* Calculate periodic transmit */
        uint32_t maxival;
        int msecs = calc_adv_interval(iface, minvalid, &maxival);
+       uint16_t lifetime = calc_ra_lifetime(iface, maxival);
 
        if (default_route) {
                if (!valid_prefix) {
@@ -549,7 +550,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                                        "on %s thus we don't announce a default route!", iface->name);
                        adv.h.nd_ra_router_lifetime = 0;
                } else
-                       adv.h.nd_ra_router_lifetime = htons(calc_ra_lifetime(iface, maxival));
+                       adv.h.nd_ra_router_lifetime = htons(lifetime);
 
        } else
                adv.h.nd_ra_router_lifetime = 0;
@@ -659,7 +660,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                        routes[routes_cnt].flags |= ND_RA_PREF_LOW;
                else if (iface->route_preference > 0)
                        routes[routes_cnt].flags |= ND_RA_PREF_HIGH;
-               routes[routes_cnt].lifetime = htonl(TIME_LEFT(addr->valid, now));
+               routes[routes_cnt].lifetime = htonl(lifetime);
                routes[routes_cnt].addr[0] = addr->addr.in6.s6_addr32[0];
                routes[routes_cnt].addr[1] = addr->addr.in6.s6_addr32[1];
                routes[routes_cnt].addr[2] = 0;
@@ -668,8 +669,8 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                ++routes_cnt;
        }
 
-       search->lifetime = htonl(maxival*10);
-       dns.lifetime = search->lifetime;
+       search->lifetime = htonl(lifetime);
+       dns.lifetime = htonl(lifetime);
 
        struct icmpv6_opt adv_interval = {
                .type = ND_OPT_RTR_ADV_INTERVAL,