extending ifmib(4) and de-mem(4)izing netstat

Michal Mertl mime at traveller.cz
Mon Dec 13 14:27:02 PST 2004


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



More information about the freebsd-net mailing list