Subject: netstat -r output vs. "ARP table" entries
To: None <tech-net@netbsd.org>
From: Ignatios Souvatzis <is@jocelyn.rhein.de>
List: tech-net
Date: 09/09/1999 21:33:11
--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii

Hi,

as you will know, with the 4.4BSD changes to the ARP table, namely
incorporating it in the general routing table, netstat -r started to 
show the ARP entries, too. (I guess that it also will show Neighbour Cache
entries for IPv6...)

On big Ethernet segments, this can be nasty if you forget to |less or 
|grep -v UHL.

I looked at the code, and found that a relatively small patch (see below)
will allow to switch to the <= 4.3 behaviour by adding the -L flag. Works
fine for me. Any objections?

Regards,
	Ignatios


--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=netstat-patch

Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/netstat/main.c,v
retrieving revision 1.23
diff -u -r1.23 main.c
--- main.c	1999/07/01 18:40:36	1.23
+++ main.c	1999/09/09 19:28:21
@@ -304,7 +304,8 @@
 	af = AF_UNSPEC;
 	pcbaddr = 0;
 
-	while ((ch = getopt(argc, argv, "Aabdf:ghI:liM:mN:nP:p:rstuvw:")) != -1)
+	while ((ch = getopt(argc, argv, "Aabdf:ghI:LliM:mN:nP:p:rstuvw:"))
+		!= -1)
 		switch(ch) {
 		case 'A':
 			Aflag = 1;
@@ -347,6 +348,9 @@
 			break;
 		case 'i':
 			iflag = 1;
+			break;
+		case 'L':
+			Lflag = 1;
 			break;
 		case 'l':
 			lflag = 1;
Index: netstat.h
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/netstat/netstat.h,v
retrieving revision 1.14
diff -u -r1.14 netstat.h
--- netstat.h	1999/07/01 18:40:36	1.14
+++ netstat.h	1999/09/09 19:28:22
@@ -45,6 +45,7 @@
 int	gflag;		/* show group (multicast) routing or stats */
 #endif
 int	iflag;		/* show interfaces */
+int	Lflag;		/* don't show LLINFO entries */
 int	lflag;		/* show routing table with use and ref */
 int	mflag;		/* show memory stats */
 int	nflag;		/* show addresses numerically */
Index: route.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/netstat/route.c,v
retrieving revision 1.38
diff -u -r1.38 route.c
--- route.c	1999/07/01 18:40:36	1.38
+++ route.c	1999/09/09 19:28:23
@@ -368,6 +368,8 @@
 	static int old_af;
 	int af = 0, interesting = RTF_UP | RTF_GATEWAY | RTF_HOST;
 
+	if (Lflag && (rtm->rtm_flags & RTF_LLINFO))
+		return;
 #ifdef notdef
 	/* for the moment, netmasks are skipped over */
 	if (!banner_printed) {
@@ -558,6 +560,9 @@
 	static struct ifnet ifnet, *lastif;
 	union sockaddr_union addr_un, mask_un;
 	struct sockaddr *addr, *mask;
+
+	if (Lflag && (rt->rt_flags & RTF_LLINFO))
+		return;
 
 	memset(&addr_un, 0, sizeof(addr_un));
 	memset(&mask_un, 0, sizeof(mask_un));

--8t9RHnE3ZwKMSgU+--