summaryrefslogtreecommitdiffstats
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authorroam <roam@FreeBSD.org>2004-08-25 16:36:17 +0000
committerroam <roam@FreeBSD.org>2004-08-25 16:36:17 +0000
commit47b3e1d3042baf9e39e847f7c40472f5640a1dd4 (patch)
treeacbbe7beb5f6a37a9ee4395562d3d9f6ca87db56 /usr.bin/sockstat
parent17cdeacd68484d9612c250ef9e82250180cbd458 (diff)
downloadFreeBSD-src-47b3e1d3042baf9e39e847f7c40472f5640a1dd4.zip
FreeBSD-src-47b3e1d3042baf9e39e847f7c40472f5640a1dd4.tar.gz
Do not display bogus entries for sockets in the TIME_WAIT or similar
states that no longer have a corresponding file descriptor - until now, sockstat would mostly randomly match null kern.file.*.xf_data fields with the first mostly-closed socket. This bugfix is a RELENG_5 candidate. Approved by: andre
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r--usr.bin/sockstat/sockstat.117
-rw-r--r--usr.bin/sockstat/sockstat.c2
2 files changed, 18 insertions, 1 deletions
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
index c6f008c..9136420 100644
--- a/usr.bin/sockstat/sockstat.1
+++ b/usr.bin/sockstat/sockstat.1
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 7, 2001
+.Dd August 25, 2004
.Dt SOCKSTAT 1
.Os
.Sh NAME
@@ -121,6 +121,21 @@ if the endpoint could not be determined.
The address the foreign end of the socket is bound to (see
.Xr getpeername 2 ) .
.El
+.Pp
+Note that TCP sockets in the
+.Dv AF_INET
+or
+.Dv AF_INET6
+domains that are not in one of the
+.Dv LISTEN ,
+.Dv SYN_SENT ,
+or
+.Dv ESTABLISHED
+states may not be shown by
+.Nm ;
+use
+.Xr netstat 1
+to examine them instead.
.Sh SEE ALSO
.Xr fstat 1 ,
.Xr netstat 1 ,
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index eaeb242..acb9182 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -494,6 +494,8 @@ display(void)
"LOCAL ADDRESS", "FOREIGN ADDRESS");
setpassent(1);
for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) {
+ if (xf->xf_data == NULL)
+ continue;
hash = (int)((uintptr_t)xf->xf_data % HASHSIZE);
for (s = sockhash[hash]; s != NULL; s = s->next)
if ((void *)s->socket == xf->xf_data)
OpenPOWER on IntegriCloud