Skip site navigation (1)Skip section navigation (2)
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

[-- Attachment #1 --]


[-- Attachment #2 --]
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 = {		  
	&sysctl_children, { 0 },			  
	CTL_NET, CTLTYPE_NODE|CTLFLAG_RW, (void*)&sysctl_net_children,  
	0, "net", 0, "N", 0 };		
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 the
'sipp' is looped to 'SI_SUB_TUNABLES'?
 You said some specific sysctl OIDs can be added before the kernel is even really started,
I want to know when they will be added? Could you give me an example?
	  
I try to trace some routine from the 'ifconfig' program source code.
The following code is copied from 'ifconfig' program:
	mib[0] = CTL_NET;
	mib[1] = PF_ROUTE;
	mib[2] = 0;
	mib[3] = 0;	/* address family */
	mib[4] = NET_RT_IFLIST;
	mib[5] = 0;

	/* if particular family specified, only ask about it */
	if (afp)
		mib[3] = 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_rtsock, "");
we can know the RF_ROUTE is the 'net's children', and its' handler is sysctl_rtsock.
So, the kernel will call sysctl_rtsock, right?
in sysctl_rtsock function:
	case NET_RT_IFLIST:
		error = 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

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OE173Kegmprho5fimNY000222e7>