When should "netstat -i" truncate output?



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 david@xxxxxxxxxxxxxx
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: pgpxDf7gnIla8.pgp
Description: PGP signature



Relevant Pages

  • USA Network New Shows
    ... CHARACTERS WELCOME AS USA NETWORK ANNOUNCES DEVELOPMENT SLATE ... president, original programming, announced today an aggressive development ...
    (rec.sport.pro-wrestling)
  • Re: Intruder in my wireless network? / intrusion detection programs
    ... Password/phrase strength is defined in terms of entropy, ... The advantage of a passphrase of random real words is that it's ... characters to achieve the same level of entropy as a password of random ... James Bond and the NSA ARE NOT trying to hack your network. ...
    (alt.internet.wireless)
  • Re: Password Policy
    ... characters because there head would explode. ... :>> I have a network that I have to upgrade their password policy. ... :> What is bringing about the policy change? ... Management alone? ...
    (microsoft.public.security)
  • Re: Should Doctor Who have remained shelved?
    ... I like it because it wasn't network material. ... saw a silver one peice jump suit in a CB episode - try and see the forest ... I don't recall one dimensional characters being a problem in drwhos ... decals next to a "Nine Inch Nails" decal next to a unicorn decal... ...
    (rec.arts.drwho)
  • USA announces new shows, movies
    ... tropical resort, an unlucky dater with an assassin for a dad, and a ... The "Characters Welcome" cable network Tuesday announced three new ... produce action movies to complement the action of its wrestling ...
    (rec.arts.tv)