jhb at freebsd.org
Thu Oct 11 12:45:35 PDT 2007
On Thursday 11 October 2007 08:11:21 am Dag-Erling Smørgrav wrote:
> Matthew Jakeman <m.jakeman at lancaster.ac.uk> writes:
> > I am wanting to create a number of sysctl variables at kernel boot
> > time, 1 for each network interface. I have the code set up to loop
> > through the interfaces using ifnet_byindex() already for other
> > purposes so wanted to create them in this loop.
> > The problem I'm having is naming them, using the SYSCTL_INT() macro as
> > specified :
> > SYSCTL_INT(parent, nbr, name, access, ptr, val, descr);
> > The 'name' parameter is what I wish to manipulate in the loop to
> > append the interface name on to the sysctl variable created however I
> > can't think of a way to do this. If there is another way to accomplish
> > this I would be grateful to hear any suggestions.
> This is the wrong approach, simply create a node with a fixed name in
> each device's private sysctl tree. See for instance how the coretemp
> driver in CURRENT inserts a node into each CPU device's sysctl tree.
Yes, but not all 'struct ifnet's have an associated device_t (think vlans).
More proper would be to create a net.if tree and give each ifnet its own
dynamic sysctl tree under the net.if tree similar to the per-device nodes
One wrinkle with this is that network interfaces can be renamed, and I don't
think the dynamic sysctl stuff lets you rename an existing node currently
(though you could fix that).
More information about the freebsd-hackers