From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 11 19:45:35 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0427816A417 for ; Thu, 11 Oct 2007 19:45:35 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 9C5C013C474 for ; Thu, 11 Oct 2007 19:45:34 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8p) with ESMTP id 214012639-1834499 for multiple; Thu, 11 Oct 2007 15:26:50 -0400 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l9BJSeAw028631; Thu, 11 Oct 2007 15:28:40 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 11 Oct 2007 14:41:48 -0400 User-Agent: KMail/1.9.6 References: <200710111156.38525.m.jakeman@lancaster.ac.uk> <86ejg14zrq.fsf@ds4.des.no> In-Reply-To: <86ejg14zrq.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200710111441.48995.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 11 Oct 2007 15:28:41 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/4529/Thu Oct 11 02:54:06 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Dag-Erling =?utf-8?q?Sm=C3=B8rgrav?= , m.jakeman@lancaster.ac.uk Subject: Re: Sysctl Naming X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2007 19:45:35 -0000 On Thursday 11 October 2007 08:11:21 am Dag-Erling Sm=C3=B8rgrav wrote: > Matthew Jakeman 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. >=20 > 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).= =20 More proper would be to create a net.if tree and give each ifnet its own=20 dynamic sysctl tree under the net.if tree similar to the per-device nodes=20 under dev. One wrinkle with this is that network interfaces can be renamed, and I don'= t=20 think the dynamic sysctl stuff lets you rename an existing node currently=20 (though you could fix that). =2D-=20 John Baldwin