From owner-svn-src-stable-10@FreeBSD.ORG Thu Oct 9 23:14:03 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 85A986BE; Thu, 9 Oct 2014 23:14:03 +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 64B99B5B; Thu, 9 Oct 2014 23:14:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s99NE3i0070193; Thu, 9 Oct 2014 23:14:03 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s99NE2ex070188; Thu, 9 Oct 2014 23:14:02 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201410092314.s99NE2ex070188@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 9 Oct 2014 23:14:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r272852 - stable/10/sbin/route X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Oct 2014 23:14:03 -0000 Author: hrs Date: Thu Oct 9 23:14:02 2014 New Revision: 272852 URL: https://svnweb.freebsd.org/changeset/base/272852 Log: MFC r256695: - Add relative specification in expiration time. - Add proto3 option for RTF_PROTO3. - Use %lu for members of struct rt_metrics. Modified: stable/10/sbin/route/keywords stable/10/sbin/route/route.8 stable/10/sbin/route/route.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/route/keywords ============================================================================== --- stable/10/sbin/route/keywords Thu Oct 9 23:11:36 2014 (r272851) +++ stable/10/sbin/route/keywords Thu Oct 9 23:14:02 2014 (r272852) @@ -41,6 +41,7 @@ osi prefixlen proto1 proto2 +proto3 proxy recvpipe reject Modified: stable/10/sbin/route/route.8 ============================================================================== --- stable/10/sbin/route/route.8 Thu Oct 9 23:11:36 2014 (r272851) +++ stable/10/sbin/route/route.8 Thu Oct 9 23:14:02 2014 (r272852) @@ -318,6 +318,7 @@ by indicating the following correspondin -blackhole RTF_BLACKHOLE - silently discard pkts (during updates) -proto1 RTF_PROTO1 - set protocol specific routing flag #1 -proto2 RTF_PROTO2 - set protocol specific routing flag #2 +-proto3 RTF_PROTO3 - set protocol specific routing flag #3 .Ed .Pp The optional modifiers @@ -341,6 +342,17 @@ specify that all ensuing metrics may be .Fl lockrest meta-modifier. .Pp +Note that +.Fl expire +accepts expiration time of the route as the number of seconds since the +Epoch +.Pq see Xr time 3 . +When the first character of the number is +.Dq + +or +.Dq - , +it is interpreted as a value relative to the current time. +.Pp The optional modifier .Fl fib Ar number specifies that the command will be applied to a non-default FIB. Modified: stable/10/sbin/route/route.c ============================================================================== --- stable/10/sbin/route/route.c Thu Oct 9 23:11:36 2014 (r272851) +++ stable/10/sbin/route/route.c Thu Oct 9 23:14:02 2014 (r272852) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -741,6 +742,7 @@ static void set_metric(char *value, int key) { int flag = 0; + char *endptr; u_long noval, *valp = &noval; switch (key) { @@ -760,7 +762,18 @@ set_metric(char *value, int key) rt_metrics.rmx_locks |= flag; if (locking) locking = 0; - *valp = atoi(value); + errno = 0; + *valp = strtol(value, &endptr, 0); + if (errno == 0 && *endptr != '\0') + errno = EINVAL; + if (errno) + err(EX_USAGE, "%s", value); + if (flag & RTV_EXPIRE && (value[0] == '+' || value[0] == '-')) { + struct timespec ts; + + clock_gettime(CLOCK_REALTIME_FAST, &ts); + *valp += ts.tv_sec; + } } #define F_ISHOST 0x01 @@ -847,6 +860,9 @@ newroute(int argc, char **argv) case K_PROTO2: flags |= RTF_PROTO2; break; + case K_PROTO3: + flags |= RTF_PROTO3; + break; case K_PROXY: nrflags |= F_PROXY; break; @@ -1701,6 +1717,7 @@ static void print_getmsg(struct rt_msghdr *rtm, int msglen, int fib) { struct sockaddr *sp[RTAX_MAX]; + struct timespec ts; char *cp; int i; @@ -1753,15 +1770,17 @@ print_getmsg(struct rt_msghdr *rtm, int #define msec(u) (((u) + 500) / 1000) /* usec to msec */ printf("\n%9s %9s %9s %9s %9s %10s %9s\n", "recvpipe", "sendpipe", "ssthresh", "rtt,msec", "mtu ", "weight", "expire"); - printf("%8ld%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); - printf("%8ld%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); - printf("%8ld%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); - if (rtm->rtm_rmx.rmx_expire) - rtm->rtm_rmx.rmx_expire -= time(0); - printf("%8ld%c\n", rtm->rtm_rmx.rmx_expire, lock(EXPIRE)); + printf("%8lu%c ", rtm->rtm_rmx.rmx_recvpipe, lock(RPIPE)); + printf("%8lu%c ", rtm->rtm_rmx.rmx_sendpipe, lock(SPIPE)); + printf("%8lu%c ", rtm->rtm_rmx.rmx_ssthresh, lock(SSTHRESH)); + printf("%8lu%c ", msec(rtm->rtm_rmx.rmx_rtt), lock(RTT)); + printf("%8lu%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); + printf("%8lu%c ", rtm->rtm_rmx.rmx_weight, lock(WEIGHT)); + if (rtm->rtm_rmx.rmx_expire > 0) + clock_gettime(CLOCK_REALTIME_FAST, &ts); + else + ts.tv_sec = 0; + printf("%8ld%c\n", rtm->rtm_rmx.rmx_expire - ts.tv_sec, lock(EXPIRE)); #undef lock #undef msec #define RTA_IGN (RTA_DST|RTA_GATEWAY|RTA_NETMASK|RTA_IFP|RTA_IFA|RTA_BRD)