summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/if.c
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2003-11-28 17:34:23 +0000
committerbms <bms@FreeBSD.org>2003-11-28 17:34:23 +0000
commita36a8ab06d69627279afdd6cb31c3c2e69f77c5a (patch)
treeacb1266c1848f77931b3b7a3f020f52d0b76e1d3 /usr.bin/netstat/if.c
parentb39c505bb04eadb8ed1e0f8d48c84ef9b4154686 (diff)
downloadFreeBSD-src-a36a8ab06d69627279afdd6cb31c3c2e69f77c5a.zip
FreeBSD-src-a36a8ab06d69627279afdd6cb31c3c2e69f77c5a.tar.gz
Fix some minor nits in netstat whereby large interface names would be
truncated. In environments where many tunnel or vlan interfaces are created, interface names have high numbers which overflow the field width. PRs: bin/52349, bin/35838 Submitted by: Mike Tancsa, Scot W. Hetzel Approved by: re (rwatson)
Diffstat (limited to 'usr.bin/netstat/if.c')
-rw-r--r--usr.bin/netstat/if.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index b2527cd..49a08c7 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -188,8 +188,12 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
return;
if (!pfunc) {
- printf("%-5.5s %5.5s %-13.13s %-17.17s %8.8s %5.5s",
- "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs");
+ if (Wflag)
+ printf("%-7.7s", "Name");
+ else
+ printf("%-5.5s", "Name");
+ printf(" %5.5s %-13.13s %-17.17s %8.8s %5.5s",
+ "Mtu", "Network", "Address", "Ipkts", "Ierrs");
if (bflag)
printf(" %10.10s","Ibytes");
printf(" %8.8s %5.5s", "Opkts", "Oerrs");
@@ -251,7 +255,11 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
drops = ifnet.if_snd.ifq_drops;
if (ifaddraddr == 0) {
- printf("%-5.5s %5lu ", name, ifnet.if_mtu);
+ if (Wflag)
+ printf("%-7.7s", name);
+ else
+ printf("%-5.5s", name);
+ printf(" %5lu ", ifnet.if_mtu);
printf("%-13.13s ", "none");
printf("%-17.17s ", "none");
} else {
@@ -268,7 +276,11 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
(u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_link);
continue;
}
- printf("%-5.5s %5lu ", name, ifnet.if_mtu);
+ if (Wflag)
+ printf("%-7.7s", name);
+ else
+ printf("%-5.5s", name);
+ printf(" %5lu ", ifnet.if_mtu);
switch (sa->sa_family) {
case AF_UNSPEC:
printf("%-13.13s ", "none");
OpenPOWER on IntegriCloud