From: Roy Marples Date: Tue, 7 Jan 2020 22:28:55 +0000 (+0000) Subject: arp: use eloop_timespec_diff to handle wrapped times X-Git-Tag: v9.0.0~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a4585cc35b5e96a8d545d88bd75255488acb027;p=thirdparty%2Fdhcpcd.git arp: use eloop_timespec_diff to handle wrapped times --- diff --git a/src/arp.c b/src/arp.c index d585e96e..8589cef3 100644 --- a/src/arp.c +++ b/src/arp.c @@ -140,7 +140,7 @@ arp_found(struct arp_state *astate, const struct arp_msg *amsg) struct interface *ifp; struct ipv4_addr *ia; #ifndef KERNEL_RFC5227 - struct timespec now, defend; + struct timespec now; #endif arp_report_conflicted(astate, amsg); @@ -163,10 +163,9 @@ arp_found(struct arp_state *astate, const struct arp_msg *amsg) * messages. * If another conflict happens within DEFEND_INTERVAL * then we must drop our address and negotiate a new one. */ - defend.tv_sec = astate->defend.tv_sec + DEFEND_INTERVAL; - defend.tv_nsec = astate->defend.tv_nsec; clock_gettime(CLOCK_MONOTONIC, &now); - if (timespeccmp(&defend, &now, >)) + if (timespecisset(&astate->defend) && + eloop_timespec_diff(&astate->defend, &now, NULL) < DEFEND_INTERVAL) logwarnx("%s: %d second defence failed for %s", ifp->name, DEFEND_INTERVAL, inet_ntoa(astate->addr)); else if (arp_request(ifp, &astate->addr, &astate->addr) == -1)