From 13c1bcf2c1d5fbdca99cdddec726f822b68dddbc Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 5 Aug 2013 20:13:02 +0000 Subject: - Use time_uptime instead of time_second in data structures for PF_INET6 in kernel. This fixes various malfunction when the wall time clock is changed. Bump __FreeBSD_version to 1000041. - Use clock_gettime(CLOCK_MONOTONIC_FAST) in userland utilities. MFC after: 1 month --- usr.sbin/rtadvctl/rtadvctl.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'usr.sbin/rtadvctl') diff --git a/usr.sbin/rtadvctl/rtadvctl.c b/usr.sbin/rtadvctl/rtadvctl.c index adc87b5..3f22518 100644 --- a/usr.sbin/rtadvctl/rtadvctl.c +++ b/usr.sbin/rtadvctl/rtadvctl.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "pathnames.h" @@ -416,6 +417,7 @@ action_show(int argc, char **argv) char argv_dnssl[IFNAMSIZ + sizeof(":dnssl=")]; char ssbuf[SSBUFLEN]; + struct timespec now, ts0, ts; struct ctrl_msg_pl cp; struct ifinfo *ifi; TAILQ_HEAD(, ifinfo) ifl = TAILQ_HEAD_INITIALIZER(ifl); @@ -464,6 +466,10 @@ action_show(int argc, char **argv) } } + clock_gettime(CLOCK_REALTIME_FAST, &now); + clock_gettime(CLOCK_MONOTONIC_FAST, &ts); + TS_SUB(&now, &ts, &ts0); + TAILQ_FOREACH(ifi, &ifl, ifi_next) { struct ifinfo *ifi_s; struct rtadvd_timer *rat; @@ -615,12 +621,20 @@ action_show(int argc, char **argv) rat = (struct rtadvd_timer *)cp.cp_val; } - printf("\tNext RA send: %s", - (rat == NULL) ? "never\n" : - ctime((time_t *)&rat->rat_tm.tv_sec)); - printf("\tLast RA sent: %s", - (ifi_s->ifi_ra_lastsent.tv_sec == 0) ? "never\n" : - ctime((time_t *)&ifi_s->ifi_ra_lastsent.tv_sec)); + printf("\tNext RA send: "); + if (rat == NULL) + printf("never\n"); + else { + ts.tv_sec = rat->rat_tm.tv_sec + ts0.tv_sec; + printf("%s", ctime(&ts.tv_sec)); + } + printf("\tLast RA send: "); + if (ifi_s->ifi_ra_lastsent.tv_sec == 0) + printf("never\n"); + else { + ts.tv_sec = ifi_s->ifi_ra_lastsent.tv_sec + ts0.tv_sec; + printf("%s", ctime(&ts.tv_sec)); + } if (rai->rai_clockskew) printf("\tClock skew: %" PRIu16 "sec\n", rai->rai_clockskew); @@ -747,9 +761,9 @@ action_show_prefix(struct prefix *pfx) { char ntopbuf[INET6_ADDRSTRLEN]; char ssbuf[SSBUFLEN]; - struct timeval now; + struct timespec now; - gettimeofday(&now, NULL); + clock_gettime(CLOCK_MONOTONIC_FAST, &now); printf("\t %s/%d", inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, sizeof(ntopbuf)), pfx->pfx_prefixlen); @@ -800,7 +814,7 @@ action_show_prefix(struct prefix *pfx) printf(""); if (pfx->pfx_timer) { - struct timeval *rest; + struct timespec *rest; rest = rtadvd_timer_rest(pfx->pfx_timer); if (rest) { /* XXX: what if not? */ -- cgit v1.1