diff options
author | Steven Barth <steven@midlink.org> | 2015-10-21 08:47:26 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2015-10-21 08:47:26 +0200 |
commit | aa3a13659ad6d2934f31e47a805b462269645f2d (patch) | |
tree | 9d3d45fb38d45d5f06d60f979997b739c9de6a76 | |
parent | b1c0c6664ed01d9643975bafb3026d699bd5e266 (diff) | |
parent | 1ef3103b7a9ac37bd2967ae57c5f0bc6e697bb7f (diff) |
Merge pull request #63 from willmo/router-lifetime
Clamp router lifetime per RFC 4861
-rw-r--r-- | src/router.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/router.c b/src/router.c index 526f9c2..74d8a09 100644 --- a/src/router.c +++ b/src/router.c @@ -292,10 +292,13 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add minvalid > 1000LL * TIME_LEFT(addr->valid, now)) minvalid = 1000LL * TIME_LEFT(addr->valid, now); + uint32_t this_lifetime = TIME_LEFT(addr->valid, now); + if (this_lifetime > UINT16_MAX) + this_lifetime = UINT16_MAX; if (((addr->addr.s6_addr[0] & 0xfe) != 0xfc || iface->default_router) && adv.h.nd_ra_router_lifetime - && ntohs(adv.h.nd_ra_router_lifetime) < TIME_LEFT(addr->valid, now)) - adv.h.nd_ra_router_lifetime = htons(TIME_LEFT(addr->valid, now)); + && ntohs(adv.h.nd_ra_router_lifetime) < this_lifetime) + adv.h.nd_ra_router_lifetime = htons(this_lifetime); odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr, (iface->ra_advrouter) ? 128 : addr->prefix); |