e9e7d6
From 7e3250d52921b5f75bdbe0b794514bb78a209969 Mon Sep 17 00:00:00 2001
e9e7d6
From: Petr Mensik <pemensik@redhat.com>
e9e7d6
Date: Wed, 3 Jul 2019 17:02:16 +0200
e9e7d6
Subject: [PATCH 2/5] Compare address and interface index for allowed interface
e9e7d6
e9e7d6
If interface is recreated with the same address but different index, it
e9e7d6
would not change any other parameter.
e9e7d6
e9e7d6
Test also address family on incoming TCP queries.
e9e7d6
---
e9e7d6
 src/dnsmasq.c | 3 ++-
e9e7d6
 src/network.c | 3 ++-
e9e7d6
 2 files changed, 4 insertions(+), 2 deletions(-)
e9e7d6
e9e7d6
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
e9e7d6
index f3d2671..7812be8 100644
e9e7d6
--- a/src/dnsmasq.c
e9e7d6
+++ b/src/dnsmasq.c
e9e7d6
@@ -1614,7 +1614,8 @@ static void check_dns_listeners(time_t now)
e9e7d6
 #endif
e9e7d6
 		  
e9e7d6
 		  for (iface = daemon->interfaces; iface; iface = iface->next)
e9e7d6
-		    if (iface->index == if_index)
e9e7d6
+		    if (iface->index == if_index &&
e9e7d6
+		        iface->addr.sa.sa_family == tcp_addr.sa.sa_family)
e9e7d6
 		      break;
e9e7d6
 		  
e9e7d6
 		  if (!iface && !loopback_exception(listener->tcpfd, tcp_addr.sa.sa_family, &addr, intr_name))
e9e7d6
diff --git a/src/network.c b/src/network.c
e9e7d6
index fd90288..f247811 100644
e9e7d6
--- a/src/network.c
e9e7d6
+++ b/src/network.c
e9e7d6
@@ -404,10 +404,11 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
e9e7d6
   /* check whether the interface IP has been added already 
e9e7d6
      we call this routine multiple times. */
e9e7d6
   for (iface = daemon->interfaces; iface; iface = iface->next) 
e9e7d6
-    if (sockaddr_isequal(&iface->addr, addr))
e9e7d6
+    if (sockaddr_isequal(&iface->addr, addr) && iface->index == if_index)
e9e7d6
       {
e9e7d6
 	iface->dad = !!(iface_flags & IFACE_TENTATIVE);
e9e7d6
 	iface->found = 1; /* for garbage collection */
e9e7d6
+	iface->netmask = netmask;
e9e7d6
 	return 1;
e9e7d6
       }
e9e7d6
 
e9e7d6
-- 
e9e7d6
2.20.1
e9e7d6