diff options
author | bms <bms@FreeBSD.org> | 2003-11-28 17:34:23 +0000 |
---|---|---|
committer | bms <bms@FreeBSD.org> | 2003-11-28 17:34:23 +0000 |
commit | a36a8ab06d69627279afdd6cb31c3c2e69f77c5a (patch) | |
tree | acb1266c1848f77931b3b7a3f020f52d0b76e1d3 /usr.bin | |
parent | b39c505bb04eadb8ed1e0f8d48c84ef9b4154686 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | usr.bin/netstat/if.c | 20 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 8 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 4 |
3 files changed, 25 insertions, 7 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"); diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index f8e2788..3071ad4 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -119,6 +119,9 @@ is also present, show the number of dropped packets. If .Fl t is also present, show the contents of watchdog timers. +If +.Fl W +is also present, print interface names using a wider field size. .It Xo .Bk -words .Nm @@ -215,7 +218,10 @@ When .Fl W is also present, show the path MTU -for each route. +for each route, +and print interface +names with a wider +field size. .It Xo .Bk -words .Nm diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 3dcd910..d1d8bae 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -225,13 +225,13 @@ pr_family(int af1) #ifndef INET6 #define WID_DST_DEFAULT(af) 18 /* width of destination column */ #define WID_GW_DEFAULT(af) 18 /* width of gateway column */ -#define WID_IF_DEFAULT(af) 6 /* width of netif column */ +#define WID_IF_DEFAULT(af) (Wflag ? 8 : 6) /* width of netif column */ #else #define WID_DST_DEFAULT(af) \ ((af) == AF_INET6 ? (numeric_addr ? 33: 18) : 18) #define WID_GW_DEFAULT(af) \ ((af) == AF_INET6 ? (numeric_addr ? 29 : 18) : 18) -#define WID_IF_DEFAULT(af) ((af) == AF_INET6 ? 8 : 6) +#define WID_IF_DEFAULT(af) ((af) == AF_INET6 ? 8 : (Wflag ? 8 : 6)) #endif /*INET6*/ static int wid_dst; |