From owner-freebsd-bugs@freebsd.org Sat Mar 19 20:56:36 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B367AD5C12 for ; Sat, 19 Mar 2016 20:56:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5BC13F62 for ; Sat, 19 Mar 2016 20:56:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u2JKuZBi079140 for ; Sat, 19 Mar 2016 20:56:36 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 161986] [patch] netstat(1): Interface auto-width in "netstat -rn" Date: Sat, 19 Mar 2016 20:56:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: yaroslav.shvets@gmail.com X-Bugzilla-Status: In Progress X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Mar 2016 20:56:36 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D161986 Yaroslav Shvets changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yaroslav.shvets@gmail.com --- Comment #4 from Yaroslav Shvets --- I prefer to rename interfaces for convenient operation in ipfw by masks: # ipfw add allow ... in via if_wan* # ipfw add deny ... out via if_vpn* etc I also observe the effect of trimming interface names after the renaming on= es: # ifconfig lagg0.17 name if_wan_kav_bgp $ netstat -i | head -2 Name Mtu Network Address Ipkts Ierrs Idrop Opkts O= errs Coll if_wa 1500 00:0c:29:6a:c0:7f 119703 0 0 88432 = 1027 0 ^^^^^ if_wa instead if_wan_kav_bgp $ netstat -iW | head -2 Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll if_wan_ 1500 00:0c:29:6a:c0:7f 119713 0 0 88440= =20 1027 0 ^^^^^^^ if_wan_ instead if_wan_kav_bgp $ netstat -r | head -5 | tail -2 Destination Gateway Flags Netif Expire default gw-kav UGS if_wan_k ^^^^^^^^ if_wan_k instead if_wan_kav_bgp $ netstat -rW | head -5 | tail -2 Destination Gateway Flags Use Mtu Netif Exp= ire default gw-kav-bgp UGS 762465 1500 if_wan_kav ^^^^^^^^^^ if_wan_kav instead if_wan_kav_bgp The problem of trimmed interface names in the output of netstat is to use uncorrectly hardcoded length interface names. There are two patches that use IFNAMSIZ from instead of fixed values. $ cd /usr/src/usr.bin/netstat $ cat patch-if.c --- if.c.orig 2016-03-19 15:05:31.758234000 +0200 +++ if.c 2016-03-19 21:10:58.987339000 +0200 @@ -240,9 +240,9 @@ if (!pfunc) { if (Wflag) - printf("%-7.7s", "Name"); + printf("%-*.*s", IFNAMSIZ-1, IFNAMSIZ-1, "Name"); else - printf("%-5.5s", "Name"); + printf("%-*.*s", IFNAMSIZ-1, IFNAMSIZ-1, "Name"); printf(" %5.5s %-13.13s %-17.17s %8.8s %5.5s %5.5s", "Mtu", "Network", "Address", "Ipkts", "Ierrs", "Idrop"); if (bflag) @@ -282,9 +282,9 @@ continue; if (Wflag) - printf("%-7.7s", ifa->ifa_name); + printf("%-*.*s", IFNAMSIZ-1, IFNAMSIZ-1, ifa->ifa_name); else - printf("%-5.5s", ifa->ifa_name); + printf("%-*.*s", IFNAMSIZ-1, IFNAMSIZ-1, ifa->ifa_name); #define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu) show_stat("lu", 6, IFA_MTU(ifa), IFA_MTU(ifa)); $ cat patch-route.c --- route.c.orig 2016-03-19 15:05:31.783407000 +0200 +++ route.c 2016-03-19 21:09:28.400830000 +0200 @@ -238,13 +238,13 @@ #ifndef INET6 #define WID_DST_DEFAULT(af) 18 /* width of destination col= umn */ #define WID_GW_DEFAULT(af) 18 /* width of gateway column = */ -#define WID_IF_DEFAULT(af) (Wflag ? 10 : 8) /* width of netif column */ +#define WID_IF_DEFAULT(af) IFNAMSIZ-1 /* width of netif column */ #else #define WID_DST_DEFAULT(af) \ ((af) =3D=3D AF_INET6 ? (numeric_addr ? 33: 18) : 18) #define WID_GW_DEFAULT(af) \ ((af) =3D=3D AF_INET6 ? (numeric_addr ? 29 : 18) : 18) -#define WID_IF_DEFAULT(af) ((af) =3D=3D AF_INET6 ? 8 : (Wflag = ? 10 : 8)) +#define WID_IF_DEFAULT(af) ((af) =3D=3D AF_INET6 ? 8 : IFNAMSI= Z-1) #endif /*INET6*/ static int wid_dst; --=20 You are receiving this mail because: You are the assignee for the bug.=