NetBSD Problem Report #22546

Received: (qmail 26824 invoked by uid 605); 19 Aug 2003 12:48:32 -0000
Message-Id: <20030819124736.69B74793@starfruit.itojun.org>
Date: Tue, 19 Aug 2003 21:47:36 +0900 (JST)
From: itojun@itojun.org
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: itojun@itojun.org
To: gnats-bugs@gnats.netbsd.org
Subject: "netstat -in -f inet" behavior is not in sync with document
X-Send-Pr-Version: 3.95

>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 +0000 2003
>Closed-Date:    
>Last-Modified:  Sun Jan 13 18:40:04 +0000 2013
>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:
From: Bug Hunting <bughunting@xs4all.nl>
To: NetBSD GNATS <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: bin/22546 ("netstat -in -f inet" behavior is not in sync with
 document)
Date: Sun, 13 Jan 2013 19:08:24 +0100

 Hi,

 (This PR has been open for almost a decade; the issue described in
 it, as well as the man page and code excerpts quoted in it, basically
 still apply / are present though.  It by the way seems that the
 PR's originator wrote about code committed by himself, in this PR
 (see src/usr.bin/netstat/main.c, r1.25); above that, please note
 who the originator is, and take that into account before replying
 (e.g., don't ask for originator feedback) -- thanks.)

 I don't have a solution (patch) for the PR available here, but
 _can_ provide some, hopefully helpful, comments.

 First off, it looks as if the PR's originator overlooked the ``(with
 the -s option)'' part from the man page's excerpt; this probably
 doesn't (fully) cancel out the issue described in the PR, but note
 that (at least?) the output from the specific command
 "netstat -is -f inet6" _does_ differ from that of
 "netstat -i -f inet6", i.e., the same command without the `-s'
 flag.

 Secondly, `-f' does not necessarily need to be specified _after_
 `-i' for the latter to get ignored, which is described like that
 specifically in the PR (and shown in its example): for `-i' to get
 ignored, `-f' may be specified _anywhere_ on the command line (in
 other words: don't let the wording confuse you here).

 Lastly, `-n' does not need to be given for `-i' to get ignored, as
 described in the PR (and shown in its examples); it was given there,
 but isn't needed for the issue described to occur.

 Can someone pick this PR up?

 Thanks,

 Bug Hunting

From: Bug Hunting <bughunting@xs4all.nl>
To: NetBSD GNATS <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: bin/22546 ("netstat -in -f inet" behavior is not in sync with
 document)
Date: Sun, 13 Jan 2013 19:38:12 +0100

 Hi,

 On Sun, Jan 13, 2013 at 07:08:24PM +0100, Bug Hunting wrote:
 > I don't have a solution (patch) for the PR available here, but
 > _can_ provide some, hopefully helpful, comments.

 To summarize the issue and to state it more simple: `-i' gets
 ignored when `-f' is used.

 This _may_ only be the case though when `-s' is not also given, as
 stated in the man page as should be done (which I also described
 in my previous reply); in that is case the man page _is_ correct,
 and there may not be an issue to begin with, after all (in which
 case this PR can simply be closed).

 Thanks,

 Bug Hunting

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.