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

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