Per-context control over ra short period.

This commit is contained in:
Simon Kelley
2012-12-18 19:55:25 +00:00
parent 293fd0f700
commit 1b75c1e61f
3 changed files with 9 additions and 9 deletions

View File

@@ -542,7 +542,7 @@ static int construct_worker(struct in6_addr *local, int prefix,
context->next = daemon->dhcp6; context->next = daemon->dhcp6;
daemon->dhcp6 = context; daemon->dhcp6 = context;
ra_start_unsolicted(dnsmasq_time(), context); ra_start_unsolicted(param->now, context);
/* we created a new one, need to call /* we created a new one, need to call
lease_update_file to get periodic functions called */ lease_update_file to get periodic functions called */
param->newone = 1; param->newone = 1;

View File

@@ -678,7 +678,7 @@ struct dhcp_context {
struct in6_addr start6, end6; /* range of available addresses */ struct in6_addr start6, end6; /* range of available addresses */
struct in6_addr local6; struct in6_addr local6;
int prefix, if_index; int prefix, if_index;
time_t ra_time; time_t ra_time, ra_short_period_start;
char *template_interface; char *template_interface;
int valid, preferred; /* times from address for constructed contexts */ int valid, preferred; /* times from address for constructed contexts */
#endif #endif

View File

@@ -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 add_lla(int index, unsigned int type, char *mac, size_t maclen, void *parm);
static int hop_limit; static int hop_limit;
static time_t ra_short_period_start;
void ra_init(time_t now) 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 */ and pick up new interfaces */
if (context) if (context)
context->ra_time = now; context->ra_short_period_start = context->ra_time = now;
else else
for (context = daemon->dhcp6; context; context = context->next) for (context = daemon->dhcp6; context; context = context->next)
if (!(context->flags & CONTEXT_TEMPLATE)) if (!(context->flags & CONTEXT_TEMPLATE))
{
context->ra_time = now + (rand16()/13000); /* range 0 - 5 */ context->ra_time = now + (rand16()/13000); /* range 0 - 5 */
/* re-do frequently for a minute or so, in case the first gets lost. */ /* re-do frequently for a minute or so, in case the first gets lost. */
ra_short_period_start = now; context->ra_short_period_start = now;
}
} }
void icmp6_packet(time_t now) void icmp6_packet(time_t now)
@@ -552,7 +552,7 @@ static int iface_search(struct in6_addr *local, int prefix,
if (!dad) if (!dad)
param->iface = if_index; 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 */ /* range 5 - 20 */
context->ra_time = param->now + 5 + (rand16()/4400); context->ra_time = param->now + 5 + (rand16()/4400);
else else