From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 24 13:01:20 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8B24F16A420; Fri, 24 Feb 2006 13:01:20 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 01EDD43D4C; Fri, 24 Feb 2006 13:01:18 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (aris.bedc.ondsl.gr [62.103.39.226]) (authenticated bits=128) by igloo.linux.gr (8.13.5/8.13.5/Debian-3) with ESMTP id k1OD0tUQ006426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 24 Feb 2006 15:00:58 +0200 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id k1OD0P1s002177; Fri, 24 Feb 2006 15:00:26 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id k1OD0OJq002176; Fri, 24 Feb 2006 15:00:24 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 24 Feb 2006 15:00:24 +0200 From: Giorgos Keramidas To: Nikos Vassiliadis Message-ID: <20060224130024.GA1800@flame.pc> References: <200602221550.17842.nvass@teledomenet.gr> <43FDED8A.90208@rcn.com> <20060223182412.GA33297@flame.pc> <200602241132.54728.nvass@teledomenet.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200602241132.54728.nvass@teledomenet.gr> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.373, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.83, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr Cc: freebsd-hackers@freebsd.org, Gary Corcoran , Eugene Grosbein Subject: Re: (feature change request) remove link-layer generated routes from netstat -r X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Feb 2006 13:01:20 -0000 On 2006-02-24 11:32, Nikos Vassiliadis wrote: >On Thursday 23 February 2006 20:24, Giorgos Keramidas wrote: >> >> ... about using a switch to shorten the netstat output (by not >> displaying the link-layer entries): >> >> How about making the new behavior non-default, i.e. toggled by a -s >> switch to the netstat -r command? >> >> % netstat -rs >> >> Then 's' can stand for 'short' output, and everyone can experiment with >> the new feature. Then, after a couple of minor releases, if we find >> that this is a feature that is very often used, we can make it the >> default. > > That would be a well balanced compromise. I can live with it. Unfortunately, the -s option is taken already. It enables the display of statistics. A possible alternative is the -c (compact) option, i.e. with a patch similar to the following: %%% Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/netstat/main.c,v retrieving revision 1.81 diff -u -r1.81 main.c --- main.c 28 Dec 2005 20:36:55 -0000 1.81 +++ main.c 24 Feb 2006 12:54:39 -0000 @@ -286,6 +286,7 @@ int aflag; /* show all sockets (including servers) */ int Bflag; /* show information about bpf consumers */ int bflag; /* show i/f total bytes in/out */ +int cflag; /* show compact output format */ int dflag; /* show i/f dropped packets */ int gflag; /* show group (multicast) routing or stats */ int hflag; /* show counters in human readable format */ @@ -316,7 +317,7 @@ af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:rSstuWw:z")) != -1) + while ((ch = getopt(argc, argv, "AaBbcdf:ghI:iLlM:mN:np:rSstuWw:z")) != -1) switch(ch) { case 'A': Aflag = 1; @@ -330,6 +331,9 @@ case 'b': bflag = 1; break; + case 'c': + cflag = 1; + break; case 'd': dflag = 1; break; Index: netstat.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/netstat/netstat.1,v retrieving revision 1.56 diff -u -r1.56 netstat.1 --- netstat.1 18 Dec 2005 19:38:43 -0000 1.56 +++ netstat.1 24 Feb 2006 12:59:34 -0000 @@ -32,7 +32,7 @@ .\" @(#)netstat.1 8.8 (Berkeley) 4/18/94 .\" $FreeBSD: src/usr.bin/netstat/netstat.1,v 1.56 2005/12/18 19:38:43 csjp Exp $ .\" -.Dd September 7, 2005 +.Dd February 24, 2006 .Dt NETSTAT 1 .Os .Sh NAME @@ -209,7 +209,7 @@ .Bk -words .Nm .Fl r -.Op Fl AanW +.Op Fl AacnW .Op Fl f Ar address_family .Op Fl M Ar core .Op Fl N Ar system @@ -231,6 +231,13 @@ .Dv RTF_PRCLONING parent route); normally these routes are not shown. +If +.Fl c +is also present, +hide routes that were generated by link-layer events (i.e. by ARP), +resulting in a more +.Dq compact +output format. When .Fl W is also present, Index: netstat.h =================================================================== RCS file: /home/ncvs/src/usr.bin/netstat/netstat.h,v retrieving revision 1.47 diff -u -r1.47 netstat.h --- netstat.h 28 Dec 2005 20:36:55 -0000 1.47 +++ netstat.h 24 Feb 2006 12:55:35 -0000 @@ -39,6 +39,7 @@ extern int Aflag; /* show addresses of protocol control block */ extern int aflag; /* show all sockets (including servers) */ extern int bflag; /* show i/f total bytes in/out */ +extern int cflag; /* show compact output format */ extern int dflag; /* show i/f dropped packets */ extern int gflag; /* show group (multicast) routing or stats */ extern int hflag; /* show counters in human readable format */ Index: route.c =================================================================== RCS file: /home/ncvs/src/usr.bin/netstat/route.c,v retrieving revision 1.76 diff -u -r1.76 route.c --- route.c 13 May 2005 16:31:10 -0000 1.76 +++ route.c 24 Feb 2006 12:54:29 -0000 @@ -720,6 +720,13 @@ return; } + /* + * Skip routes that were generated by link-layer (i.e. ARP) if we are + * in `compact output' mode. + */ + if (rt->rt_flags & RTF_LLINFO && cflag) + return; + bzero(&addr, sizeof(addr)); if ((sa = kgetsa(rt_key(rt)))) bcopy(sa, &addr, sa->sa_len); %%%