]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Fix botch in new arp-cache linked-list code resulting in 100% CPU spin.
authorSimon Kelley <simon@thekelleys.org.uk>
Mon, 4 Jan 2016 17:17:41 +0000 (17:17 +0000)
committerSimon Kelley <simon@thekelleys.org.uk>
Mon, 4 Jan 2016 17:17:41 +0000 (17:17 +0000)
src/arp.c

index f41cdece8b7c3598bafb4d683c43dbdaf543b794..d17eedbac6515a423ce58b054ae85f53fb2b8cdf 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -110,7 +110,7 @@ static int filter_mac(int family, char *addrp, char *mac, size_t maclen, void *p
 /* If in lazy mode, we cache absence of ARP entries. */
 int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
 {
-  struct arp_record *arp, **up;
+  struct arp_record *arp, *tmp, **up;
   int updated = 0;
 
  again:
@@ -155,16 +155,20 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
        iface_enumerate(AF_UNSPEC, NULL, filter_mac);
        
        /* Remove all unconfirmed entries to old list. */
-       for (arp = arps, up = &arps; arp; arp = arp->next)
-        if (arp->status == ARP_MARK)
-          {
-            *up = arp->next;
-            arp->next = old;
-            old = arp;
-          }
-        else
-          up = &arp->next;
+       for (arp = arps, up = &arps; arp; arp = tmp)
+        {
+          tmp = arp->next;
           
+          if (arp->status == ARP_MARK)
+            {
+              *up = arp->next;
+              arp->next = old;
+              old = arp;
+            }
+          else
+            up = &arp->next;
+        }
+
        goto again;
      }