Subject: bin/1268: netstat -i truncates IP network adresses
To: None <gnats-bugs@gnats.netbsd.org>
From: Ignatios Souvatzis <is@beverly.rhein.de>
List: netbsd-bugs
Date: 07/25/1995 11:52:49
>Number: 1268
>Category: bin
>Synopsis: netstat -i truncates subnets
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 25 06:20:01 1995
>Last-Modified:
>Originator: Ignatios Souvatzis
>Organization:
private site
>Release: 950704, about.
>Environment:
System: NetBSD beverly 1.0A NetBSD 1.0A (BEVERLY) #117: Wed Jul 19 08:56:51 MET DST 1995 root@beverly:/usr/src/sys/arch/amiga/compile/BEVERLY amiga
>Description:
I always was annoyed by the stupid netstat -i which truncated
network addresses like 193.174.6.72 to 193.174.6.7. The supplied patch
corrects this behaviour. However, displaying dropped packets (with
additional -d flag) needs a display with more than 80 columns. This
could be corrected by fine-tuning the other field widths (e.g.,
the if name could be printed with 4 cols (bah0), the error counts could
be truncated by one, ...) I didn't bother to, since netstat -itd uses
more then 80 columns, anyway.
>How-To-Repeat:
netstat -i, when one of the interfaces has a netmask of, e.g.,
255.255.255.248.
>Fix:
Apply this patch to usr.bin/netstat/if.c:
--- if.c.orig Tue Jul 25 11:13:16 1995
+++ if.c Tue Jul 25 11:31:33 1995
@@ -92,7 +92,7 @@
}
if (kread(ifnetaddr, (char *)&ifnetaddr, sizeof ifnetaddr))
return;
- printf("%-5.5s %-5.5s %-11.11s %-15.15s %8.8s %5.5s %8.8s %5.5s",
+ printf("%-5.5s %-5.5s %-15.15s %-15.15s %8.8s %5.5s %8.8s %5.5s",
"Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs",
"Opkts", "Oerrs");
printf(" %5s", "Coll");
@@ -125,7 +125,7 @@
}
printf("%-5.5s %-5d ", name, ifnet.if_mtu);
if (ifaddraddr == 0) {
- printf("%-11.11s ", "none");
+ printf("%-15.15s ", "none");
printf("%-15.15s ", "none");
} else {
if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) {
@@ -137,7 +137,7 @@
CP(&ifaddr); sa = (struct sockaddr *)cp;
switch (sa->sa_family) {
case AF_UNSPEC:
- printf("%-11.11s ", "none");
+ printf("%-15.15s ", "none");
printf("%-15.15s ", "none");
break;
case AF_INET:
@@ -148,10 +148,10 @@
*/
in = inet_makeaddr(ifaddr.in.ia_subnet,
INADDR_ANY);
- printf("%-11.11s ", netname(in.s_addr,
+ printf("%-15.15s ", netname(in.s_addr,
ifaddr.in.ia_subnetmask));
#else
- printf("%-11.11s ",
+ printf("%-15.15s ",
netname(ifaddr.in.ia_subnet,
ifaddr.in.ia_subnetmask));
#endif
@@ -194,7 +194,7 @@
cp = (char *)LLADDR(sdl);
n = sdl->sdl_alen;
}
- m = printf("%-11.11s ", "<Link>");
+ m = printf("%-15.15s ", "<Link>");
goto hexprint;
default:
m = printf("(%d)", sa->sa_family);
@@ -206,7 +206,7 @@
while (--n >= 0)
m += printf("%x%c", *cp++ & 0xff,
n > 0 ? '.' : ' ');
- m = 28 - m;
+ m = 32 - m;
while (m-- > 0)
putchar(' ');
break;
>Audit-Trail:
>Unformatted:
Ignatios Souvatzis