Fix botch in new arp-cache linked-list code resulting in 100% CPU spin.

This commit is contained in:
Simon Kelley
2016-01-04 17:17:41 +00:00
parent cc7cb0b893
commit d917275e48

View File

@@ -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. */ /* If in lazy mode, we cache absence of ARP entries. */
int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now) 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; int updated = 0;
again: again:
@@ -155,7 +155,10 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
iface_enumerate(AF_UNSPEC, NULL, filter_mac); iface_enumerate(AF_UNSPEC, NULL, filter_mac);
/* Remove all unconfirmed entries to old list. */ /* Remove all unconfirmed entries to old list. */
for (arp = arps, up = &arps; arp; arp = arp->next) for (arp = arps, up = &arps; arp; arp = tmp)
{
tmp = arp->next;
if (arp->status == ARP_MARK) if (arp->status == ARP_MARK)
{ {
*up = arp->next; *up = arp->next;
@@ -164,6 +167,7 @@ int find_mac(union mysockaddr *addr, unsigned char *mac, int lazy, time_t now)
} }
else else
up = &arp->next; up = &arp->next;
}
goto again; goto again;
} }