From: Roy Marples Date: Sat, 12 Jan 2019 13:36:01 +0000 (+0000) Subject: FreeBSD: Fix bogus RTM_DELADDR messages from affecting DHCP lease X-Git-Tag: v7.1.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca9f7f084f3be88c83fa6f346ac5cccc20ebe80b;p=thirdparty%2Fdhcpcd.git FreeBSD: Fix bogus RTM_DELADDR messages from affecting DHCP lease --- diff --git a/src/if-bsd.c b/src/if-bsd.c index 5f76b544..7e4b6774 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -1114,22 +1114,21 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam) * This makes this call very heavy weight, but we * really need to know if the message is late or not. */ + const struct sockaddr *sa; struct ifaddrs *ifaddrs = NULL, *ifa; - struct in_addr *a; - getifaddrs(&ifa); + sa = rti_info[RTAX_IFA]; + getifaddrs(&ifaddrs); for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) { - if (ifa->ifa_addr == NULL || - ifa->ifa_addr->sa_family != AF_INET) + if (ifa->ifa_addr == NULL) continue; - a = (void *)ifa->ifa_addr; - if (a->s_addr == addr.s_addr && + if (sa_cmp(ifa->ifa_addr, sa) == 0 && strcmp(ifa->ifa_name, ifp->name) == 0) break; } - freeifaddrs(ifa); + freeifaddrs(ifaddrs); if (ifa != NULL) - break; + return; #endif }