From owner-freebsd-bugs@FreeBSD.ORG Sat Apr 12 15:50:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.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 B79F8EF2 for ; Sat, 12 Apr 2014 15:50:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (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 9097B13C9 for ; Sat, 12 Apr 2014 15:50:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3CFo00x005827 for ; Sat, 12 Apr 2014 15:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3CFo0gm005826; Sat, 12 Apr 2014 15:50:00 GMT (envelope-from gnats) Resent-Date: Sat, 12 Apr 2014 15:50:00 GMT Resent-Message-Id: <201404121550.s3CFo0gm005826@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Guy Yur 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 97D79D7C for ; Sat, 12 Apr 2014 15:44:21 +0000 (UTC) Received: from mail-ee0-x22d.google.com (mail-ee0-x22d.google.com [IPv6:2a00:1450:4013:c00::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 300FE1390 for ; Sat, 12 Apr 2014 15:44:21 +0000 (UTC) Received: by mail-ee0-f45.google.com with SMTP id d17so5100502eek.4 for ; Sat, 12 Apr 2014 08:44:19 -0700 (PDT) Received: from vm2.localdomain ([31.210.185.47]) by mx.google.com with ESMTPSA id 45sm26210947eeh.9.2014.04.12.08.44.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Apr 2014 08:44:18 -0700 (PDT) Received: by vm2.localdomain (sSMTP sendmail emulation); Sat, 12 Apr 2014 18:43:56 +0300 Message-Id: <53495f52.c5030e0a.4fc3.ffffbb4a@mx.google.com> Date: Sat, 12 Apr 2014 18:43:56 +0300 From: Guy Yur To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: bin/188520: [patch] ifconfig -L shows pltime and vltime as zero since 10.0-RELEASE X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Guy Yur List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Apr 2014 15:50:00 -0000 >Number: 188520 >Category: bin >Synopsis: [patch] ifconfig -L shows pltime and vltime as zero since 10.0-RELEASE >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 12 15:50:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Guy Yur >Release: FreeBSD 10.0-RELEASE-p1 i386 >Organization: >Environment: System: FreeBSD vm2.localdomain 10.0-RELEASE-p1 FreeBSD 10.0-RELEASE-p1 #0 r264267M: Sat Apr 12 10:28:56 IDT 2014 root@vm2.localdomain:/usr/obj/i386.i386/usr/src/sys/VIRTUALBOX i386 >Description: ifconfig -L shows pltime and vltime as zero. Seems that ifconfig was missed in r253970 which changed usage from time_second to time_uptime. ifconfig -L ... inet6 XXXX:XXXX:XXXX:XXXX:YYYY:YYYY:YYYY:YYYY prefixlen 64 autoconf temporary pltime 0 vltime 0 The prefix is learned via router advertisment. tcpdump shows non zero values in the icmp6 packet. A test program that calls SIOCGIFALIFETIME_IN6 shows the value is < wall clock which is the test done by ifconfig. time = 1397314436 ia6t_preferred = 608907 ia6t_expire = 2596107 >How-To-Repeat: Run "ifconfig -L" with global or ULA IPv6 addresses learned through router advertisment or define an IPv6 address with pltime and vltime: ifconfig IFNAME inet6 2001:DB8::1 pltime 100 vltime 100 ifconfig -L IFNAME inet6 >Fix: Attached patch to use clock_gettime(CLOCK_MONOTONIC_FAST) in ifconfig per r253970 comment. --- ifconfig_af_inet6_monotonic.patch begins here --- Index: sbin/ifconfig/af_inet6.c =================================================================== --- sbin/ifconfig/af_inet6.c (revision 264366) +++ sbin/ifconfig/af_inet6.c (working copy) @@ -42,6 +42,7 @@ static const char rcsid[] = #include #include #include +#include #include #include @@ -98,10 +99,11 @@ 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); @@ -108,10 +110,10 @@ setip6lifetime(const char *cmd, const char *val, i 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 *i 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 *i 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 "); } --- ifconfig_af_inet6_monotonic.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: