diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2019-08-16 21:22:11 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-08-26 22:36:37 +0200 |
commit | 752fc2c278dc01f0b3ed2faf67a11f9bc1f3c627 (patch) | |
tree | 9f6dd8b11b898d02b536d593a6f717b27aa45e4c /src/router.c | |
parent | 09aa022ea1990dbb3f3f0d09331ef0cd1b8a8e1a (diff) |
router: speed up initial router advertisements
Speed up sending initial router advertisement messages as documented in
RFC2461 point 6.2.4
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/router.c')
-rw-r--r-- | src/router.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/router.c b/src/router.c index 34d43b0..07dd146 100644 --- a/src/router.c +++ b/src/router.c @@ -176,6 +176,7 @@ int router_setup_interface(struct interface *iface, bool enable) } iface->router_event.handle_dgram = handle_icmpv6; + iface->ra_sent = 0; odhcpd_register(&iface->router_event); } else { uloop_timeout_cancel(&iface->timer_rs); @@ -358,6 +359,13 @@ static int calc_adv_interval(struct interface *iface, uint32_t minvalid, msecs = (labs(msecs) % ((*maxival != minival) ? (*maxival - minival)*1000 : 500)) + minival*1000; + /* RFC 2461 6.2.4 For the first MAX_INITIAL_RTR_ADVERTISEMENTS advertisements */ + /* if the timer is bigger than MAX_INITIAL_RTR_ADVERT_INTERVAL it should be */ + /* set to MAX_INITIAL_RTR_ADVERT_INTERVAL */ + /* Off by one as an initial interval timer has already expired */ + if ((iface->ra_sent + 1) < MaxInitialRtAdvs && msecs > MaxInitialRtrAdvInterval*1000) + msecs = MaxInitialRtrAdvInterval*1000; + return msecs; } @@ -730,7 +738,8 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr syslog(LOG_NOTICE, "Sending a RA on %s", iface->name); - odhcpd_send(iface->router_event.uloop.fd, &dest, iov, ARRAY_SIZE(iov), iface); + if (odhcpd_send(iface->router_event.uloop.fd, &dest, iov, ARRAY_SIZE(iov), iface) > 0) + iface->ra_sent++; free(pfxs); free(routes); |