diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2013-04-21 19:42:33 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2013-04-21 19:42:33 +0000 |
commit | da7671b7206f65f339eefd257ffe8e1e7af89d9f (patch) | |
tree | 9732ad18dde69d9b9d3f230aa538e82634e0a683 /usr.sbin/rtsold | |
parent | 8b8ff9fc26a00ed8dc894361ae6679ac0547fa1d (diff) |
IPv6 might still be around in 2038, replace magic timeval
{0x7fffffff, 0x7fffffff} with an explicit flag that timers should
be stopped.
input deraadt@, kettenis@
"Looks like a nice solution." deraadt@
OK benno@
Diffstat (limited to 'usr.sbin/rtsold')
-rw-r--r-- | usr.sbin/rtsold/dump.c | 5 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.c | 27 | ||||
-rw-r--r-- | usr.sbin/rtsold/rtsold.h | 4 |
3 files changed, 19 insertions, 17 deletions
diff --git a/usr.sbin/rtsold/dump.c b/usr.sbin/rtsold/dump.c index 3b641d2d39a..6d670fb552a 100644 --- a/usr.sbin/rtsold/dump.c +++ b/usr.sbin/rtsold/dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.c,v 1.13 2013/04/17 00:13:40 deraadt Exp $ */ +/* $OpenBSD: dump.c,v 1.14 2013/04/21 19:42:32 florian Exp $ */ /* $KAME: dump.c,v 1.10 2002/05/31 10:10:03 itojun Exp $ */ /* @@ -83,8 +83,7 @@ dump_interface_status(void) ifinfo->mediareqok ? "available" : "unavailable"); fprintf(fp, " probes: %d, dadcount = %d\n", ifinfo->probes, ifinfo->dadcount); - if (ifinfo->timer.tv_sec == tm_max.tv_sec && - ifinfo->timer.tv_usec == tm_max.tv_usec) + if (ifinfo->stoptimer) fprintf(fp, " no timer\n"); else { fprintf(fp, " timer: interval=%lld:%ld, expire=%s\n", diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index c88f8c61f20..f4eb3221f64 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsold.c,v 1.48 2013/04/19 05:06:52 deraadt Exp $ */ +/* $OpenBSD: rtsold.c,v 1.49 2013/04/21 19:42:32 florian Exp $ */ /* $KAME: rtsold.c,v 1.75 2004/01/03 00:00:07 itojun Exp $ */ /* @@ -57,7 +57,6 @@ #include "rtsold.h" struct ifinfo *iflist; -struct timeval tm_max = {0x7fffffff, 0x7fffffff}; static int log_upto = 999; static int fflag = 0; static int Fflag = 0; /* force setting sysctl parameters */ @@ -457,14 +456,14 @@ rtsol_check_timer(void) static struct timeval returnval; struct timeval now, rtsol_timer; struct ifinfo *ifinfo; - int flags; + int flags, timers; gettimeofday(&now, NULL); - rtsol_timer = tm_max; + timers = 0; for (ifinfo = iflist; ifinfo; ifinfo = ifinfo->next) { - if (timercmp(&ifinfo->expire, &now, <=)) { + if (!ifinfo->stoptimer && timercmp(&ifinfo->expire, &now, <=)) { if (dflag > 1) warnmsg(LOG_DEBUG, __func__, "timer expiration on %s, " @@ -539,12 +538,16 @@ rtsol_check_timer(void) } rtsol_timer_update(ifinfo); } - - if (timercmp(&ifinfo->expire, &rtsol_timer, <)) - rtsol_timer = ifinfo->expire; + if (!ifinfo->stoptimer) { + if (timers == 0) + rtsol_timer = ifinfo->expire; + else if (timercmp(&ifinfo->expire, &rtsol_timer, <)) + rtsol_timer = ifinfo->expire; + timers++; + } } - if (timercmp(&rtsol_timer, &tm_max, ==)) { + if (timers == 0) { warnmsg(LOG_DEBUG, __func__, "there is no timer"); return(NULL); } else if (timercmp(&rtsol_timer, &now, <)) @@ -569,6 +572,7 @@ rtsol_timer_update(struct ifinfo *ifinfo) struct timeval now; bzero(&ifinfo->timer, sizeof(ifinfo->timer)); + ifinfo->stoptimer = 0; switch (ifinfo->state) { case IFS_DOWN: @@ -584,7 +588,7 @@ rtsol_timer_update(struct ifinfo *ifinfo) /* XXX should be configurable */ ifinfo->timer.tv_sec = 3; } else - ifinfo->timer = tm_max; /* stop timer(valid?) */ + ifinfo->stoptimer = 1; break; case IFS_DELAY: interval = arc4random_uniform(MAX_RTR_SOLICITATION_DELAY * @@ -614,8 +618,7 @@ rtsol_timer_update(struct ifinfo *ifinfo) } /* reset the timer */ - if (timercmp(&ifinfo->timer, &tm_max, ==)) { - ifinfo->expire = tm_max; + if (ifinfo->stoptimer) { warnmsg(LOG_DEBUG, __func__, "stop timer for %s", ifinfo->ifname); } else { diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h index 4dc3d829188..4e20edf03a3 100644 --- a/usr.sbin/rtsold/rtsold.h +++ b/usr.sbin/rtsold/rtsold.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsold.h,v 1.14 2011/03/23 00:59:49 bluhm Exp $ */ +/* $OpenBSD: rtsold.h,v 1.15 2013/04/21 19:42:32 florian Exp $ */ /* $KAME: rtsold.h,v 1.14 2002/05/31 10:10:03 itojun Exp $ */ /* @@ -47,6 +47,7 @@ struct ifinfo { int dadcount; struct timeval timer; struct timeval expire; + int stoptimer; int errors; /* # of errors we've got - detect wedge */ int racnt; /* total # of valid RAs it have got */ @@ -63,7 +64,6 @@ struct ifinfo { #define IFS_TENTATIVE 4 /* rtsold.c */ -extern struct timeval tm_max; extern int dflag; extern char *otherconf_script; struct ifinfo *find_ifinfo(int ifindex); |