Check for new SLAAC addresses when we add new prefixes.

This commit is contained in:
Simon Kelley
2012-12-22 22:13:19 +00:00
parent 7f035f58c6
commit 0c0502426f
3 changed files with 27 additions and 4 deletions

View File

@@ -475,7 +475,7 @@ static int make_duid1(int index, unsigned int type, char *mac, size_t maclen, vo
struct cparam { struct cparam {
time_t now; time_t now;
int newone; int newone, newname;
}; };
static int construct_worker(struct in6_addr *local, int prefix, static int construct_worker(struct in6_addr *local, int prefix,
@@ -549,6 +549,10 @@ static int construct_worker(struct in6_addr *local, int prefix,
lease_update_file to get periodic functions called */ lease_update_file to get periodic functions called */
param->newone = 1; param->newone = 1;
/* Will need to add new putative SLAAC addresses to existing leases */
if (context->flags & CONTEXT_RA_NAME)
param->newname = 1;
log_context(AF_INET6, context); log_context(AF_INET6, context);
} }
} }
@@ -561,6 +565,7 @@ void dhcp_construct_contexts(time_t now)
struct dhcp_context *tmp, *context, **up; struct dhcp_context *tmp, *context, **up;
struct cparam param; struct cparam param;
param.newone = 0; param.newone = 0;
param.newname = 0;
param.now = now; param.now = now;
for (context = daemon->dhcp6; context; context = context->next) for (context = daemon->dhcp6; context; context = context->next)
@@ -578,10 +583,11 @@ void dhcp_construct_contexts(time_t now)
if (context->flags & CONTEXT_GC) if (context->flags & CONTEXT_GC)
{ {
if (daemon->dhcp6 == context)
daemon->dhcp6 = context->next;
*up = context->next; *up = context->next;
free(context); free(context);
param.newone = 1; /* include deletion */
if (context->flags & CONTEXT_RA_NAME)
param.newname = 1;
} }
else else
up = &context->next; up = &context->next;
@@ -590,7 +596,11 @@ void dhcp_construct_contexts(time_t now)
if (param.newone) if (param.newone)
{ {
if (daemon->dhcp || daemon->doing_dhcp6) if (daemon->dhcp || daemon->doing_dhcp6)
{
if (param.newname)
lease_update_slaac(now);
lease_update_file(now); lease_update_file(now);
}
else else
/* Not doing DHCP, so no lease system, manage alarms for ra only */ /* Not doing DHCP, so no lease system, manage alarms for ra only */
send_alarm(periodic_ra(now), now); send_alarm(periodic_ra(now), now);

View File

@@ -1047,6 +1047,7 @@ void lease6_filter(int lease_type, int iaid, struct dhcp_context *context);
struct dhcp_lease *lease6_find_by_addr(struct in6_addr *net, int prefix, u64 addr); struct dhcp_lease *lease6_find_by_addr(struct in6_addr *net, int prefix, u64 addr);
u64 lease_find_max_addr6(struct dhcp_context *context); u64 lease_find_max_addr6(struct dhcp_context *context);
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface); void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface);
void lease_update_slaac(time_t now);
#endif #endif
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr, void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force); unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force);

View File

@@ -389,6 +389,18 @@ void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *inte
slaac_ping_reply(sender, packet, interface, leases); slaac_ping_reply(sender, packet, interface, leases);
} }
void lease_update_slaac(time_t now)
{
/* Called when we contruct a new RA-names context, to add putative
new SLAAC addresses to existing leases. */
struct dhcp_lease *lease;
if (daemon->dhcp)
for (lease = leases; lease; lease = lease->next)
slaac_add_addrs(lease, now, 0);
}
#endif #endif