From owner-freebsd-net@FreeBSD.ORG Mon Dec 13 22:27:02 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 1331416A4CE for ; Mon, 13 Dec 2004 22:27:02 +0000 (GMT) Received: from ss.eunet.cz (ss.eunet.cz [193.85.228.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4797D43D1D for ; Mon, 13 Dec 2004 22:27:01 +0000 (GMT) (envelope-from mime@traveller.cz) Received: from [127.0.0.1] (ss.eunet.cz. [193.85.228.13]) by ss.eunet.cz (8.13.1/8.13.1) with ESMTP id iBDMQlvJ090299 for ; Mon, 13 Dec 2004 23:26:47 +0100 (CET) (envelope-from mime@traveller.cz) Message-ID: <41BE1731.8070902@traveller.cz> Date: Mon, 13 Dec 2004 23:26:57 +0100 From: Michal Mertl User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; cs-CZ; rv:1.7.3) Gecko/20041117 X-Accept-Language: cs, en-us, en MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: extending ifmib(4) and de-mem(4)izing netstat 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: Mon, 13 Dec 2004 22:27:02 -0000 Hello all, I like the idea of a system without mem(4) but some system utilities depend on it. I thought I would go and change them to use other ways to get the information. I started with 'netstat -r' and almost completely (refcnt field is missing) removed the need for /dev/mem (in fact there already was incomplete support for it in the sources). I then went to reimplement 'netstat -i' and found out I can't get all the information from sysctls. The stats which I can't find are the counters for addresses configured on the interfaces (in kernel stored in struct in_ifaddr). Am I missing something or would I have to export the data from the kernel? What is the best way to export them? I can see two ways: make it accessible like if_data is exported for physical interfaces in getifaddrs(3) or export the data into some other place like ifmib(4) - e.g. net.inet.generic and net.inet6.generic. From getifaddrs.c I can see that one way to add the information would be to implement something called ifam_data (probably in fact struct ifam_msghdr) which is present on BSDI. It would probably be also possible to hack it rather easily into sysctl_iflist (src/sys/net/rtsock.c) a-la ifm_data member of struct if_msghdr. P.S.: It was a great adventure to browse through the code trying to understand what it does. Did humans write it? :-) I'm talking about the data structures in the kernel, netstat sources are on the other hand a mess. -- Michal Mertl