From owner-freebsd-net@FreeBSD.ORG Sun Mar 7 11:42:14 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5E79016A4CE; Sun, 7 Mar 2004 11:42:14 -0800 (PST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EA7143D31; Sun, 7 Mar 2004 11:42:14 -0800 (PST) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.10/8.12.10) with ESMTP id i27JeoxC002974; Sun, 7 Mar 2004 14:40:50 -0500 (EST) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i27Jeo2H002971; Sun, 7 Mar 2004 14:40:50 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Sun, 7 Mar 2004 14:40:50 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Kiss Tibor In-Reply-To: <20040307175453.GA44645@PSY.tvnetwork.hu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org cc: freebsd-hackers@freebsd.org Subject: Re: Strange problem with vnodes and sockets X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2004 19:42:14 -0000 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, > VFIFO, VBAD }; > > 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@fledge.watson.org Senior Research Scientist, McAfee Research