summaryrefslogtreecommitdiffstats
path: root/src/ipv6nd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-01-04 07:20:50 +0000
committerRoy Marples <roy@marples.name>2020-01-04 07:20:50 +0000
commit858d217d04bf4026a07dbe5354542ff047a36162 (patch)
tree70beaba3c7d8268046ccdcbfc696b1564bd33fff /src/ipv6nd.c
parentbf45767fe07cda0b749690342b218428c8603747 (diff)
downloaddhcpcd-858d217d04bf4026a07dbe5354542ff047a36162.tar.xz
inet6: Use milliseconds rather than timespec for calcuating delays
Diffstat (limited to 'src/ipv6nd.c')
-rw-r--r--src/ipv6nd.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/ipv6nd.c b/src/ipv6nd.c
index f341cea6..10b20ed4 100644
--- a/src/ipv6nd.c
+++ b/src/ipv6nd.c
@@ -890,7 +890,6 @@ ipv6nd_dadcallback(void *arg)
struct interface *ifp;
struct ra *rap;
int wascompleted, found;
- struct timespec tv;
char buf[INET6_ADDRSTRLEN];
const char *p;
int dadcounter;
@@ -907,6 +906,8 @@ ipv6nd_dadcallback(void *arg)
* a different address is generated. */
/* XXX Cache DAD counter per prefix/id/ssid? */
if (ifp->options->options & DHCPCD_SLAACPRIVATE) {
+ unsigned int delay;
+
if (ia->dadcounter >= IDGEN_RETRIES) {
logerrx("%s: unable to obtain a"
" stable private address",
@@ -937,11 +938,8 @@ ipv6nd_dadcallback(void *arg)
p, ia->prefix_len);
else
ia->saddr[0] = '\0';
- tv.tv_sec = 0;
- tv.tv_nsec = (suseconds_t)
- arc4random_uniform(IDGEN_DELAY * NSEC_PER_SEC);
- timespecnorm(&tv);
- eloop_timeout_add_tv(ifp->ctx->eloop, &tv,
+ delay = arc4random_uniform(IDGEN_DELAY * MSEC_PER_SEC);
+ eloop_timeout_add_msec(ifp->ctx->eloop, delay,
ipv6nd_addaddr, ia);
return;
}
@@ -1907,7 +1905,7 @@ ipv6nd_startrs1(void *arg)
void
ipv6nd_startrs(struct interface *ifp)
{
- struct timespec tv;
+ unsigned int delay;
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
if (!(ifp->options->options & DHCPCD_INITIAL_DELAY)) {
@@ -1915,12 +1913,9 @@ ipv6nd_startrs(struct interface *ifp)
return;
}
- tv.tv_sec = 0;
- tv.tv_nsec = (suseconds_t)arc4random_uniform(
- MAX_RTR_SOLICITATION_DELAY * NSEC_PER_SEC);
- timespecnorm(&tv);
+ delay = arc4random_uniform(MAX_RTR_SOLICITATION_DELAY * MSEC_PER_SEC);
logdebugx("%s: delaying IPv6 router solicitation for %0.1f seconds",
- ifp->name, timespec_to_double(&tv));
- eloop_timeout_add_tv(ifp->ctx->eloop, &tv, ipv6nd_startrs1, ifp);
+ ifp->name, (float)delay / MSEC_PER_SEC);
+ eloop_timeout_add_msec(ifp->ctx->eloop, delay, ipv6nd_startrs1, ifp);
return;
}