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