summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/af_inet6.c
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2014-07-07 15:31:46 +0000
committerume <ume@FreeBSD.org>2014-07-07 15:31:46 +0000
commit46755924b63c76ea80bf4c8384806cae1942624c (patch)
tree4f6f68a83b0dae24503712478d927c9ed164c377 /sbin/ifconfig/af_inet6.c
parent74b8e10dc8320877d77c972a0f9a432c58388311 (diff)
downloadFreeBSD-src-46755924b63c76ea80bf4c8384806cae1942624c.zip
FreeBSD-src-46755924b63c76ea80bf4c8384806cae1942624c.tar.gz
MFC r268049:
Fix ifconfig to show pltime and vltime with -L option, again after usage change from time_second to time_uptime. PR: 188520 Submitted by: Guy Yur <guyyur__at__gmail.com>
Diffstat (limited to 'sbin/ifconfig/af_inet6.c')
-rw-r--r--sbin/ifconfig/af_inet6.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index b4db0f1..d2e65e4 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
@@ -98,20 +99,21 @@ static void
setip6lifetime(const char *cmd, const char *val, int s,
const struct afswtch *afp)
{
- time_t newval, t;
+ struct timespec now;
+ time_t newval;
char *ep;
- t = time(NULL);
+ clock_gettime(CLOCK_MONOTONIC_FAST, &now);
newval = (time_t)strtoul(val, &ep, 0);
if (val == ep)
errx(1, "invalid %s", cmd);
if (afp->af_af != AF_INET6)
errx(1, "%s not allowed for the AF", cmd);
if (strcmp(cmd, "vltime") == 0) {
- in6_addreq.ifra_lifetime.ia6t_expire = t + newval;
+ in6_addreq.ifra_lifetime.ia6t_expire = now.tv_sec + newval;
in6_addreq.ifra_lifetime.ia6t_vltime = newval;
} else if (strcmp(cmd, "pltime") == 0) {
- in6_addreq.ifra_lifetime.ia6t_preferred = t + newval;
+ in6_addreq.ifra_lifetime.ia6t_preferred = now.tv_sec + newval;
in6_addreq.ifra_lifetime.ia6t_pltime = newval;
}
}
@@ -172,9 +174,11 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
int s6;
u_int32_t flags6;
struct in6_addrlifetime lifetime;
- time_t t = time(NULL);
+ struct timespec now;
int error;
+ clock_gettime(CLOCK_MONOTONIC_FAST, &now);
+
memset(&null_sin, 0, sizeof(null_sin));
sin = (struct sockaddr_in6 *)ifa->ifa_addr;
@@ -258,15 +262,15 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) {
printf("pltime ");
if (lifetime.ia6t_preferred) {
- printf("%s ", lifetime.ia6t_preferred < t
- ? "0" : sec2str(lifetime.ia6t_preferred - t));
+ printf("%s ", lifetime.ia6t_preferred < now.tv_sec
+ ? "0" : sec2str(lifetime.ia6t_preferred - now.tv_sec));
} else
printf("infty ");
printf("vltime ");
if (lifetime.ia6t_expire) {
- printf("%s ", lifetime.ia6t_expire < t
- ? "0" : sec2str(lifetime.ia6t_expire - t));
+ printf("%s ", lifetime.ia6t_expire < now.tv_sec
+ ? "0" : sec2str(lifetime.ia6t_expire - now.tv_sec));
} else
printf("infty ");
}
OpenPOWER on IntegriCloud