diff --git a/CHANGELOG b/CHANGELOG index 3919d1d..8b57a36 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -144,6 +144,11 @@ version 2.67 target of --cname. Thanks to Hadmut Danisch for the 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 Add the ability to act as an authoritative DNS diff --git a/src/dhcp-common.c b/src/dhcp-common.c index 304c47e..5b0756d 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -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() */ return 1; - if (!(context->flags & CONTEXT_V6)) - { - if (!(config->flags & CONFIG_ADDR)) + if (!(config->flags & (CONFIG_ADDR | CONFIG_ADDR6))) + return 1; + +#ifdef HAVE_DHCP6 + if ((context->flags & CONTEXT_V6) && (config->flags & CONFIG_WILDCARD)) + return 1; +#endif + + for (; context; context = context->current) +#ifdef HAVE_DHCP6 + if (context->flags & CONTEXT_V6) + { + if ((config->flags & CONFIG_ADDR6) && is_same_net6(&config->addr6, &context->start6, context->prefix)) + return 1; + } + else +#endif + if ((config->flags & CONFIG_ADDR) && is_same_net(config->addr, context->start, context->netmask)) return 1; - for (; context; context = context->current) - if (is_same_net(config->addr, context->start, context->netmask)) - return 1; - } -#ifdef HAVE_DHCP6 - else - { - if (!(config->flags & CONFIG_ADDR6) || (config->flags & CONFIG_WILDCARD)) - return 1; - - for (; context; context = context->current) - if (is_same_net6(&config->addr6, &context->start6, context->prefix)) - return 1; - } -#endif - return 0; } diff --git a/src/rfc1035.c b/src/rfc1035.c index 7c1c30d..c1dc716 100644 --- a/src/rfc1035.c +++ b/src/rfc1035.c @@ -644,20 +644,20 @@ size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source) int len; 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 - else + if (source->sa.sa_family == AF_INET6) { opt->family = htons(2); opt->source_netmask = daemon->addr6_netmask; addrp = &source->in6.sin6_addr; } + else #endif + { + opt->family = htons(1); + opt->source_netmask = daemon->addr4_netmask; + addrp = &source->in.sin_addr; + } opt->scope_netmask = 0; len = 0;