Bug 25712

Summary: sockstat truncates field
Product: Base System Reporter: Poul-Henning Kamp <phk>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description Poul-Henning Kamp 2001-03-11 22:40:01 UTC
Portnumbers may get truncated, which can confuse the heck out of
people.

Example where "1141" gets truncated to "114"

femmer:/home/jail/nsx/etc/namedb# sockstat | grep 212.242.86.173
bind     named     1103    3 udp4   212.242.86.173:114    *:*                  
bind     named     1103   20 udp4   212.242.86.173:53     *:*                  
bind     named     1103   21 tcp4   212.242.86.173:53     *:*                  
root     ntpd       248   10 udp4   212.242.86.173:123    *:*                  

femmer:/home/jail/nsx/etc/namedb# netstat -an | grep 212.242.86.173
tcp4       0      0  212.242.86.173.53      *.*                    LISTEN
udp4       0      0  212.242.86.173.1141    *.*                    
udp4       0      0  212.242.86.173.53      *.*                    
udp4       0      0  212.242.86.173.123     *.*
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-03-13 01:34:25 UTC
Responsible Changed
From-To: freebsd-bugs->des

I wrote sockstat(1).
Comment 2 des 2001-03-13 01:38:54 UTC
Poul-Henning Kamp <phk@critter.freebsd.dk> writes:
> femmer:/home/jail/nsx/etc/namedb# netstat -an | grep 212.242.86.173
> tcp4       0      0  212.242.86.173.53      *.*                    LISTEN
> udp4       0      0  212.242.86.173.1141    *.*                    
> udp4       0      0  212.242.86.173.53      *.*                    
> udp4       0      0  212.242.86.173.123     *.*            

The problem is that sockstat(1) uses 'netstat -Aan', which truncates
port numbers to restrict the source and destination address to 19
characters each (15 for dotted quad + 1 for colon leave only 3 for
port number). Unfortunately, there's no way to join the information
from 'netstat -an' with that from 'netstat -Aan' (no common key), so
this will remain a problem until an option is added to netstat(1) to
*not* truncate even if this causes individual lines to exceed 80
characters.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 3 Poul-Henning Kamp 2001-03-13 10:57:28 UTC
In message <xzp3dcisb0x.fsf@flood.ping.uio.no>, Dag-Erling Smorgrav writes:
>Poul-Henning Kamp <phk@critter.freebsd.dk> writes:
>> femmer:/home/jail/nsx/etc/namedb# netstat -an | grep 212.242.86.173
>> tcp4       0      0  212.242.86.173.53      *.*                    LISTEN
>> udp4       0      0  212.242.86.173.1141    *.*                    
>> udp4       0      0  212.242.86.173.53      *.*                    
>> udp4       0      0  212.242.86.173.123     *.*            
>
>The problem is that sockstat(1) uses 'netstat -Aan', which truncates
>port numbers to restrict the source and destination address to 19
>characters each (15 for dotted quad + 1 for colon leave only 3 for
>port number). 

Well, then netstat -Aan should be fixed :-)

--
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-05-27 14:12:29 UTC
State Changed
From-To: open->closed

Fixed before 4.3-RELEASE.