src/usr.bin/netstat/if.c was modified back in late November 1995, to
expand the "Network" field from 11 characters to 13:

| Revision 12459 - (view) (annotate) - [select for diffs]
| Modified Wed Nov 22 22:21:04 1995 UTC (14 years, 8 months ago) by se
| File length: 11619 byte(s)
| Diff to previous 11819
| 
| Increase width of Network column from 11 to 13 for the AF_INET case.
| This seems to have been missed, when the recent IPX changes went in ...

While I appreciate the thought & effort, it should be readily apparent
that even 13 characters is insufficient to represent even an IPv4
address in dotted quad format (in the general case), let alone a network
specification in CIDR format:

        192.168.127.126/29

is 15 characters for the IPv4 address part itself, plus another 3 for
the mask, totalling 18.

I just checked NetBSD sources
(<http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/netstat/if.c?rev=1.69&content-type=text/x-cvsweb-markup&only_with_tag=MAIN>),
and it appears that they (also) use "%-13.13s" as the format
specification for Network.

(OpenBSD appears to use "%-11.11s", thus limiting the output to 11
characters.)

OpenSolaris, per
<http://cr.opensolaris.org/~meem/clearview-ipmp-cr2/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c.html>
apparently uses "%-14s" as the format specification -- which avoids the
(potentail) truncation issue entirely.


I realize that the information in question is avaiklable in other ways,
but limiting the size of the "Network" field of netstat(1) to 13
characters yields some rather ... odd ... results -- e.g.:

d254(7.3-S)[23] netstat -nif inet
Name    Mtu Network       Address              Ipkts Ierrs    Opkts Oerrs  Coll
xl0    1500 192.168.7.0/2 192.168.7.254        95210     -    90017     -     -
lo0   16384 127.0.0.0/8   127.0.0.1              195     -      195     -     -
d254(7.3-S)[24] 

As evidence that the xl0 NIX is, in fact, not on a /2, I submit:

d254(7.3-S)[24] netstat -nrf inet
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.7.1        UGS         0    61386    xl0
127.0.0.1          127.0.0.1          UH          0      195    lo0
192.168.7.0/24     link#1             UC          0        0    xl0
192.168.7.1        00:1a:a0:62:96:09  UHLW        2      286    xl0    431
d254(7.3-S)[25] ifconfig xl0
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=9<RXCSUM,VLAN_MTU>
        ether 00:08:74:e9:c9:41
        inet 192.168.7.254 netmask 0xffffff00 broadcast 192.168.7.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
d254(7.3-S)[26] 

I suppose the thing that's bugging me here is that "netstat -nif inet"
appears to be mis-stating the situation.  I believe it would be ideal if
it were to provide correct output, but failing that, I'm tempted to
suggest that  it might be better to be silent on the matter.

Of course, the general output of netstat(1) is fairly well entrenched in
history, and I don't advocate change for its own sake.

Anyone else think this is enough of a "problem" that it merits modifying
the code (e.g., in netstat/if.c) a bit?

Peace,
david
-- 
David H. Wolfskill                              da...@catwhisker.org
Depriving a girl or boy of an opportunity for education is evil.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.

Attachment: pgp56ZZvTpd8y.pgp
Description: PGP signature

Reply via email to