Blame SOURCES/dnsmasq-2.76-rh1721668-3.patch

e9e7d6
From 527029312cbe37c0285240943ad02352d64d403d Mon Sep 17 00:00:00 2001
e9e7d6
From: Petr Mensik <pemensik@redhat.com>
e9e7d6
Date: Tue, 9 Jul 2019 14:05:59 +0200
e9e7d6
Subject: [PATCH 3/5] Cleanup interfaces no longer available
e9e7d6
e9e7d6
Clean addresses and interfaces not found after enumerate. Free unused
e9e7d6
records to speed up checking active interfaces and reduce used memory.
e9e7d6
---
e9e7d6
 src/network.c | 32 ++++++++++++++++++++++++++++++--
e9e7d6
 1 file changed, 30 insertions(+), 2 deletions(-)
e9e7d6
e9e7d6
diff --git a/src/network.c b/src/network.c
e9e7d6
index f247811..d6d4b01 100644
e9e7d6
--- a/src/network.c
e9e7d6
+++ b/src/network.c
e9e7d6
@@ -553,7 +553,30 @@ static int iface_allowed_v4(struct in_addr local, int if_index, char *label,
e9e7d6
 
e9e7d6
   return iface_allowed((struct iface_param *)vparam, if_index, label, &addr, netmask, prefix, 0);
e9e7d6
 }
e9e7d6
-   
e9e7d6
+
e9e7d6
+/*
e9e7d6
+ * Clean old interfaces no longer found.
e9e7d6
+ */
e9e7d6
+static void clean_interfaces()
e9e7d6
+{
e9e7d6
+  struct irec *iface;
e9e7d6
+  struct irec **up = &daemon->interfaces;
e9e7d6
+
e9e7d6
+  for (iface = *up; iface; iface = *up)
e9e7d6
+  {
e9e7d6
+    if (!iface->found && !iface->done)
e9e7d6
+      {
e9e7d6
+        *up = iface->next;
e9e7d6
+        free(iface->name);
e9e7d6
+        free(iface);
e9e7d6
+      }
e9e7d6
+    else
e9e7d6
+      {
e9e7d6
+        up = &iface->next;
e9e7d6
+      }
e9e7d6
+  }
e9e7d6
+}
e9e7d6
+
e9e7d6
 int enumerate_interfaces(int reset)
e9e7d6
 {
e9e7d6
   static struct addrlist *spare = NULL;
e9e7d6
@@ -653,6 +676,7 @@ int enumerate_interfaces(int reset)
e9e7d6
 	 in OPT_CLEVERBIND mode, that at listener will just disappear after
e9e7d6
 	 a call to enumerate_interfaces, this is checked OK on all calls. */
e9e7d6
       struct listener *l, *tmp, **up;
e9e7d6
+      int freed = 0;
e9e7d6
       
e9e7d6
       for (up = &daemon->listeners, l = daemon->listeners; l; l = tmp)
e9e7d6
 	{
e9e7d6
@@ -682,10 +706,14 @@ int enumerate_interfaces(int reset)
e9e7d6
 		close(l->tftpfd);
e9e7d6
 	      
e9e7d6
 	      free(l);
e9e7d6
+	      freed = 1;
e9e7d6
 	    }
e9e7d6
 	}
e9e7d6
+
e9e7d6
+      if (freed)
e9e7d6
+	clean_interfaces();
e9e7d6
     }
e9e7d6
-  
e9e7d6
+
e9e7d6
   errno = errsave;
e9e7d6
   spare = param.spare;
e9e7d6
     
e9e7d6
-- 
e9e7d6
2.20.1
e9e7d6