From 0d9a9b35c355fa5273055d9cf21630d07adda40f Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Mon, 1 Sep 2014 15:52:07 +0600 Subject: ipv6: randomize router adverts as per rfc4861 and add tunable MaxInitialRtrAdvCount, MaxInitialRtrAdvInterval parameters --- accel-pppd/ipv6/nd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'accel-pppd/ipv6') diff --git a/accel-pppd/ipv6/nd.c b/accel-pppd/ipv6/nd.c index 8eb4b5e..1241380 100644 --- a/accel-pppd/ipv6/nd.c +++ b/accel-pppd/ipv6/nd.c @@ -192,10 +192,12 @@ static void send_ra_timer(struct triton_timer_t *t) addr.sin6_addr.s6_addr32[3] = htonl(0x1); addr.sin6_scope_id = h->ses->ifindex; - if (h->ra_sent++ == conf_init_ra) { + if (h->ra_sent == conf_init_ra) { h->timer.period = conf_MaxRtrAdvInterval * 1000; + h->timer.period -= (conf_MaxRtrAdvInterval - conf_MinRtrAdvInterval) * random() * 1000 / RAND_MAX; triton_timer_mod(t, 0); - } + } else + h->ra_sent++; ipv6_nd_send_ra(h, &addr); } @@ -328,6 +330,7 @@ static int ipv6_nd_start(struct ap_session *ses) triton_md_enable_handler(&h->hnd, MD_MODE_READ); triton_timer_add(ses->ctrl->ctx, &h->timer, 0); + send_ra_timer(&h->timer); return 0; @@ -483,6 +486,13 @@ static void load_config(void) if (opt) conf_MinRtrAdvInterval = atoi(opt); + opt = conf_get_opt("ipv6-nd", "MaxInitialRtrAdvCount"); + if (opt) + conf_init_ra = atoi(opt); + opt = conf_get_opt("ipv6-nd", "MaxInitialRtrAdvInterval"); + if (opt) + conf_init_ra_interval = atoi(opt); + opt = conf_get_opt("ipv6-nd", "AdvManagedFlag"); if (opt) conf_AdvManagedFlag = atoi(opt); -- cgit v1.2.3