Date: Thu, 15 Aug 2002 17:25:12 +0800 From: "ouyang kai" <oykai@msn.com> To: "Lambert Terry" <tlambert2@mindspring.com>, <freebsd-hackers@FreeBSD.ORG> Subject: Re: About 'sysctl' routine problem? Message-ID: <OE173Kegmprho5fimNY000222e7@hotmail.com>
next in thread | raw e-mail | index | archive | help
------=_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 <HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV>Dear Terry,<BR= > Thank you!</DIV> <DIV>>Once again, we are talking about linker= sets. This is a little<BR>>more complex, though, since you have= to take the "boot environment"<BR>>into account, as well (the boot en= vironment is the basis for a<BR>>preinitialized sysctl space contents,= seperate from the code you<BR>>see in the kernel itself for the decla= rations of specific sysctl<BR>>OIDs that are added to the ones exporte= d before the kernel is even<BR>>really started.</DIV> <DIV> in ke= rn_mib.c:<BR>SYSCTL_NODE(, CTL_NET, net, CT= LFLAG_RW, 0,<BR> "Network, (see socket.h)");<BR>--><BR>struct sys= ctl_oid_list sysctl_net_children;<BR>static struct sysctl_oid sysctl__net= =3D { <BR> &sysctl_children, { 0 }, &nbs= p; <BR> CTL_NET, CTLTYPE_NODE|CTLFLAG_RW, (void*)&sysctl_net_chi= ldren, <BR> 0, "net", 0, "N", 0 }; <BR>DATA_SET(sysctl_set, sys= ctl__net);</DIV> <DIV>It seem like the SYSINIT macro.<BR>> TUNABL= E_INT_DECL<BR>> TUNABLE_INT_FETCH<BR>> SYSCTL_DECL<BR>>= ; SYSCTL_NODE<BR>> SYSCTL_INT<BR>> SYSCTL_STRUCT<BR>= > SYSCTL_PROC<BR> Whether do they register also in mi_startu= p() like other devices, when the<BR>'sipp' is looped to 'SI_SUB_TUNABLES'= ?<BR> You said some specific sysctl OIDs can be added before the ker= nel is even really started,<BR>I want to know when they will be added? Co= uld you give me an example?<BR> <BR>I try to trace some routine fro= m the 'ifconfig' program source code.<BR>The following code is copied fro= m 'ifconfig' program:<BR> mib[0] =3D CTL_NET;<BR> mib[1] =3D PF= _ROUTE;<BR> mib[2] =3D 0;<BR> mib[3] =3D 0; /* address fam= ily */<BR> mib[4] =3D NET_RT_IFLIST;<BR> mib[5] =3D 0;</DIV> <D= IV> /* if particular family specified, only ask about it */<BR> = ;if (afp)<BR> mib[3] =3D afp->af_af;</DIV> <DIV> if (s= ysctl(mib, 6, NULL, &needed, NULL, 0) < 0)<BR> errx(1, = "iflist-sysctl-estimate");</DIV> <DIV>From the SYSCTL_NODE(_net, PF_ROUTE= , routetable, CTLFLAG_RD, sysctl_rtsock, "");<BR>we can know the RF_ROUTE= is the 'net's children', and its' handler is sysctl_rtsock.<BR>So, the k= ernel will call sysctl_rtsock, right?<BR>in sysctl_rtsock function:<BR>&n= bsp;case NET_RT_IFLIST:<BR> error =3D sysctl_iflist(af, &w= );<BR>So, this time, the kernel will call sysctl_iflist finally, right?<B= R>But I have some wonder how the 'sysctl' command transfer from user spac= e to kernel space?<BR>I find the line in sysproto.h:<BR>int __sysctl= __P((struct proc *, struct sysctl_args *));<BR>I think whether the 'sysc= tl' is changed to '__sysctl' in kernel space?<BR>If that is right, the __= sysctl is how conect with sysctl_rtsock?</DIV> <DIV> Thank yo= u very much!:-)</DIV> <DIV>Best Regards<BR>Ouyang Kai</DIV></BODY></HTML>= <br clear=3Dall><hr>Get more from the Web. FREE MSN Explorer download : = <a href=3D'http://explorer.msn.com'>http://explorer.msn.com</a><br></p> ------=_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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OE173Kegmprho5fimNY000222e7>