interface cleanup

Anders Persson anders at
Thu Jul 21 18:07:16 GMT 2005

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,

More information about the freebsd-net mailing list