Subject: Re: netstat -i in /etc/daily
To: Alexis Rosen <alexis@panix.com>
From: None <itojun@iijlab.net>
List: tech-userlevel
Date: 01/24/2000 19:42:36
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <10669.948710472.1@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

>> 	for IPv6 we already have -v (avoid truncation, with unaligned columns).
>> 	i think it okay to reuse it.
>I don't run IPv6 yet so I have no real opinion on this but I suspect a lot
>of poeple will dislike reusing a flag.

	It makes much more sense to me to use the same flag, for similar
	functionality on top of different AFs.

>> 	we may be able to expand "Network" column to occupy 18 letters,
>> 	instead of 13 letters, to avoid IPv4 address/prefix truncation.
>> 	we need to remove some of stat items on the righthand side, to do this.
>Again, doesn't bother me, but some people are likely going to be very
>unhappy. Actually, maybe it does bother me- sometimes I need those numbers.

	I believe there's no solution that can make everyone happy.

	My proposal is
	- leave the default behavior as is (since some may depend on it)
	- and when -v is supplied, don't truncate columns to certain length.
	  (don't merge 3rd and 4th columns, just don't truncate)
	I believe this is good enough, and comes with very little surprise.
	A patch that does my proposal, and the sample output (with -in and
	with -inv) is attached.  Try it if you have time.

itojun


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <10669.948710472.2@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

Index: if.c
===================================================================
RCS file: /cvsroot/kame/kame/netbsd/usr.bin/netstat/if.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- if.c	2000/01/17 18:19:07	1.9
+++ if.c	2000/01/24 07:38:25	1.10
@@ -205,13 +205,20 @@
 				printf("%-13.13s ", netname(in.s_addr,
 				    ifaddr.in.ia_subnetmask));
 #else
-				printf("%-13.13s ",
-				    netname(ifaddr.in.ia_subnet,
-				    ifaddr.in.ia_subnetmask));
+				cp = netname(ifaddr.in.ia_subnet,
+				    ifaddr.in.ia_subnetmask);
+				if (vflag)
+					n = strlen(cp) < 13 ? 13 : strlen(cp);
+				else
+					n = 13;
+				printf("%-*.*s ", n, n, cp);
 #endif
-				printf("%-17.17s ",
-				    routename(sin->sin_addr.s_addr));
-
+				cp = routename(sin->sin_addr.s_addr);
+				if (vflag)
+					n = strlen(cp) < 17 ? 17 : strlen(cp);
+				else
+					n = 17;
+				printf("%-*.*s ", n, n, cp);
 				if (aflag) {
 					u_long multiaddr;
 					struct in_multi inm;

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <10669.948710472.3@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

Name  Mtu   Network       Address              Ipkts Ierrs    Opkts Oerrs Colls
sm1   1500  <Link>        00:00:86:05:80:fa   198430     1   188308     0   491
sm1   1500  fe80:1::/64   fe80:1::200:86ff:   198430     1   188308     0   491
sm1   1500  2001:218:420: 2001:218:420:0:20   198430     1   188308     0   491
sm1   1500  3ffe:8020:10f 3ffe:8020:10ff:1:   198430     1   188308     0   491
sm1   1500  3ffe:507:1:1: 3ffe:507:1:1:200:   198430     1   188308     0   491
sm1   1500  3ffe:501:410: 3ffe:501:410:0:20   198430     1   188308     0   491
sm1   1500  3ffe:507:0:1: 3ffe:507:0:1:200:   198430     1   188308     0   491
sm1   1500  202.232.15.96 202.232.15.108      198430     1   188308     0   491
lo0   32976 <Link>                              6613     0     6613     0     0
lo0   32976 fe80:2::/64   fe80:2::1             6613     0     6613     0     0
lo0   32976 ::1/128       ::1                   6613     0     6613     0     0
lo0   32976 127           127.0.0.1             6613     0     6613     0     0
lo1*  32976 <Link>                                 0     0        0     0     0
ppp0* 1500  <Link>                               674     0      775     0     0
ppp1* 1500  <Link>                                 0     0        0     0     0
sl0*  296   <Link>                                 0     0        0     0     0
sl1*  296   <Link>                                 0     0        0     0     0
strip 1100  <Link>                                 0     0        0     0     0
strip 1100  <Link>                                 0     0        0     0     0
tun0* 1500  <Link>                                 0     0        0     0     0
tun1* 1500  <Link>                                 0     0        0     0     0
gre0* 1450  <Link>                                 0     0        0     0     0
gre1* 1450  <Link>                                 0     0        0     0     0
ipip0 0     <Link>                                 0     0        0     0     0
ipip1 0     <Link>                                 0     0        0     0     0
gif0* 1280  <Link>                                 0     0        0     0     0
gif1* 1280  <Link>                                 0     0        0     0     0
gif2* 1280  <Link>                                 0     0        0     0     0
gif3* 1280  <Link>                                 0     0        0     0     0
dummy 16384 <Link>                                 0     0        0     0     0
faith 1500  <Link>                                 0     0        0     0     0
eon0  1500  <Link>                                 0     0        0     0     0

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <10669.948710472.4@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

Name  Mtu   Network       Address              Ipkts Ierrs    Opkts Oerrs Colls
sm1   1500  <Link>        00:00:86:05:80:fa   198693     1   188605     0   491
sm1   1500  fe80:1::/64   fe80:1::200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  2001:218:420::/64 2001:218:420:0:200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  3ffe:8020:10ff:1::/64 3ffe:8020:10ff:1:200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  3ffe:507:1:1::/64 3ffe:507:1:1:200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  3ffe:501:410::/64 3ffe:501:410:0:200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  3ffe:507:0:1::/64 3ffe:507:0:1:200:86ff:fe05:80fa   198693     1   188605     0   491
sm1   1500  202.232.15.96/28 202.232.15.108      198693     1   188605     0   491
lo0   32976 <Link>                              6619     0     6619     0     0
lo0   32976 fe80:2::/64   fe80:2::1             6619     0     6619     0     0
lo0   32976 ::1/128       ::1                   6619     0     6619     0     0
lo0   32976 127           127.0.0.1             6619     0     6619     0     0
lo1*  32976 <Link>                                 0     0        0     0     0
ppp0* 1500  <Link>                               674     0      775     0     0
ppp1* 1500  <Link>                                 0     0        0     0     0
sl0*  296   <Link>                                 0     0        0     0     0
sl1*  296   <Link>                                 0     0        0     0     0
strip 1100  <Link>                                 0     0        0     0     0
strip 1100  <Link>                                 0     0        0     0     0
tun0* 1500  <Link>                                 0     0        0     0     0
tun1* 1500  <Link>                                 0     0        0     0     0
gre0* 1450  <Link>                                 0     0        0     0     0
gre1* 1450  <Link>                                 0     0        0     0     0
ipip0 0     <Link>                                 0     0        0     0     0
ipip1 0     <Link>                                 0     0        0     0     0
gif0* 1280  <Link>                                 0     0        0     0     0
gif1* 1280  <Link>                                 0     0        0     0     0
gif2* 1280  <Link>                                 0     0        0     0     0
gif3* 1280  <Link>                                 0     0        0     0     0
dummy 16384 <Link>                                 0     0        0     0     0
faith 1500  <Link>                                 0     0        0     0     0
eon0  1500  <Link>                                 0     0        0     0     0

------- =_aaaaaaaaaa0--