Date: Fri, 12 Jul 2002 00:29:39 +0200 From: Cyrille Lefevre <cyrille.lefevre@laposte.net> To: Juan Francisco Rodriguez Hervella <jrh@it.uc3m.es> Cc: freebsd-net@FreeBSD.ORG Subject: Re: sysctl inferface question Message-ID: <20020711222939.GE21234@gits.dyndns.org> In-Reply-To: <3D2D9D4E.74A1B6F4@it.uc3m.es> References: <3D2D9D4E.74A1B6F4@it.uc3m.es>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jul 11, 2002 at 04:59:26PM +0200, Juan Francisco Rodriguez Hervella wrote: > > I'm very confused with the sysctl internals. > > For example, looking at the kernel source code of FreeBSD, I've realized > > of the following: > > netinet/in_proco.c: > SYSCTL_NODE(_net_inet6, IPPROTO_DIVERT, divert, > CTLFLAG_RW, 0, "DIVERT"); > netinet/ip_divert.c: > SYSCTL_DECL(_net_inet_divert); > netinet/ip_divert.c: > SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLFLAG_RD, > 0, 0, > div_pcblist, "S,xinpcb", "List of active divert sockets"); > > Isn't this redundant ? I mean, if there is a "SYSCTL_NODE", there is > *no* need for having > "SYSCTL_DECL" in "ip_divert.c"... I am wrong ? to define a node (pcblist here), you have to declare the node (_net_inet_divert here) you want attach it before. > Also, I don't undertand the meaning of the "fmt" field....what is it for > ? What's the > meaning of "S,xinpcb" in the above example ? the format strings isn't used by the kernel but is by the sysctl(1) command. take a look around lines 556-589 (show_var) in /usr/src/sbin/sysctl/sysctl.c : case 'S': i = 0; if (strcmp(fmt, "S,clockinfo") == 0) func = S_clockinfo; else if (strcmp(fmt, "S,timeval") == 0) func = S_timeval; else if (strcmp(fmt, "S,loadavg") == 0) func = S_loadavg; else if (strcmp(fmt, "T,dev_t") == 0) func = T_dev_t; else func = NULL; if (func) { if (!nflag) printf("%s%s", name, sep); return ((*func)(len, p)); } /* FALL THROUGH */ default: if (!oflag && !xflag) return (1); if (!nflag) printf("%s%s", name, sep); printf("Format:%s Length:%d Dump:0x", fmt, len); while (len-- && (xflag || p < val + 16)) printf("%02x", *p++); if (!xflag && len > 16) printf("..."); return (0); so, the "S" is required, but, IMHO, ",xinpcb" is just informative for now. # sysctl net.inet.divert # sysctl net.inet.divert.pcblist # sysctl -A net.inet.divert net.inet.divert.pcblist: Format:S,xinpcb Length:336 Dump:0x18000000010000000100000000000000... # sysctl -A net.inet.divert.pcblist (same) Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net 12, Rue de Bizerte 75017 Paris http://clefevre.fr.st tel/fax: +33 (0)1 45 22 83 85 gsm: +33 (0)6 80 94 76 63 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020711222939.GE21234>