Bug 266474 - Column truncated -- netstat routing table output
Summary: Column truncated -- netstat routing table output
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-18 01:33 UTC by pprocacci
Modified: 2024-10-10 10:07 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pprocacci 2022-09-18 01:33:06 UTC
The Netif column is truncated.
In my case, I have vlans that are 4 digits.  This output is cutting off the last digit.


root@nas:~ # ifconfig -g vlan
igb0.1004
igb0.1208
igb0.1616
igb0.1843


root@nas:~ # netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.255.161    UGS        igb0
127.0.0.1          link#3             UH          lo0
192.168.255.128/27 link#7             U      igb0.100
192.168.255.158    link#7             UHS         lo0
192.168.255.160/28 link#1             U          igb0
192.168.255.164    link#1             UHS         lo0
192.168.255.176/28 link#8             U      igb0.120
192.168.255.183    link#8             UHS         lo0
192.168.255.208/28 link#9             U      igb0.161
192.168.255.211    link#9             UHS         lo0
192.168.255.224/28 link#10            U      igb0.184
192.168.255.230    link#10            UHS         lo0
Comment 1 Zhenlei Huang freebsd_committer freebsd_triage 2024-09-30 15:17:17 UTC
You can try the option `-W` to avoid truncating. That should be sufficient for your case.

There's also an improvement https://github.com/freebsd/freebsd-src/pull/1223 but has not yet been MFCed to stable branches.
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-10-10 10:03:37 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e46d65d56198760ad0a867a651dffb11fbd258d

commit 3e46d65d56198760ad0a867a651dffb11fbd258d
Author:     Lexi Winter <lexi@le-Fay.ORG>
AuthorDate: 2024-05-08 09:44:29 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-10-10 10:00:48 +0000

    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)

 usr.bin/netstat/nhops.c | 5 ++---
 usr.bin/netstat/route.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)
Comment 3 Zhenlei Huang freebsd_committer freebsd_triage 2024-10-10 10:07:45 UTC
https://github.com/freebsd/freebsd-src/pull/1223 has ben MFCed into stable/14 and stable/13 branches. The width of column Netif is now 12. Should suffice. Closing now.