Subject: bin/22546: "netstat -in -f inet" behavior is not in sync with document
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 08/19/2003 21:47:36
>Number: 22546
>Category: bin
>Synopsis: "netstat -in -f inet" behavior is not in sync with document
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 19 12:49:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Jun-ichiro itojun Hagino
>Release: NetBSD 1.6W
>Organization:
itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.6W NetBSD 1.6W (STARFRUIT) #269: Mon Aug 18 13:20:50 JST 2003 itojun@starfruit.itojun.org:/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
netstat(1) says:
-i Show the state of interfaces which have been auto-configured (in-
terfaces statically configured into a system, but not located at
boot time are not shown). If the -a options is also present, mul-
ticast addresses currently in use are shown for each Ethernet in-
terface and for each IP interface address. Multicast addresses are
shown on separate lines following the interface address with which
they are associated. If the -f address_family option (with the -s
option) or the -p protocol option is present, show per-interface
statistics on all interfaces for the specified address_family or
protocol, respectively.
so i expect "netstat -in -f inet" to print interface information for
IPv4 addresses, like below:
% netstat -in
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Colls
wi0 1500 172.16/16 172.16.18.246 345097 409 117005 47 2499
lo0 33196 127/8 127.0.0.1 13571 0 13571 0 0
however, it does not happen. once we specify -f after -i, -i gets
ignored and netstat(1) behaves like "netstat -n -f inet".
>How-To-Repeat:
% netstat -in
Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Colls
wi0 1500 <Link> 00:20:e0:8d:3a:8c 345097 409 117005 47 2499
wi0 1500 fe80::/64 fe80::220:e0ff:fe 345097 409 117005 47 2499
wi0 1500 172.16/16 172.16.18.246 345097 409 117005 47 2499
fxp0 1500 <Link> 00:d0:59:ca:65:04 16941 0 9039 0 0
fxp0 1500 fe80::/64 fe80::2d0:59ff:fe 16941 0 9039 0 0
lo0 33196 <Link> 13571 0 13571 0 0
lo0 33196 127/8 127.0.0.1 13571 0 13571 0 0
lo0 33196 ::1/128 ::1 13571 0 13571 0 0
lo0 33196 fe80::/64 fe80::1 13571 0 13571 0 0
ppp0* 1500 <Link> 0 0 0 0 0
ppp1* 1500 <Link> 0 0 0 0 0
sl0* 296 <Link> 0 0 0 0 0
sl1* 296 <Link> 0 0 0 0 0
strip 1100 <Link> 0 0 0 0 0
strip 1100 <Link> 0 0 0 0 0
pflog 33196 <Link> 0 0 0 0 0
pfsyn 1896 <Link> 0 0 0 0 0
fw0* 1500 <Link> 00:06:1b:00:20:02 0 0 0 0 0
% netstat -in -f inet (the behavior is unexpected)
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 172.16.18.246.53 *.* LISTEN
tcp 0 0 172.16.18.246.64716 219.101.47.130.22 ESTABLISHED
tcp 0 0 127.0.0.1.5680 127.0.0.1.64903 ESTABLISHED
tcp 0 0 127.0.0.1.64903 127.0.0.1.5680 ESTABLISHED
tcp 0 0 127.0.0.1.25 *.* LISTEN
tcp 0 0 127.0.0.1.53 *.* LISTEN
udp 0 0 172.16.18.246.53 *.*
udp 0 0 127.0.0.1.53 *.*
% netstat -n -f inet (looks like -i is ignored)
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 172.16.18.246.53 *.* LISTEN
tcp 0 0 172.16.18.246.64716 219.101.47.130.22 ESTABLISHED
tcp 0 0 127.0.0.1.5680 127.0.0.1.64903 ESTABLISHED
tcp 0 0 127.0.0.1.64903 127.0.0.1.5680 ESTABLISHED
tcp 0 0 127.0.0.1.25 *.* LISTEN
tcp 0 0 127.0.0.1.53 *.* LISTEN
udp 0 0 172.16.18.246.53 *.*
udp 0 0 127.0.0.1.53 *.*
>Fix:
reconsider the following goto statement in netstat/main.c:main().
if (iflag) {
if (af != AF_UNSPEC)
goto protostat;
intpr(interval, nl[N_IFNET].n_value, NULL);
exit(0);
}
>Release-Note:
>Audit-Trail:
>Unformatted: