From owner-freebsd-stable@FreeBSD.ORG Tue Jan 26 12:42:20 2010 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A86D106566C for ; Tue, 26 Jan 2010 12:42:20 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from mail.vega.ru (mail.vega.ru [90.156.167.5]) by mx1.freebsd.org (Postfix) with ESMTP id CCB3F8FC1C for ; Tue, 26 Jan 2010 12:42:19 +0000 (UTC) Received: from [10.100.124.99] (helo=edoofus.dev.vega.ru) by mail.vega.ru with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.71 (FreeBSD)) (envelope-from ) id 1NZkkM-0008R2-3F; Tue, 26 Jan 2010 15:42:18 +0300 Date: Tue, 26 Jan 2010 15:41:54 +0300 From: Ruslan Ermilov To: Nick Rogers Message-ID: <20100126124154.GA72180@edoofus.dev.vega.ru> References: <147432021001251901u7d56f014n83e834061fd09fec@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <147432021001251901u7d56f014n83e834061fd09fec@mail.gmail.com> Cc: stable@freebsd.org Subject: Re: netstat output changes in 8.0? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 12:42:20 -0000 On Mon, Jan 25, 2010 at 07:01:46PM -0800, Nick Rogers wrote: > Before 8.0-RELEASE, if I ran netstat -rn, it listed a separate route for > each host on the network, along with its MAC address. For example ... > > 172.20.172.17 00:02:b3:2f:64:6a UHLW 1 105712 1500 > vlan172 595 > 172.20.172.20 00:1e:c9:bb:7c:a9 UHLW 1 1002 1500 > vlan172 598 > 172.20.172.22 00:14:5e:16:bb:b6 UHLW 1 107 1500 > vlan172 491 > > This behavior seems to have changed in 8.0, where now only the > locally-assigned IP addresses and related CIDRs are displayed. >From src/UPDATING: : 20081214: : __FreeBSD_version 800059 incorporates the new arp-v2 rewrite. : RTF_CLONING, RTF_LLINFO and RTF_WASCLONED flags are eliminated. : The new code reduced struct rtentry{} by 16 bytes on 32-bit : architecture and 40 bytes on 64-bit architecture. The userland : applications "arp" and "ndp" have been updated accordingly. : The output from "netstat -r" shows only routing entries and : none of the L2 information. > Is there any way to get this behavior back, perhaps with a new flag that I > am not able to find? Or some sysctl? I have a script that was relying on > each host's "expire" flag in the routing table to determine when the MAC > address first appeared on the network according to ARP. If you need to know when a particular ARP entry expires, a variation of the following patch can be used, perhaps hiding this output by the -v (verbose) option. %%% Index: arp.c =================================================================== --- arp.c (revision 203016) +++ arp.c (working copy) @@ -101,7 +101,8 @@ static int nflag; /* no reverse dns lookups */ static char *rifname; -static int expire_time, flags, doing_proxy, proxy_only; +static time_t expire_time; +static int flags, doing_proxy, proxy_only; /* which function we're supposed to do */ #define F_GET 1 @@ -594,6 +595,15 @@ printf(" on %s", ifname); if (rtm->rtm_rmx.rmx_expire == 0) printf(" permanent"); + else { + static struct timeval tv; + if (tv.tv_sec == 0) + gettimeofday(&tv, 0); + if ((expire_time = rtm->rtm_rmx.rmx_expire - tv.tv_sec) > 0) + printf(" expires %d", (int)expire_time); + else + printf(" expired"); + } if (addr->sin_other & SIN_PROXY) printf(" published (proxy only)"); if (rtm->rtm_flags & RTF_ANNOUNCE) %%% Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer