From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 22 14:12:53 2004 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 7B1D616A4CE for ; Sun, 22 Aug 2004 14:12:53 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EFBC43D39; Sun, 22 Aug 2004 14:12:53 +0000 (GMT) (envelope-from bmilekic@FreeBSD.org) Received: from freefall.freebsd.org (bmilekic@localhost [127.0.0.1]) i7MECr2U050541; Sun, 22 Aug 2004 14:12:53 GMT (envelope-from bmilekic@freefall.freebsd.org) Received: (from bmilekic@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i7MECrgn050540; Sun, 22 Aug 2004 14:12:53 GMT (envelope-from bmilekic) Date: Sun, 22 Aug 2004 14:12:53 +0000 From: Bosko Milekic To: Paolo Pisati , FreeBSD_Hackers Message-ID: <20040822141253.GA50325@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: Re: Playing with mbuf in userland 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: Sun, 22 Aug 2004 14:12:53 -0000 I wrote: Another option to look into would be to implement a sysctl(8)-exported handler that iterates over the mbuf chain and prints out the mbuf chains in something like XML, which your userland application can then more or less easily parse, and reproduce the chain ("fake it up") in userland. This solution is rather attractive because you can do all sorts of things with the intermediate-parsing-language right from the kernel, as well as from userland (at the parsing stages). To see an example of a sysctl(8) handler, refer to src/sys/vm/uma_core.c (the bottom) in FreeBSD 5.x. I should also add: you should have various sysctl OIDs that call this handler passing, say, the mbuf chain as an argument (a reference to the top mbuf). This way certain OIDs can send out a snapshot of an mbuf chain at a particular point in the stack, and others can send snapshots from the socket buffer and driver entry-points (you can get some perception of how the chain changes as it makes its way up-and-down the layers). -Bosko