From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 1 06:08:01 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A9DD737B401 for ; Tue, 1 Apr 2003 06:08:01 -0800 (PST) Received: from relay1.ntu-kpi.kiev.ua (oberon.ntu-kpi.kiev.ua [195.245.194.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0ACB243F93 for ; Tue, 1 Apr 2003 06:07:56 -0800 (PST) (envelope-from diman@pth.ntu-kpi.kiev.ua) Received: by relay1.ntu-kpi.kiev.ua (Postfix, from userid 426) id E009819B60; Tue, 1 Apr 2003 17:07:31 +0300 (EEST) Received: from mate.pth.ntu-kpi.kiev.ua (if100Mbit.pth.ntu-kpi.kiev.ua [10.100.5.180]) by relay1.ntu-kpi.kiev.ua (Postfix) with SMTP id 6F08D19B1E for ; Tue, 1 Apr 2003 17:07:18 +0300 (EEST) Received: (qmail 76966 invoked by uid 1015); 1 Apr 2003 14:07:07 -0000 Date: Tue, 1 Apr 2003 17:07:07 +0300 From: "Dmitry V.Galant" To: freebsd-hackers@freebsd.org Message-ID: <20030401140706.GA35382@pth.ntu-kpi.kiev.ua> References: <002301c2f831$d847b820$4206000a@stalker> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <002301c2f831$d847b820$4206000a@stalker> Subject: Re: mbuf question again X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Apr 2003 14:08:02 -0000 On Tue, Apr 01, 2003 at 11:34:03AM +0200, Stalker wrote: > > Hi > > I would like to know if it is possible to write a program to check which > mbuf's are allocated to which programs that are currently running, or is > this totally not possible? > > If it is possible, could someone point me in the right direction as in which > libraries / functions / reading material i would need to look at in order to > do so? It's not so easy. mbuf objects primary used to represent fragmented packet in the system or incapsulated packet as list of protocols headers and packet data. mbuf objects are allocated when NIC receive packet and transfer it from NIC's memory to main RAM. In that moment mbuf object is unqueued and referenced only by interface driver code so you cant find a system structure points to mbuf object. Packet incapsulated in mbuf object can be bridged out, fast-forwarded or queued for other processing. Network stack then dequeue it and pop it up until packet is added to process socket buffer sockbuf (see sys/socketvar.h) [*] At this moment you can map mbufs against running processes. But in the context of fixing network problems it can be total useless to view this mapping. Same process is on sending packets. Theoretically it's possible to write kernel module to print all allocated mbufs in the system but it's much easy just to coredump the kernel, save core and use gdb for browsing.