From: Alexander Bluhm Subject: netstat nits and options To: tech@openbsd.org Date: Thu, 16 Jul 2026 12:53:02 +0200 Hi, Claudio tricked me to have a closer look at the netstat man page. Fix some nits and options. - Use NULL for pointer. - The if_errs->count() has the additinal space indent in other places. - Add -v to usage where long IPv6 addresses are not truncated. - Only IPv6 multicast routes used -l for not truncating. Use -v for that features everywhere. It is documented in general at -v, remove the long explanation at -l. - I don't understand "(interfaces statically configured into a system but not located at boot-time are not shown)". Just delete the sentence. - Option -w wait picks the first egress interface. Document it, otherwise the sentence and behavior is confusing. ok? bluhm Index: usr.bin/netstat/if.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/if.c,v diff -u -p -r1.82 if.c --- usr.bin/netstat/if.c 16 Jul 2026 08:16:36 -0000 1.82 +++ usr.bin/netstat/if.c 16 Jul 2026 09:00:42 -0000 @@ -147,7 +147,7 @@ intpr(int interval, int repeatcount) else if (sdl->sdl_nlen > 0) memcpy(name, sdl->sdl_data, sdl->sdl_nlen); - if (interface != 0 && strcmp(name, interface) != 0) + if (interface != NULL && strcmp(name, interface) != 0) continue; /* mark inactive interfaces with a '*' */ @@ -167,10 +167,10 @@ intpr(int interval, int repeatcount) total = ifd->ifi_ipackets + if_errs->count(ifd->ifi_ierrors, - ifd->ifi_iqdrops) + + ifd->ifi_iqdrops) + ifd->ifi_opackets + if_errs->count(ifd->ifi_oerrors, - ifd->ifi_oqdrops) + + ifd->ifi_oqdrops) + ifd->ifi_collisions; } if (total == 0) @@ -183,7 +183,7 @@ intpr(int interval, int repeatcount) case RTM_NEWADDR: if (qflag && total == 0) continue; - if (interface != 0 && strcmp(name, interface) != 0) + if (interface != NULL && strcmp(name, interface) != 0) continue; ifam = (struct ifa_msghdr *)next; Index: usr.bin/netstat/main.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/main.c,v diff -u -p -r1.125 main.c --- usr.bin/netstat/main.c 21 Jun 2025 22:08:44 -0000 1.125 +++ usr.bin/netstat/main.c 16 Jul 2026 08:57:10 -0000 @@ -476,15 +476,17 @@ static void usage(void) { (void)fprintf(stderr, - "usage: netstat [-AaBln] [-M core] [-N system] [-p protocol] [-T rtable]\n" + "usage: netstat [-AaBlnv] [-M core] [-N system] [-p protocol] " + "[-T rtable]\n" " netstat -W interface\n" " netstat -m\n" - " netstat -I interface | -i [-bdehnq]\n" + " netstat -I interface | -i [-bdehnqv]\n" " netstat -w wait [-bdehnq] [-c count] [-I interface]\n" " netstat -s [-gru] [-f address_family] [-p protocol]\n" - " netstat -g [-lnu] [-f address_family]\n" + " netstat -g [-nuv] [-f address_family]\n" " netstat -R\n" - " netstat -r [-AFu] [-f address_family] [-M core] [-N system] [-T rtable]\n" + " netstat -r [-AFuv] [-f address_family] [-M core] " + "[-N system] [-T rtable]\n" " netstat -P pcbaddr [-v] [-M core] [-N system]\n"); exit(1); } Index: usr.bin/netstat/mroute6.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/mroute6.c,v diff -u -p -r1.28 mroute6.c --- usr.bin/netstat/mroute6.c 24 Jun 2026 12:33:49 -0000 1.28 +++ usr.bin/netstat/mroute6.c 16 Jul 2026 08:56:49 -0000 @@ -79,8 +79,8 @@ #include #include "netstat.h" -#define WID_ORG (lflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */ -#define WID_GRP (lflag ? 18 : (nflag ? 16 : 18)) /* width of group column */ +#define WID_ORG (vflag ? 39 : (nflag ? 29 : 18)) /* width of origin column */ +#define WID_GRP (vflag ? 18 : (nflag ? 16 : 18)) /* width of group column */ void mroute6pr(void) Index: usr.bin/netstat/netstat.1 =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/netstat/netstat.1,v diff -u -p -r1.99 netstat.1 --- usr.bin/netstat/netstat.1 16 Jul 2026 08:16:36 -0000 1.99 +++ usr.bin/netstat/netstat.1 16 Jul 2026 09:03:45 -0000 @@ -38,7 +38,7 @@ .Nd show network status .Sh SYNOPSIS .Nm -.Op Fl AaBln +.Op Fl AaBlnv .Op Fl M Ar core .Op Fl N Ar system .Op Fl p Ar protocol @@ -49,7 +49,7 @@ .Fl m .Nm .Fl I Ar interface | Fl i -.Op Fl bdehnq +.Op Fl bdehnqv .Nm .Fl w Ar wait .Op Fl bdehnq @@ -62,13 +62,13 @@ .Op Fl p Ar protocol .Nm .Fl g -.Op Fl lnu +.Op Fl nuv .Op Fl f Ar address_family .Nm .Fl R .Nm .Fl r -.Op Fl AFu +.Op Fl AFuv .Op Fl f Ar address_family .Op Fl M Ar core .Op Fl N Ar system @@ -200,22 +200,13 @@ With the .Fl g option, display multicast interface counter. .It Fl i -Show the state of interfaces which have been auto-configured -(interfaces statically configured into a system but not -located at boot-time are not shown). +Show the state of interfaces which have been auto-configured. With the .Fl g option, display multicast interface counter. .It Fl l With the default display, show only listening sockets. -With the -.Fl g -option, display wider fields for the IPv6 multicast routing table -.Qq Origin -and -.Qq Group -columns. .It Fl M Ar core Extract values associated with the name list from the specified core instead of the running kernel. @@ -380,9 +371,9 @@ interval argument, it displays a running network interfaces (an obsolescent version of this option used a numeric parameter with no option, and is currently supported for backward compatibility). -The display consists of a column for the primary interface (the first -interface found during autoconfiguration) and a column summarizing -information for all interfaces. +The display consists of a column for the primary interface (the +first egress interface found during auto-configuration) and a column +summarizing information for all interfaces. The primary interface may be replaced with another interface with the .Fl I option.