Commit 24b5a5d5 authored by Simon Kelley's avatar Simon Kelley

dhcp-host selection fix for v4/v6

parent d56a604a
...@@ -144,6 +144,11 @@ version 2.67 ...@@ -144,6 +144,11 @@ version 2.67
target of --cname. Thanks to Hadmut Danisch for the target of --cname. Thanks to Hadmut Danisch for the
suggestion. suggestion.
Avoid treating a --dhcp-host which has an IPv6 address
as eligable for use with DHCPv4 on the grounds that it has
no address, and vice-versa. Thanks to Yury Konovalov for
spotting the problem.
version 2.66 version 2.66
Add the ability to act as an authoritative DNS Add the ability to act as an authoritative DNS
......
...@@ -272,27 +272,26 @@ static int is_config_in_context(struct dhcp_context *context, struct dhcp_config ...@@ -272,27 +272,26 @@ static int is_config_in_context(struct dhcp_context *context, struct dhcp_config
if (!context) /* called via find_config() from lease_update_from_configs() */ if (!context) /* called via find_config() from lease_update_from_configs() */
return 1; return 1;
if (!(context->flags & CONTEXT_V6)) if (!(config->flags & (CONFIG_ADDR | CONFIG_ADDR6)))
{ return 1;
if (!(config->flags & CONFIG_ADDR))
return 1; #ifdef HAVE_DHCP6
if ((context->flags & CONTEXT_V6) && (config->flags & CONFIG_WILDCARD))
return 1;
#endif
for (; context; context = context->current) for (; context; context = context->current)
if (is_same_net(config->addr, context->start, context->netmask))
return 1;
}
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
else if (context->flags & CONTEXT_V6)
{ {
if (!(config->flags & CONFIG_ADDR6) || (config->flags & CONFIG_WILDCARD)) if ((config->flags & CONFIG_ADDR6) && is_same_net6(&config->addr6, &context->start6, context->prefix))
return 1; return 1;
}
for (; context; context = context->current) else
if (is_same_net6(&config->addr6, &context->start6, context->prefix))
return 1;
}
#endif #endif
if ((config->flags & CONFIG_ADDR) && is_same_net(config->addr, context->start, context->netmask))
return 1;
return 0; return 0;
} }
......
...@@ -644,20 +644,20 @@ size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source) ...@@ -644,20 +644,20 @@ size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source)
int len; int len;
void *addrp; void *addrp;
if (source->sa.sa_family == AF_INET)
{
opt->family = htons(1);
opt->source_netmask = daemon->addr4_netmask;
addrp = &source->in.sin_addr;
}
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
else if (source->sa.sa_family == AF_INET6)
{ {
opt->family = htons(2); opt->family = htons(2);
opt->source_netmask = daemon->addr6_netmask; opt->source_netmask = daemon->addr6_netmask;
addrp = &source->in6.sin6_addr; addrp = &source->in6.sin6_addr;
} }
else
#endif #endif
{
opt->family = htons(1);
opt->source_netmask = daemon->addr4_netmask;
addrp = &source->in.sin_addr;
}
opt->scope_netmask = 0; opt->scope_netmask = 0;
len = 0; len = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment