svn commit: r200779 - head/usr.bin/sockstat
Robert Watson
rwatson at FreeBSD.org
Mon Dec 21 17:55:14 UTC 2009
On Mon, 21 Dec 2009, Xin LI wrote:
> On Mon, Dec 21, 2009 at 9:23 AM, Dag-Erling Smorgrav <des at freebsd.org> wrote:
>> Author: des
>> Date: Mon Dec 21 17:23:04 2009
>> New Revision: 200779
>> URL: http://svn.freebsd.org/changeset/base/200779
>>
>> Log:
>> Note that sockstat(1) does not display kernel-owned sockets.
>
> Just curious - is this easily fixable? (Perhaps not since sockstat(1) does
> not use libkvm?)
Not really, and it's not 100% clear to me it's desirable to fix. sockstat,
fstat, and procstat work by walking the list of processes, and for each
process, then walking its file descriptor table. This means that a single
socket may not appear if it's not in use by any process (as with nlm, NFS
server, etc, where the sockets don't even have file descriptors), or it may
appear multiple times (if it's in use by more than one process -- think apache
listen sockets). To list sockets that have no process linkage, you'd need to
change its underlying model of operation, and right now we simply don't keep
global lists of sockets (because global lists are expensive and unnecessary).
I'm actually not sure I consider this a bug, so perhaps the comment should be
moved to the IMPLEMENTATION NOTES section. The point of these tools is to
generate lists by process. netstat works in a completely different way, by
walking the connection lists in the TCP/IP code, and therefore will list them,
since they have full socket state at that layer.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the svn-src-head
mailing list