Fix initialisation order.

This commit is contained in:
Simon Kelley
2012-12-17 21:54:08 +00:00
parent 72c9c3b11b
commit 8445f5d2e2
4 changed files with 18 additions and 13 deletions

View File

@@ -577,7 +577,10 @@ void dhcp_construct_contexts(time_t now)
for (context = daemon->dhcp6; context; context = context->next) for (context = daemon->dhcp6; context; context = context->next)
if (context->flags & CONTEXT_CONSTRUCTED) if (context->flags & CONTEXT_CONSTRUCTED)
context->flags |= CONTEXT_GC; {
context->flags |= CONTEXT_GC;
context->if_index = 0;
}
iface_enumerate(AF_INET6, &param, construct_worker); iface_enumerate(AF_INET6, &param, construct_worker);

View File

@@ -210,7 +210,6 @@ int main (int argc, char **argv)
#endif #endif
#ifdef HAVE_LINUX_NETWORK #ifdef HAVE_LINUX_NETWORK
/* After lease_init */
netlink_init(); netlink_init();
if (option_bool(OPT_NOWILD) && option_bool(OPT_CLEVERBIND)) if (option_bool(OPT_NOWILD) && option_bool(OPT_CLEVERBIND))
@@ -223,12 +222,6 @@ int main (int argc, char **argv)
join_multicast(); join_multicast();
#endif #endif
#ifdef HAVE_DHCP
/* after netlink_init */
if (daemon->dhcp || daemon->doing_dhcp6)
lease_find_interfaces(now);
#endif
if (!enumerate_interfaces()) if (!enumerate_interfaces())
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC); die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
@@ -650,6 +643,9 @@ int main (int argc, char **argv)
my_syslog(MS_DHCP | LOG_INFO, _("IPv6 router advertisement enabled")); my_syslog(MS_DHCP | LOG_INFO, _("IPv6 router advertisement enabled"));
# endif # endif
/* after dhcp_contruct_contexts */
if (daemon->dhcp || daemon->doing_dhcp6)
lease_find_interfaces(now);
#endif #endif
#ifdef HAVE_TFTP #ifdef HAVE_TFTP

View File

@@ -200,13 +200,19 @@ int iface_enumerate(int family, void *parm, int (*callback)())
after we complete as we're not re-entrant */ after we complete as we're not re-entrant */
if (newaddr) if (newaddr)
{ {
time_t now = dnsmasq_time();
if (option_bool(OPT_CLEVERBIND)) if (option_bool(OPT_CLEVERBIND))
{ {
enumerate_interfaces(); enumerate_interfaces();
create_bound_listeners(0); create_bound_listeners(0);
} }
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
dhcp_construct_contexts(dnsmasq_time()); if (daemon->doing_dhcp6 || daemon->doing_ra)
dhcp_construct_contexts(now);
if (daemon->doing_dhcp6)
lease_find_interfaces(now);
#endif #endif
} }
return callback_ok; return callback_ok;

View File

@@ -2180,7 +2180,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
case 'F': /* --dhcp-range */ case 'F': /* --dhcp-range */
{ {
int k, leasepos = 2; int k, leasepos = 2;
char *cp, *a[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; char *cp, *a[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
struct dhcp_context *new = opt_malloc(sizeof(struct dhcp_context)); struct dhcp_context *new = opt_malloc(sizeof(struct dhcp_context));
memset (new, 0, sizeof(*new)); memset (new, 0, sizeof(*new));