From owner-freebsd-hackers Thu Aug 15 2:25:34 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22A3B37B400 for ; Thu, 15 Aug 2002 02:25:23 -0700 (PDT) Received: from hotmail.com (oe17.pav0.hotmail.com [64.4.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99D2743E70 for ; Thu, 15 Aug 2002 02:25:22 -0700 (PDT) (envelope-from oykai@msn.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 15 Aug 2002 02:25:22 -0700 X-Originating-IP: [210.12.61.105] From: "ouyang kai" To: "Lambert Terry" , Subject: Re: About 'sysctl' routine problem? Date: Thu, 15 Aug 2002 17:25:12 +0800 MIME-Version: 1.0 X-Mailer: MSN Explorer 6.10.0016.1624 Content-Type: multipart/mixed; boundary="----=_NextPart_001_0000_01C24480.B630A860" Message-ID: X-OriginalArrivalTime: 15 Aug 2002 09:25:22.0551 (UTC) FILETIME=[AE2A8070:01C2443D] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG ------=_NextPart_001_0000_01C24480.B630A860 Content-Type: multipart/alternative; boundary="----=_NextPart_002_0001_01C24480.B630A860" ------=_NextPart_002_0001_01C24480.B630A860 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Dear Terry, Thank you! >Once again, we are talking about linker sets. This is a little >more complex, though, since you have to take the "boot environment" >into account, as well (the boot environment is the basis for a >preinitialized sysctl space contents, seperate from the code you >see in the kernel itself for the declarations of specific sysctl >OIDs that are added to the ones exported before the kernel is even >really started. in kern_mib.c: SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); --> struct sysctl_oid_list sysctl_net_children; static struct sysctl_oid sysctl__net =3D { =20 &sysctl_children, { 0 }, =20 CTL_NET, CTLTYPE_NODE|CTLFLAG_RW, (void*)&sysctl_net_children, =20 0, "net", 0, "N", 0 }; =20 DATA_SET(sysctl_set, sysctl__net); It seem like the SYSINIT macro. > TUNABLE_INT_DECL > TUNABLE_INT_FETCH > SYSCTL_DECL > SYSCTL_NODE > SYSCTL_INT > SYSCTL_STRUCT > SYSCTL_PROC Whether do they register also in mi_startup() like other devices, when t= he 'sipp' is looped to 'SI_SUB_TUNABLES'? You said some specific sysctl OIDs can be added before the kernel is eve= n really started, I want to know when they will be added? Could you give me an example? =20 I try to trace some routine from the 'ifconfig' program source code. The following code is copied from 'ifconfig' program: mib[0] =3D CTL_NET; mib[1] =3D PF_ROUTE; mib[2] =3D 0; mib[3] =3D 0; /* address family */ mib[4] =3D NET_RT_IFLIST; mib[5] =3D 0; /* if particular family specified, only ask about it */ if (afp) mib[3] =3D afp->af_af; if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) errx(1, "iflist-sysctl-estimate"); From the SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsoc= k, ""); we can know the RF_ROUTE is the 'net's children', and its' handler is sys= ctl_rtsock. So, the kernel will call sysctl_rtsock, right? in sysctl_rtsock function: case NET_RT_IFLIST: error =3D sysctl_iflist(af, &w); So, this time, the kernel will call sysctl_iflist finally, right? But I have some wonder how the 'sysctl' command transfer from user space = to kernel space? I find the line in sysproto.h: int __sysctl __P((struct proc *, struct sysctl_args *)); I think whether the 'sysctl' is changed to '__sysctl' in kernel space? If that is right, the __sysctl is how conect with sysctl_rtsock? Thank you very much!:-) Best Regards Ouyang KaiGet more from the Web. FREE MSN Explorer download : http://exp= lorer.msn.com ------=_NextPart_002_0001_01C24480.B630A860 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Dear Terry,  Thank you!
>Once again, we are talking about linker= sets.  This is a little
>more complex, though, since you have= to take the "boot environment"
>into account, as well (the boot en= vironment is the basis for a
>preinitialized sysctl space contents,= seperate from the code you
>see in the kernel itself for the decla= rations of specific sysctl
>OIDs that are added to the ones exporte= d before the kernel is even
>really started.
 in ke= rn_mib.c:
SYSCTL_NODE(, CTL_NET,   net,    CT= LFLAG_RW, 0,
 "Network, (see socket.h)");
-->
struct sys= ctl_oid_list sysctl_net_children;
static struct sysctl_oid sysctl__net= =3D {  
 &sysctl_children, { 0 },  &nbs= p;
 CTL_NET, CTLTYPE_NODE|CTLFLAG_RW, (void*)&sysctl_net_chi= ldren,
 0, "net", 0, "N", 0 }; 
DATA_SET(sysctl_set, sys= ctl__net);
It seem like the SYSINIT macro.
> TUNABL= E_INT_DECL
> TUNABLE_INT_FETCH
> SYSCTL_DECL
>= ; SYSCTL_NODE
> SYSCTL_INT
> SYSCTL_STRUCT
= > SYSCTL_PROC
 Whether do they register also in mi_startu= p() like other devices, when the
'sipp' is looped to 'SI_SUB_TUNABLES'= ?
 You said some specific sysctl OIDs can be added before the ker= nel is even really started,
I want to know when they will be added? Co= uld you give me an example?
 
I try to trace some routine fro= m the 'ifconfig' program source code.
The following code is copied fro= m 'ifconfig' program:
 mib[0] =3D CTL_NET;
 mib[1] =3D PF= _ROUTE;
 mib[2] =3D 0;
 mib[3] =3D 0; /* address fam= ily */
 mib[4] =3D NET_RT_IFLIST;
 mib[5] =3D 0;
 /* if particular family specified, only ask about it */
 = ;if (afp)
  mib[3] =3D afp->af_af;
 if (s= ysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
  errx(1, = "iflist-sysctl-estimate");
From the SYSCTL_NODE(_net, PF_ROUTE= , routetable, CTLFLAG_RD, sysctl_rtsock, "");
we can know the RF_ROUTE= is the 'net's children', and its' handler is sysctl_rtsock.
So, the k= ernel will call sysctl_rtsock, right?
in sysctl_rtsock function:
&n= bsp;case NET_RT_IFLIST:
  error =3D sysctl_iflist(af, &w= );
So, this time, the kernel will call sysctl_iflist finally, right?But I have some wonder how the 'sysctl' command transfer from user spac= e to kernel space?
I find the line in sysproto.h:
int __sysctl= __P((struct proc *, struct sysctl_args *));
I think whether the 'sysc= tl' is changed to '__sysctl' in kernel space?
If that is right, the __= sysctl is how conect with sysctl_rtsock?
   Thank yo= u very much!:-)
Best Regards
Ouyang Kai
=

Get more from the Web. FREE MSN Explorer download : = http://explorer.msn.com

------=_NextPart_002_0001_01C24480.B630A860-- ------=_NextPart_001_0000_01C24480.B630A860 Content-Type: text/plain; name="sysctl2.txt" Content-Disposition: attachment; filename="sysctl2.txt" Content-Transfer-Encoding: quoted-printable Dear Terry, Thank you! >Once again, we are talking about linker sets. This is a little >more complex, though, since you have to take the "boot environment" >into account, as well (the boot environment is the basis for a >preinitialized sysctl space contents, seperate from the code you >see in the kernel itself for the declarations of specific sysctl >OIDs that are added to the ones exported before the kernel is even >really started. in kern_mib.c: SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); --> struct sysctl_oid_list sysctl_net_children; static struct sysctl_oid sysctl__net =3D { =20 &sysctl_children, { 0 }, =20 CTL_NET, CTLTYPE_NODE|CTLFLAG_RW, (void*)&sysctl_net_children, =20 0, "net", 0, "N", 0 }; =09 DATA_SET(sysctl_set, sysctl__net); It seem like the SYSINIT macro. > TUNABLE_INT_DECL > TUNABLE_INT_FETCH > SYSCTL_DECL > SYSCTL_NODE > SYSCTL_INT > SYSCTL_STRUCT > SYSCTL_PROC Whether do they register also in mi_startup() like other devices, when t= he 'sipp' is looped to 'SI_SUB_TUNABLES'? You said some specific sysctl OIDs can be added before the kernel is eve= n really started, I want to know when they will be added? Could you give me an example? =20 I try to trace some routine from the 'ifconfig' program source code. The following code is copied from 'ifconfig' program: mib[0] =3D CTL_NET; mib[1] =3D PF_ROUTE; mib[2] =3D 0; mib[3] =3D 0; /* address family */ mib[4] =3D NET_RT_IFLIST; mib[5] =3D 0; /* if particular family specified, only ask about it */ if (afp) mib[3] =3D afp->af_af; if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) errx(1, "iflist-sysctl-estimate"); From the SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsoc= k, ""); we can know the RF_ROUTE is the 'net's children', and its' handler is sys= ctl_rtsock. So, the kernel will call sysctl_rtsock, right? in sysctl_rtsock function: case NET_RT_IFLIST: error =3D sysctl_iflist(af, &w); So, this time, the kernel will call sysctl_iflist finally, right? But I have some wonder how the 'sysctl' command transfer from user space = to kernel space? I find the line in sysproto.h: int __sysctl __P((struct proc *, struct sysctl_args *)); I think whether the 'sysctl' is changed to '__sysctl' in kernel space? If that is right, the __sysctl is how conect with sysctl_rtsock? Thank you very much!:-) Best Regards Ouyang Kai ------=_NextPart_001_0000_01C24480.B630A860-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message