From owner-freebsd-net@FreeBSD.ORG Thu Jul 21 18:07:16 2005 Return-Path: X-Original-To: freebsd-net@freebsd.org 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 2386616A434 for ; Thu, 21 Jul 2005 18:07:16 +0000 (GMT) (envelope-from anders@cs.ucla.edu) Received: from smtp110.sbc.mail.mud.yahoo.com (smtp110.sbc.mail.mud.yahoo.com [68.142.198.209]) by mx1.FreeBSD.org (Postfix) with SMTP id D046343D60 for ; Thu, 21 Jul 2005 18:06:58 +0000 (GMT) (envelope-from anders@cs.ucla.edu) Received: (qmail 98783 invoked from network); 21 Jul 2005 18:06:58 -0000 Received: from unknown (HELO ?10.0.1.3?) (apeiris@sbcglobal.net@69.108.126.145 with plain) by smtp110.sbc.mail.mud.yahoo.com with SMTP; 21 Jul 2005 18:06:58 -0000 Mime-Version: 1.0 (Apple Message framework v733) Content-Transfer-Encoding: 7bit Message-Id: <91885646-8E16-4D06-91D7-307DD5836475@cs.ucla.edu> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: freebsd-net@freebsd.org From: Anders Persson Date: Thu, 21 Jul 2005 11:06:56 -0700 X-Mailer: Apple Mail (2.733) Subject: interface cleanup X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2005 18:07:16 -0000 Hi all, My name is Anders Persson and I am working on a Google SoC project in which I am trying to remove reference made from user land to kernel- only data structures. Currently I am going through netstat and rewriting some of the functions to rely on sysctl rather than kvm. The hope is to completely remove kvm from netstat, and parts that solely depend on it, like the core dump analysis would be factored out and moved to a more suitable place (kgdb?) In many cases this works quite well, and the public interfaces contain most of the information needed. In some cases certain pieces of information are not available. A specific example would be routing information, where I try to rely on routing messages to obtain the info. However, one piece of information that is missing is the ref count (rt_refcnt in rtentry). If this is one piece of information deemed necessary, what is the general opinion of including that in rt_msghdr? (Just a side note, I noticed there is both rtm_use and rtm_rmx.rmx_pksent in rt_msghdr, however when dumping an rtentry, the pksent metric of the entry is assigned to rtm_use and rmx_pksent is left unassigned, I assume this is done to avoid breaking legacy code?) The parts of netstat I am currently looking at are multicast routing info and netgraph. For both of these parts there seem to be no public interfaces to query for information. However, mrouting in IPv4 provide access to the internal structures which partially avoids using kvm (in one case you sysctl returns a list of mem locations so you have to do a sysctl/kvm combo to get the stuff you want), however, the structs that are returned contains pointers to other internal data such as ifnet's. There already exists some basic ioctl () request to obtain partial information, but I was thinking of extending the publicly available information by either adding a few more ioctl request, or extending the information available via sysctl. I guess the more complex task would be to efficiently dump the routing cache with bandwidth meters etc. Any thoughts about this? I have not had time to go through netgraph enough yet, but does anyone have some ideas how to avoid using kvm to obtain netgraph info? Thanks a lot, Anders