aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-Fay.ORG>2024-05-08 09:44:29 +0000
committerZhenlei Huang <zlei@FreeBSD.org>2024-10-10 10:00:48 +0000
commit3e46d65d56198760ad0a867a651dffb11fbd258d (patch)
treeb4350a2afa290c7a4a9f96aeb6dd1962743bf279
parentea980c17f48e9307504d7567d8f2b37dc3181588 (diff)
netstat: increase width of Netif column
The previous width of Netif (10 or 8) was too short for modern interface names; make it 12, which is long enough to display "epair0a.1000". This came up in practice with genet(4) interfaces, since the base interface name is long enough that with the previous limit, VLAN identifiers would be truncated at 1 character in the IPv6 output: "genet0.100" becomes "genet0.1". The width is now fixed, and doesn't depend on the address family, because there's no reason that length of the interface name would vary based on the AF. PR: 266474 Reviewed by: imp,zlei,Mina Galić Pull Request: https://github.com/freebsd/freebsd-src/pull/1223 (cherry picked from commit d33b87e8cf91a6bcb5eac0ecc0371c1041c61050) netstat: for -W, use IFNAMSIZ If -W is specified, use IFNAMSIZ as the width of the Netif column, instead of the default 12. (cherry picked from commit ae9c0ba8ef2f540f9030909cf07e3c59f876fd23) (cherry picked from commit 6b86b8f0f6b6bfd5d93e45c7f584ec5bffac2a62)
-rw-r--r--usr.bin/netstat/nhops.c5
-rw-r--r--usr.bin/netstat/route.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/usr.bin/netstat/nhops.c b/usr.bin/netstat/nhops.c
index 19a7a6891050..c4412bc68081 100644
--- a/usr.bin/netstat/nhops.c
+++ b/usr.bin/netstat/nhops.c
@@ -65,16 +65,15 @@
#include "common.h"
/* column widths; each followed by one space */
+#define WID_IF_DEFAULT (Wflag ? IFNAMSIZ : 12) /* width of netif column */
#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) (Wflag ? 10 : 8) /* 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 : (Wflag ? 10 : 8))
#endif /*INET6*/
static int wid_dst;
static int wid_gw;
@@ -416,7 +415,7 @@ print_nhops_sysctl(int fibnum, int af)
wid_flags = 6;
wid_pksent = 8;
wid_mtu = 6;
- wid_if = WID_IF_DEFAULT(fam);
+ wid_if = WID_IF_DEFAULT;
xo_open_instance("rt-family");
pr_family(fam);
xo_open_list("nh-entry");
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 5c737b28df78..0a0ddc52f61f 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -183,16 +183,15 @@ pr_family(int af1)
}
/* column widths; each followed by one space */
+#define WID_IF_DEFAULT (Wflag ? IFNAMSIZ : 12) /* width of netif column */
#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) (Wflag ? 10 : 8) /* 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 : (Wflag ? 10 : 8))
#endif /*INET6*/
static int wid_dst;
@@ -283,7 +282,7 @@ p_rtable_sysctl(int fibnum, int af)
wid_flags = 6;
wid_pksent = 8;
wid_mtu = 6;
- wid_if = WID_IF_DEFAULT(fam);
+ wid_if = WID_IF_DEFAULT;
wid_expire = 6;
xo_open_instance("rt-family");
pr_family(fam);