dhcp-host selection fix for v4/v6.

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.
This commit is contained in:
Simon Kelley
2021-02-28 17:56:54 +00:00
parent 17360439dc
commit e7c0d7b348
2 changed files with 19 additions and 15 deletions

View File

@@ -14,6 +14,12 @@ version 2.85
sorts before v2.83test1. This fixes the problem which lead sorts before v2.83test1. This fixes the problem which lead
to 2.84 announcing itself as 2.84rc2. to 2.84 announcing itself as 2.84rc2.
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 Viktor Papp for
spotting the problem. (This bug was fixed was back in 2.67, and
then regessed in 2.81).
version 2.84 version 2.84
Fix a problem, introduced in 2.83, which could see DNS replies Fix a problem, introduced in 2.83, which could see DNS replies

View File

@@ -281,14 +281,15 @@ 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 (!(config->flags & (CONFIG_ADDR | CONFIG_ADDR6)))
return 1;
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
if (context->flags & CONTEXT_V6) if (context->flags & CONTEXT_V6)
{ {
struct addrlist *addr_list; struct addrlist *addr_list;
if (!(config->flags & CONFIG_ADDR6)) if (config->flags & CONFIG_ADDR6)
return 1;
for (; context; context = context->current) for (; context; context = context->current)
for (addr_list = config->addr6; addr_list; addr_list = addr_list->next) for (addr_list = config->addr6; addr_list; addr_list = addr_list->next)
{ {
@@ -302,9 +303,6 @@ static int is_config_in_context(struct dhcp_context *context, struct dhcp_config
else else
#endif #endif
{ {
if (!(config->flags & CONFIG_ADDR))
return 1;
for (; context; context = context->current) for (; context; context = context->current)
if ((config->flags & CONFIG_ADDR) && is_same_net(config->addr, context->start, context->netmask)) if ((config->flags & CONFIG_ADDR) && is_same_net(config->addr, context->start, context->netmask))
return 1; return 1;