Strange problem with vnodes and sockets

Robert Watson rwatson at
Sun Mar 7 11:42:14 PST 2004

On Sun, 7 Mar 2004, Kiss Tibor wrote:

> I want to create a small kernel module which logs the socket operations.
> So in my module I have a socket structure, and i want to know which
> process (thread) owns that. I try to solve this problem by this way: 

Sockets, as with files, can be referenced by more than one process at a
time.  While there is only one process that has created any given socket,
references to the socket can be inherited by processes forked from it, as
well as passed using UNIX domain sockets.  As such, there really isn't a
notion of "owner".  so_cred is a cached referenced to the process
credential of the process that created the socket...

> So how can the v_type 2048? v_type is an enum (vnode.h) with 10
> "options":  enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK,
> And the real problem is: why don't find that code any VSOCK type vnode
> in the active process list? And how can i find the proc struct for a
> socket? :) 

VSOCK vnodes are rendezvous points for UNIX domain socket communication,
not the actual communication vehicles themselves.  Very few UNIX domain
sockets are used in normal operation, but you might take a look at
/var/run/log, and the file descriptors that referenced various sockets to
the log subsystem.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at      Senior Research Scientist, McAfee Research

More information about the freebsd-net mailing list