3c5dfd
From 3d113137fd64cd0723cbecab6a36a75d3ecfb0a6 Mon Sep 17 00:00:00 2001
3c5dfd
From: =?UTF-8?q?Harald=20Jens=C3=A5s?= <hjensas@redhat.com>
3c5dfd
Date: Thu, 7 May 2020 00:33:54 +0200
3c5dfd
Subject: [PATCH 1/1] Fix regression in s_config_in_context() method
3c5dfd
3c5dfd
Prior to commit 137286e9baecf6a3ba97722ef1b49c851b531810
3c5dfd
a config would not be considered in context if:
3c5dfd
a) it has no address family flags set
3c5dfd
b) it has the address family flag of current context set
3c5dfd
3c5dfd
Since above commit config is considered in context if the
3c5dfd
address family is the opposite of current context.
3c5dfd
3c5dfd
The result is that a config with two dhcp-host records,
3c5dfd
one for IPv6 and another for IPv4 no longer works, for
3c5dfd
example with the below config the config with the IPv6
3c5dfd
address would be considered in context for a DHCP(v4)
3c5dfd
request.
3c5dfd
 dhcp-host=52:54:00:bc:c3:fd,172.20.0.11,host2
3c5dfd
 dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aadd],host2
3c5dfd
3c5dfd
This commit restores the previous behavior.
3c5dfd
---
3c5dfd
 src/dhcp-common.c | 10 +++++++---
3c5dfd
 1 file changed, 7 insertions(+), 3 deletions(-)
3c5dfd
3c5dfd
diff --git a/src/dhcp-common.c b/src/dhcp-common.c
3c5dfd
index eae9886..ffc78ca 100644
3c5dfd
--- a/src/dhcp-common.c
3c5dfd
+++ b/src/dhcp-common.c
3c5dfd
@@ -280,14 +280,18 @@ static int is_config_in_context(struct dhcp_context *context, struct dhcp_config
3c5dfd
 {
3c5dfd
   if (!context) /* called via find_config() from lease_update_from_configs() */
3c5dfd
     return 1; 
3c5dfd
-  
3c5dfd
+
3c5dfd
+  /* No address present in config == in context */
3c5dfd
+  if (!(config->flags & (CONFIG_ADDR | CONFIG_ADDR6)))
3c5dfd
+    return 1;
3c5dfd
+
3c5dfd
 #ifdef HAVE_DHCP6
3c5dfd
   if (context->flags & CONTEXT_V6)
3c5dfd
     {
3c5dfd
        struct addrlist *addr_list;
3c5dfd
 
3c5dfd
        if (!(config->flags & CONFIG_ADDR6))
3c5dfd
-	 return 1;
3c5dfd
+	 return 0;
3c5dfd
        
3c5dfd
         for (; context; context = context->current)
3c5dfd
 	  for (addr_list = config->addr6; addr_list; addr_list = addr_list->next)
3c5dfd
@@ -303,7 +307,7 @@ static int is_config_in_context(struct dhcp_context *context, struct dhcp_config
3c5dfd
 #endif
3c5dfd
     {
3c5dfd
       if (!(config->flags & CONFIG_ADDR))
3c5dfd
-	return 1;
3c5dfd
+	return 0;
3c5dfd
       
3c5dfd
       for (; context; context = context->current)
3c5dfd
 	if ((config->flags & CONFIG_ADDR) && is_same_net(config->addr, context->start, context->netmask))
3c5dfd
-- 
3c5dfd
2.25.4