summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2019-08-16 21:22:11 +0200
committerHans Dedecker <dedeckeh@gmail.com>2019-08-26 22:36:37 +0200
commit752fc2c278dc01f0b3ed2faf67a11f9bc1f3c627 (patch)
tree9f6dd8b11b898d02b536d593a6f717b27aa45e4c /src
parent09aa022ea1990dbb3f3f0d09331ef0cd1b8a8e1a (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')
-rw-r--r--src/odhcpd.h1
-rw-r--r--src/router.c11
-rw-r--r--src/router.h12
3 files changed, 18 insertions, 6 deletions
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 8715ca7..4a07252 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -212,6 +212,7 @@ struct interface {
// RA runtime data
struct odhcpd_event router_event;
struct uloop_timeout timer_rs;
+ uint32_t ra_sent;
// DHCPv6 runtime data
struct odhcpd_event dhcpv6_event;
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);
diff --git a/src/router.h b/src/router.h
index bdfe52c..0444da8 100644
--- a/src/router.h
+++ b/src/router.h
@@ -30,9 +30,11 @@ struct icmpv6_opt {
(void*)(opt + opt->len) <= (void*)(end); opt += opt->len)
-#define MaxRtrAdvInterval 1800
-#define MinRtrAdvInterval 3
+#define MaxInitialRtrAdvInterval 16
+#define MaxInitialRtAdvs 3
+#define MaxRtrAdvInterval 1800
+#define MinRtrAdvInterval 3
-#define ND_RA_FLAG_PROXY 0x4
-#define ND_RA_PREF_HIGH (1 << 3)
-#define ND_RA_PREF_LOW (3 << 3)
+#define ND_RA_FLAG_PROXY 0x4
+#define ND_RA_PREF_HIGH (1 << 3)
+#define ND_RA_PREF_LOW (3 << 3)