From 1b75c1e61ffc9be8648a646f6300f8d4d04f0e47 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 18 Dec 2012 19:55:25 +0000 Subject: [PATCH] Per-context control over ra short period. --- src/dhcp6.c | 2 +- src/dnsmasq.h | 2 +- src/radv.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dhcp6.c b/src/dhcp6.c index 18e477b..bf8e960 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -542,7 +542,7 @@ static int construct_worker(struct in6_addr *local, int prefix, context->next = daemon->dhcp6; daemon->dhcp6 = context; - ra_start_unsolicted(dnsmasq_time(), context); + ra_start_unsolicted(param->now, context); /* we created a new one, need to call lease_update_file to get periodic functions called */ param->newone = 1; diff --git a/src/dnsmasq.h b/src/dnsmasq.h index 385fd3a..0ae3621 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -678,7 +678,7 @@ struct dhcp_context { struct in6_addr start6, end6; /* range of available addresses */ struct in6_addr local6; int prefix, if_index; - time_t ra_time; + time_t ra_time, ra_short_period_start; char *template_interface; int valid, preferred; /* times from address for constructed contexts */ #endif diff --git a/src/radv.c b/src/radv.c index 6150cfc..2cce57e 100644 --- a/src/radv.c +++ b/src/radv.c @@ -48,7 +48,6 @@ static int iface_search(struct in6_addr *local, int prefix, static int add_lla(int index, unsigned int type, char *mac, size_t maclen, void *parm); static int hop_limit; -static time_t ra_short_period_start; void ra_init(time_t now) { @@ -99,14 +98,15 @@ void ra_start_unsolicted(time_t now, struct dhcp_context *context) and pick up new interfaces */ if (context) - context->ra_time = now; + context->ra_short_period_start = context->ra_time = now; else for (context = daemon->dhcp6; context; context = context->next) if (!(context->flags & CONTEXT_TEMPLATE)) - context->ra_time = now + (rand16()/13000); /* range 0 - 5 */ - - /* re-do frequently for a minute or so, in case the first gets lost. */ - ra_short_period_start = now; + { + context->ra_time = now + (rand16()/13000); /* range 0 - 5 */ + /* re-do frequently for a minute or so, in case the first gets lost. */ + context->ra_short_period_start = now; + } } void icmp6_packet(time_t now) @@ -552,7 +552,7 @@ static int iface_search(struct in6_addr *local, int prefix, if (!dad) param->iface = if_index; - if (difftime(param->now, ra_short_period_start) < 60.0) + if (difftime(param->now, context->ra_short_period_start) < 60.0) /* range 5 - 20 */ context->ra_time = param->now + 5 + (rand16()/4400); else