From nobody@FreeBSD.ORG Wed Jun 16 19:02:31 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 2E03314C2B; Wed, 16 Jun 1999 19:02:31 -0700 (PDT)
Message-Id: <19990617020231.2E03314C2B@hub.freebsd.org>
Date: Wed, 16 Jun 1999 19:02:31 -0700 (PDT)
From: jrd@cc.usu.edu
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: netstat fails to display TCP connectoins
X-Send-Pr-Version: www-1.0

>Number:         12252
>Category:       misc
>Synopsis:       netstat fails to display TCP connectoins
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 16 19:10:01 PDT 1999
>Closed-Date:    Tue Sep 21 10:07:35 PDT 1999
>Last-Modified:  Tue Sep 21 10:11:20 PDT 1999
>Originator:     Joe R. Doupnik
>Release:        v3.2
>Organization:
Utah State University
>Environment:
FreeBSD netlab6.usu.edu 3.2-RELEASE FreeBSD 3.2-RELEASE #17: Wed Jun 16 16:50:45
 MDT 1999     root@netlab6.usu.edu:/usr/src/sys/compile/JRD  i386

>Description:
netstat shows UDP and Unix but not TCP connections. The problem is
the TCP protocol value is not set in the xt_socket structure
passed back to netstat routines. See horrid workaround below (one
line). The value returned in the structure looks rather like an
address or left over un-inited garbage.
>How-To-Repeat:
Type netstat with TCP connections active
>Fix:
My dirty but quick fix, to netstat/inet.c:

        oxig = xig = (struct xinpgen *)buf;
        for (xig = (struct xinpgen *)((char *)xig + xig->xig_len);
             xig->xig_len > sizeof(struct xinpgen);
             xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
                if (istcp) {
                        tp = &((struct xtcpcb *)xig)->xt_tp;
                        inp = &((struct xtcpcb *)xig)->xt_inp;
                        so = &((struct xtcpcb *)xig)->xt_socket;
/* JRD */
so->xso_protocol = proto;       /* correct uninited value */
/* JRD */
                } else {
                        inp = &((struct xinpcb *)xig)->xi_inp;
                        so = &((struct xinpcb *)xig)->xi_socket;
                }

                /* Ignore sockets for protocols other than the desired one. */
                if (so->xso_protocol != proto)
                        continue;



>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@FreeBSD.ORG>
To: jrd@cc.usu.edu
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/12252: netstat fails to display TCP connectoins
Date: Mon, 20 Sep 1999 12:49:17 +0300

 On Wed, Jun 16, 1999 at 07:02:31PM -0700, jrd@cc.usu.edu wrote:
 > 
 > netstat shows UDP and Unix but not TCP connections. The problem is
 > the TCP protocol value is not set in the xt_socket structure
 > passed back to netstat routines. See horrid workaround below (one
 > line). The value returned in the structure looks rather like an
 > address or left over un-inited garbage.
 > 
 I can't reproduce your problem on neither 3.2-RELEASE nor 3.3-RELEASE.
 tcp_pcblist() sysctl correctly calls sotoxsocket(), which certainly
 fills in `xso_protocol' field.
 
 If the problem still exist, could you please provide some additional
 details, e.g. the output of `netstat -n -finet' while TCP sockets are
 in use?
 
 
 Thanks,
 -- 
 Ruslan Ermilov		Sysadmin and DBA of the
 ru@ucb.crimea.ua	United Commercial Bank,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.247.647	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Tue Sep 21 10:07:35 PDT 1999 
State-Changed-Why:  
Originator reports that the problem is fixed in 3.2-STABLE. 
>Unformatted:
