From owner-svn-src-all@FreeBSD.ORG Mon Jun 30 16:39:38 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06615C37; Mon, 30 Jun 2014 16:39:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CDB5B2A77; Mon, 30 Jun 2014 16:39:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5UGdbew089216; Mon, 30 Jun 2014 16:39:37 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5UGdb84089215; Mon, 30 Jun 2014 16:39:37 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <201406301639.s5UGdb84089215@svn.freebsd.org> From: Hajimu UMEMOTO Date: Mon, 30 Jun 2014 16:39:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268049 - head/sbin/ifconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jun 2014 16:39:38 -0000 Author: ume Date: Mon Jun 30 16:39:37 2014 New Revision: 268049 URL: http://svnweb.freebsd.org/changeset/base/268049 Log: 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 MFC after: 1 week Modified: head/sbin/ifconfig/af_inet6.c Modified: head/sbin/ifconfig/af_inet6.c ============================================================================== --- head/sbin/ifconfig/af_inet6.c Mon Jun 30 16:32:49 2014 (r268048) +++ head/sbin/ifconfig/af_inet6.c Mon Jun 30 16:39:37 2014 (r268049) @@ -42,6 +42,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -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 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 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 "); }