xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision 1921cb5602567cfc8401cc953be22fe9d74238f2)
1.\"	$NetBSD: sysctl.3,v 1.183 2006/09/26 14:48:40 elad Exp $
2.\"
3.\" Copyright (c) 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
31.\"
32.Dd September 26, 2006
33.Dt SYSCTL 3
34.Os
35.Sh NAME
36.Nm sysctl ,
37.Nm sysctlbyname ,
38.Nm sysctlgetmibinfo ,
39.Nm sysctlnametomib
40.Nd get or set system information
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In sys/param.h
45.In sys/sysctl.h
46.Ft int
47.Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" \
48"const void *newp" "size_t newlen"
49.Ft int
50.Fn sysctlbyname "const char *sname" "void *oldp" "size_t *oldlenp" \
51"void *newp" "size_t newlen"
52.Ft int
53.Fn sysctlgetmibinfo "const char *sname" "int *name" "u_int *namelenp" \
54"char *cname" "size_t *csz" "struct sysctlnode **rnode" "int v"
55.Ft int
56.Fn sysctlnametomib "const char *sname" "int *name" "size_t *namelenp"
57.Sh DESCRIPTION
58The
59.Nm
60function retrieves system information and allows processes with
61appropriate privileges to set system information.
62The information available from
63.Nm
64consists of integers, strings, and tables.
65Information may be retrieved and set from the command interface
66using the
67.Xr sysctl 8
68utility.
69.Pp
70Unless explicitly noted below,
71.Nm
72returns a consistent snapshot of the data requested.
73Consistency is obtained by locking the destination
74buffer into memory so that the data may be copied out without blocking.
75Calls to
76.Nm
77are serialized to avoid deadlock.
78.Pp
79The state is described using a ``Management Information Base'' (MIB)
80style name, listed in
81.Fa name ,
82which is a
83.Fa namelen
84length array of integers.
85.Pp
86The
87.Fn sysctlbyname
88function accepts a string representation of a MIB entry and internally
89maps it to the appropriate numeric MIB representation.
90Its semantics are otherwise no different from
91.Fn sysctl .
92.Pp
93The information is copied into the buffer specified by
94.Fa oldp .
95The size of the buffer is given by the location specified by
96.Fa oldlenp
97before the call,
98and that location gives the amount of data copied after a successful call.
99If the amount of data available is greater
100than the size of the buffer supplied,
101the call supplies as much data as fits in the buffer provided
102and returns with the error code ENOMEM.
103If the old value is not desired,
104.Fa oldp
105and
106.Fa oldlenp
107should be set to
108.Dv NULL .
109.Pp
110The size of the available data can be determined by calling
111.Nm
112with a
113.Dv NULL
114parameter for
115.Fa oldp .
116The size of the available data will be returned in the location pointed to by
117.Fa oldlenp .
118For some operations, the amount of space may change often.
119For these operations,
120the system attempts to round up so that the returned size is
121large enough for a call to return the data shortly thereafter.
122.Pp
123To set a new value,
124.Fa newp
125is set to point to a buffer of length
126.Fa newlen
127from which the requested value is to be taken.
128If a new value is not to be set,
129.Fa newp
130should be set to
131.Dv NULL
132and
133.Fa newlen
134set to 0.
135.Pp
136The
137.Fn sysctlnametomib
138function can be used to map the string representation of a MIB entry
139to the numeric version.
140The
141.Fa name
142argument should point to an array of integers large enough to hold the
143MIB, and
144.Fa namelenp
145should indicate the number of integer slots available.
146Following a successful translation, the size_t indicated by
147.Fa namelenp
148will be changed to show the number of slots consumed.
149.Pp
150The
151.Fn sysctlgetmibinfo
152function performs name translation similar to
153.Fn sysctlnametomib ,
154but also canonicalizes the name (or returns the first erroneous token
155from the string being parsed) into the space indicated by
156.Fa cname
157and
158.Fa csz .
159.Fa csz
160should indicate the size of the buffer pointed to by
161.Fa cname
162and on return, will indicate the size of the returned string including
163the trailing
164.Sq nul
165character.
166.Pp
167The
168.Fa rnode
169and
170.Fa v
171arguments to
172.Fn sysctlgetmibinfo
173are used to provide a tree for it to parse into, and to get back
174either a pointer to, or a copy of, the terminal node.
175If
176.Fa rnode
177is
178.Dv NULL ,
179.Fn sysctlgetmibinfo
180uses its own internal tree for parsing, and checks it against the
181kernel at each call, to make sure that the name-to-number mapping is
182kept up to date.
183The
184.Fa v
185argument is ignored in this case.
186If
187.Fa rnode
188is not
189.Dv NULL
190but the pointer it references is, on a successful return,
191.Fa rnode
192will be adjusted to point to a copy of the terminal node.
193The
194.Fa v
195argument indicates which version of the
196.Nm
197node structure the caller wants.
198The application must later
199.Fn free
200this copy.
201If neither
202.Fa rnode
203nor the pointer it references are
204.Dv NULL ,
205the pointer is used as the address of a tree over which the parsing is
206done.
207In this last case, the tree is not checked against the kernel, no
208refreshing of the mappings is performed, and the value given by
209.Fa v
210must agree with the version indicated by the tree.
211It is recommended that applications always use
212.Dv SYSCTL_VERSION
213as the value for
214.Fa v ,
215as defined in the include file
216.Pa sys/sysctl.h .
217.Pp
218The top level names are defined with a CTL_ prefix in
219.Aq Pa sys/sysctl.h ,
220and are as follows.
221The next and subsequent levels down are found in the include files
222listed here, and described in separate sections below.
223.Pp
224.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
225.It Sy Name	Next level names	Description
226.It CTL\_KERN	sys/sysctl.h	High kernel limits
227.It CTL\_VM	uvm/uvm_param.h	Virtual memory
228.It CTL\_VFS	sys/mount.h	Filesystem
229.It CTL\_NET	sys/socket.h	Networking
230.It CTL\_DEBUG	sys/sysctl.h	Debugging
231.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
232.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
233.It CTL\_USER	sys/sysctl.h	User-level
234.It CTL\_DDB	sys/sysctl.h	In-kernel debugger
235.It CTL\_PROC	sys/sysctl.h	Per-process
236.It CTL\_VENDOR	?	Vendor specific
237.It CTL\_EMUL	sys/sysctl.h	Emulation settings
238.It CTL\_SECURITY	sys/sysctl.h	Security settings
239.El
240.Pp
241For example, the following retrieves the maximum number of processes allowed
242in the system:
243.Bd -literal -offset indent -compact
244int mib[2], maxproc;
245size_t len;
246.sp
247mib[0] = CTL_KERN;
248mib[1] = KERN_MAXPROC;
249len = sizeof(maxproc);
250sysctl(mib, 2, \*[Am]maxproc, \*[Am]len, NULL, 0);
251.Ed
252.sp
253To retrieve the standard search path for the system utilities:
254.Bd -literal -offset indent -compact
255int mib[2];
256size_t len;
257char *p;
258.sp
259mib[0] = CTL_USER;
260mib[1] = USER_CS_PATH;
261sysctl(mib, 2, NULL, \*[Am]len, NULL, 0);
262p = malloc(len);
263sysctl(mib, 2, p, \*[Am]len, NULL, 0);
264.Ed
265.Sh CTL_DEBUG
266The debugging variables vary from system to system.
267A debugging variable may be added or deleted without need to recompile
268.Nm
269to know about it.
270Each time it runs,
271.Nm
272gets the list of debugging variables from the kernel and
273displays their current values.
274The system defines twenty
275.Va ( struct ctldebug )
276variables named
277.Dv debug0
278through
279.Dv debug19 .
280They are declared as separate variables so that they can be
281individually initialized at the location of their associated variable.
282The loader prevents multiple use of the same variable by issuing errors
283if a variable is initialized in more than one place.
284For example, to export the variable
285.Dv dospecialcheck
286as a debugging variable, the following declaration would be used:
287.Bd -literal -offset indent -compact
288int dospecialcheck = 1;
289struct ctldebug debug5 = { "dospecialcheck", \*[Am]dospecialcheck };
290.Ed
291.Pp
292Note that the dynamic implementation of
293.Nm
294currently in use largely makes this particular
295.Nm
296interface obsolete.
297See
298.Xr sysctl 8
299.\" and
300.\" .Xr sysctl 9
301for more information.
302.Sh CTL_VFS
303A distinguished second level name, VFS_GENERIC,
304is used to get general information about all filesystems.
305One of its third level identifiers is VFS_MAXTYPENUM
306that gives the highest valid filesystem type number.
307Its other third level identifier is VFS_CONF that
308returns configuration information about the filesystem
309type given as a fourth level identifier.
310The remaining second level identifiers are the
311filesystem type number returned by a
312.Xr statvfs 2
313call or from VFS_CONF.
314The third level identifiers available for each filesystem
315are given in the header file that defines the mount
316argument structure for that filesystem.
317.Sh CTL_HW
318The string and integer information available for the CTL_HW level
319is detailed below.
320The changeable column shows whether a process with appropriate
321privilege may change the value.
322.Bl -column "Second level nameXXXXXX" "struct disk_sysctlXXX" -offset indent
323.It Sy Second level name	Type	Changeable
324.It HW\_ALIGNBYTES	integer	no
325.It HW\_BYTEORDER	integer	no
326.It HW\_CNMAGIC	string	yes
327.It HW\_DISKNAMES	string	no
328.It HW\_DISKSTATS	struct	no
329.It HW\_MACHINE	string	no
330.It HW\_MACHINE\_ARCH	string	no
331.It HW\_MODEL	string	no
332.It HW\_NCPU	integer	no
333.It HW\_PAGESIZE	integer	no
334.It HW\_PHYSMEM	integer	no
335.It HW\_PHYSMEM64	quad	no
336.It HW\_USERMEM	integer	no
337.It HW\_USERMEM64	quad	no
338.El
339.Pp
340.Bl -tag -width "123456"
341.It Li HW_ALIGNBYTES
342Alignment constraint for all possible data types.
343This shows the value
344.Dv ALIGNBYTES
345in
346.Pa /usr/include/machine/param.h ,
347at the kernel compilation time.
348.It Li HW_BYTEORDER
349The byteorder (4,321, or 1,234).
350.It Li HW_CNMAGIC
351The console magic key sequence.
352.It Li HW_DISKNAMES
353The list of (space separated) disk device and NFS mount names on the system.
354.It Li HW_IOSTATNAMES
355A space separated list of devices that will have I/O statistics
356collected on them.
357.It Li HW_IOSTATS
358Return statistical information on the NFS mounts, disk and tape
359devices on the system.
360An array of
361.Va struct io_sysctl
362structures is returned,
363whose size depends on the current number of such objects in the system.
364The third level name is the size of the
365.Va struct io_sysctl .
366The type of object can be determined by examining the
367.Va type
368element of
369.Va struct io_sysctl .
370Which can be
371.Dv IOSTAT_DISK
372(disk drive),
373.Dv IOSTAT_TAPE
374(tape drive), or
375.Dv IOSTAT_NFS
376(NFS mount).
377.It Li HW_MACHINE
378The machine class.
379.It Li HW_MACHINE_ARCH
380The machine CPU class.
381.It Li HW_MODEL
382The machine model.
383.It Li HW_NCPU
384The number of CPUs.
385.ne 1i
386.It Li HW_PAGESIZE
387The software page size.
388.It Li HW_PHYSMEM
389The bytes of physical memory as a 32-bit integer.
390.It Li HW_PHYSMEM64
391The bytes of physical memory as a 64-bit integer.
392.It Li HW_USERMEM
393The bytes of non-kernel memory as a 32-bit integer.
394.It Li HW_USERMEM64
395The bytes of non-kernel memory as a 64-bit integer.
396.El
397.Sh CTL_KERN
398The string and integer information available for the CTL_KERN level
399is detailed below.
400The changeable column shows whether a process with appropriate
401privilege may change the value.
402The types of data currently available are process information,
403system vnodes, the open file entries, routing table entries,
404virtual memory statistics, load average history, and clock rate
405information.
406.Bl -column "KERNXPOSIXXREADERXWRITERXLOCKS" "struct clockrateXXX" -offset indent
407.It Sy Second level name	Type	Changeable
408.It KERN\_ARGMAX	integer	no
409.It KERN\_AUTONICETIME	integer	yes
410.It KERN\_AUTONICEVAL	integer	yes
411.It KERN\_BOOTTIME	struct timeval	no
412.It KERN\_BUFQ	node	not applicable
413.It KERN\_CCPU	integer	no
414.It KERN\_CLOCKRATE	struct clockinfo	no
415.It KERN\_CONSDEV	integer	no
416.It KERN\_CP\_ID	struct	no
417.It KERN\_CP\_TIME	uint64_t[\|]	no
418.It KERN\_DEFCORENAME	string	yes
419.It KERN\_DOMAINNAME	string	yes
420.It KERN\_DRIVERS	struct kinfo_drivers	no
421.It KERN\_FILE	struct file	no
422.It KERN\_FORKFSLEEP	integer	yes
423.It KERN\_FSCALE	integer	no
424.It KERN\_FSYNC	integer	no
425.It KERN\_HARDCLOCK\_TICKS	integer	no
426.It KERN\_HOSTID	integer	yes
427.It KERN\_HOSTNAME	string	yes
428.It KERN\_IOV\_MAX	integer	no
429.It KERN\_JOB\_CONTROL	integer	no
430.It KERN\_LABELOFFSET	integer	no
431.It KERN\_LABELSECTOR	integer	no
432.It KERN\_LOGIN\_NAME\_MAX	integer	no
433.It KERN\_LOGSIGEXIT	integer	yes
434.It KERN\_MAPPED\_FILES	integer	no
435.It KERN\_MAXFILES	integer	yes
436.It KERN\_MAXPARTITIONS	integer	no
437.It KERN\_MAXPHYS	integer	no
438.It KERN\_MAXPROC	integer	yes
439.It KERN\_MAXPTYS	integer	yes
440.It KERN\_MAXVNODES	integer	yes
441.It KERN\_MBUF	node	not applicable
442.It KERN\_MEMLOCK	integer	no
443.It KERN\_MEMLOCK\_RANGE	integer	no
444.It KERN\_MEMORY\_PROTECTION	integer	no
445.It KERN\_MONOTONIC\_CLOCK	integer	no
446.It KERN\_MSGBUF	integer	no
447.It KERN\_MSGBUFSIZE	integer	no
448.It KERN\_NGROUPS	integer	no
449.It KERN\_NTPTIME	struct ntptimeval	no
450.It KERN\_OSRELEASE	string	no
451.It KERN\_OSREV	integer	no
452.It KERN\_OSTYPE	string	no
453.It KERN\_PIPE	node	not applicable
454.It KERN\_POSIX1	integer	no
455.It KERN\_POSIX\_BARRIERS	integer	no
456.It KERN\_POSIX\_READER\_WRITER\_LOCKS	integer	no
457.It KERN\_POSIX\_SEMAPHORES	integer	no
458.It KERN\_POSIX\_SPIN\_LOCKS	integer	no
459.It KERN\_POSIX\_THREADS	integer	no
460.It KERN\_POSIX\_TIMERS	integer	no
461.It KERN\_PROC	struct kinfo_proc	no
462.It KERN\_PROC2	struct kinfo_proc2	no
463.It KERN\_PROC\_ARGS	string	no
464.It KERN\_PROF	node	not applicable
465.It KERN\_RAWPARTITION	integer	no
466.It KERN\_ROOT\_DEVICE	string	no
467.It KERN\_ROOT\_PARTITION	integer	no
468.It KERN\_RTC\_OFFSET	integer	yes
469.It KERN\_SAVED\_IDS	integer	no
470.It KERN\_SECURELVL	integer	raise only
471.It KERN\_SYNCHRONIZED\_IO	integer	no
472.It KERN\_SYSVIPC\_INFO	node	not applicable
473.It KERN\_SYSVMSG	integer	no
474.It KERN\_SYSVSEM	integer	no
475.It KERN\_SYSVSHM	integer	no
476.It KERN\_TIMEX	struct	no
477.It KERN\_TKSTAT	node	not applicable
478.It KERN\_URANDOM	integer	no
479.It KERN\_VERIEXEC	node	not applicable
480.It KERN\_VERSION	string	no
481.It KERN\_VNODE	struct vnode	no
482.El
483.ne 1i
484.Pp
485.Bl -tag -width "123456"
486.It Li KERN_ARGMAX
487The maximum bytes of argument to
488.Xr execve 2 .
489.It Li KERN_AUTONICETIME
490The number of seconds of CPU-time a non-root process may accumulate before
491having its priority lowered from the default to the value of KERN_AUTONICEVAL.
492If set to 0, automatic lowering of priority is not performed, and if set to \-1
493all non-root processes are immediately lowered.
494.It Li KERN_AUTONICEVAL
495The priority assigned for automatically niced processes.
496.It Li KERN_BOOTTIME
497A
498.Va struct timeval
499structure is returned.
500This structure contains the time that the system was booted.
501.It Li KERN_CCPU
502The scheduler exponential decay value.
503.It Li KERN_CLOCKRATE
504A
505.Va struct clockinfo
506structure is returned.
507This structure contains the clock, statistics clock and profiling clock
508frequencies, the number of micro-seconds per hz tick, and the clock
509skew rate.
510.It Li KERN_CONSDEV
511Console device.
512.It Li KERN_CP_ID
513Mapping of CPU number to CPU id.
514.It Li KERN_CP_TIME
515Returns an array of CPUSTATES uint64_ts.
516This array contains the
517number of clock ticks spent in different CPU states.
518On multi-processor systems, the sum across all CPUs is returned unless
519appropriate space is given for one data set for each CPU.
520Data for a specific CPU can also be obtained by adding the number of the
521CPU at the end of the MIB, enlarging it by one.
522.It Li KERN_DEFCORENAME
523Default template for the name of core dump files (see also PROC_PID_CORENAME
524in the per-process variables CTL_PROC, and
525.Xr core 5
526for format of this template).
527The default value is
528.Nm %n.core
529and can be changed with the kernel configuration option
530.Cd options DEFCORENAME
531(see
532.Xr options 4
533).
534.It Li KERN_DOMAINNAME
535Get or set the YP domain name.
536.It Li KERN_DUMP_ON_PANIC
537Perform a crash dump on system panic.
538.It Li KERN_DRIVERS
539Return an array of
540.Va struct kinfo_drivers
541that contains the name and major device numbers of all the device drivers
542in the current kernel.
543The
544.Va d_name
545field is always a NUL terminated string.
546The
547.Va d_bmajor
548field will be set to \-1 if the driver doesn't have a block device.
549.It Li KERN_FILE
550Return the entire file table.
551The returned data consists of a single
552.Va struct filelist
553followed by an array of
554.Va struct file ,
555whose size depends on the current number of such objects in the system.
556.It Li KERN_FORKFSLEEP
557If
558.Xr fork 2
559system call fails due to limit on number of processes (either
560the global maxproc limit or user's one), wait for this many
561milliseconds before returning
562.Er EAGAIN
563error to process.
564Useful to keep heavily forking runaway processes in bay.
565Default zero (no sleep).
566Maximum is 20 seconds.
567.It Li KERN_FSCALE
568The kernel fixed-point scale factor.
569.It Li KERN_FSYNC
570Return 1 if the POSIX 1003.1b File Synchronization Option is available
571on this system,
572otherwise 0.
573.It Li KERN_HARDCLOCK_TICKS
574Returns the number of
575.Xr hardclock 9
576ticks.
577.It Li KERN_HOSTID
578Get or set the host id.
579.It Li KERN_HOSTNAME
580Get or set the hostname.
581.It Li KERN_IOV_MAX
582Return the maximum number of
583.Va iovec
584structures that a process has available for use with
585.Xr preadv 2 ,
586.Xr pwritev 2 ,
587.Xr readv 2 ,
588.Xr recvmsg 2 ,
589.Xr sendmsg 2
590and
591.Xr writev 2 .
592.It Li KERN_JOB_CONTROL
593Return 1 if job control is available on this system, otherwise 0.
594.It Li KERN_LABELOFFSET
595The offset within the sector specified by KERN_LABELSECTOR of the
596.Xr disklabel 5 .
597.It Li KERN_LABELSECTOR
598The sector number containing the
599.Xr disklabel 5 .
600.It Li KERN_LOGIN_NAME_MAX
601The size of the storage required for a login name, in bytes,
602including the terminating NUL.
603.It Li KERN_LOGSIGEXIT
604If this flag is non-zero, the kernel will
605.Xr log 9
606all process exits due to signals which create a
607.Xr core 5
608file, and whether the coredump was created.
609.It Li KERN_MAPPED_FILES
610Returns 1 if the POSIX 1003.1b Memory Mapped Files Option is available
611on this system,
612otherwise 0.
613.It Li KERN_MAXFILES
614The maximum number of open files that may be open in the system.
615.It Li KERN_MAXPARTITIONS
616The maximum number of partitions allowed per disk.
617.It Li KERN_MAXPHYS
618Maximum raw I/O transfer size.
619.It Li KERN_MAXPROC
620The maximum number of simultaneous processes the system will allow.
621.It Li KERN_MAXPTYS
622The maximum number of pseudo terminals.
623This value can be both raised and lowered, though it cannot
624be set lower than number of currently used ptys.
625See also
626.Xr pty 4 .
627.It Li KERN_MAXVNODES
628The maximum number of vnodes available on the system.
629This can only be raised.
630.It Li KERN_MBUF
631Return information about the mbuf control variables.
632the third level names for the mbuf variables are detailed below.
633The changeable column shows whether a process with appropriate
634privilege may change the value.
635.Bl -column "MBUFXNMBCLUSTERSXXX" "struct integerXXX" -offset indent
636.It Sy Third level name	Type	Changeable
637.It MBUF\_MBLOWAT	integer	yes
638.It MBUF\_MCLBYTES	integer	yes
639.It MBUF\_MCLLOWAT	integer	yes
640.It MBUF\_MSIZE	integer	yes
641.It MBUF\_NMBCLUSTERS	integer	yes
642.El
643.Pp
644The variables are as follows:
645.Bl -tag -width "123456"
646.It Li MBUF_MBLOWAT
647The mbuf low water mark.
648.It Li MBUF_MCLBYTES
649The mbuf cluster size.
650.It Li MBUF_MCLLOWAT
651The mbuf cluster low water mark.
652.It Li MBUF_MSIZE
653The mbuf base size.
654.It Li MBUF_NMBCLUSTERS
655The limit on the number of mbuf clusters.
656The variable can only be increased, and only increased on machines with
657direct-mapped pool pages.
658.El
659.It Li KERN_MEMLOCK
660Returns 1 if the POSIX 1003.1b Process Memory Locking Option is available
661on this system,
662otherwise 0.
663.It Li KERN_MEMLOCK_RANGE
664Returns 1 if the POSIX 1003.1b Range Memory Locking Option is available
665on this system,
666otherwise 0.
667.It Li KERN_MEMORY_PROTECTION
668Returns 1 if the POSIX 1003.1b Memory Protection Option is available
669on this system,
670otherwise 0.
671.It Li KERN_MONOTONIC_CLOCK
672Returns the standard version the implementation of the POSIX 1003.1b
673Monotonic Clock Option conforms to,
674otherwise 0.
675.It Li KERN_MSGBUF
676The kernel message buffer, rotated so that the head of the circular kernel
677message buffer is returned at the start of the buffer specified by
678.Fa oldp .
679The returned data may contain NUL bytes.
680.It Li KERN_MSGBUFSIZE
681The maximum number of characters that the kernel message buffer can hold.
682.It Li KERN_NGROUPS
683The maximum number of supplemental groups.
684.It Li KERN_NTPTIME
685A
686.Va struct ntptimeval
687structure is returned.
688This structure contains data used by the
689.Xr ntpd 8
690program.
691.It Li KERN_OSRELEASE
692The system release string.
693.It Li KERN_OSREV
694The system revision string.
695.It Li KERN_OSTYPE
696The system type string.
697.It Li KERN_PIPE
698Pipe settings.
699The third level names for the  integer pipe settings is detailed below.
700The changeable column shows whether a process with appropriate
701privilege may change the value.
702.Bl -column "KERNXPIPEXFOOXXX" "integerXXX" -offset indent
703.It Sy Third level name Type    Changeable
704.It KERN\_PIPE\_KVASIZ	integer	yes
705.It KERN\_PIPE\_MAXBIGPIPES	integer	yes
706.It KERN\_PIPE\_MAXKVASZ	integer	yes
707.It KERN\_PIPE\_LIMITKVA	integer	yes
708.It KERN\_PIPE\_NBIGPIPES	integer	yes
709.El
710.Pp
711The variables are as follows:
712.Bl -tag -width "123456"
713.It Li KERN_PIPE_KVASIZ
714Amount of kernel memory consumed by pipe buffers.
715.It Li KERN_PIPE_MAXBIGPIPES
716Maximum number of "big" pipes.
717.It Li KERN_PIPE_MAXKVASZ
718Maximum amount of kernel memory to be used for pipes.
719.It Li KERN_PIPE_LIMITKVA
720Limit for direct transfers via page loan.
721.It Li KERN_PIPE_NBIGPIPES
722Number of "big" pipes.
723.El
724.It Li KERN_POSIX1
725The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
726attempts to comply.
727.It Li KERN_POSIX_BARRIERS
728The version of
729.St -p1003.1
730and its
731Barriers
732option to which the system attempts to conform,
733otherwise 0.
734.It Li KERN_POSIX_READER_WRITER_LOCKS
735The version of
736.St -p1003.1
737and its
738Read-Write Locks
739option to which the system attempts to conform,
740otherwise 0.
741.It Li KERN_POSIX_SEMAPHORES
742The version of
743.St -p1003.1
744and its
745Semaphores
746option to which the system attempts to conform,
747otherwise 0.
748.It Li KERN_POSIX_SPIN_LOCKS
749The version of
750.St -p1003.1
751and its
752Spin Locks
753option to which the system attempts to conform,
754otherwise 0.
755.It Li KERN_POSIX_THREADS
756The version of
757.St -p1003.1
758and its
759Threads
760option to which the system attempts to conform,
761otherwise 0.
762.It Li KERN_POSIX_TIMERS
763The version of
764.St -p1003.1
765and its
766Timers
767option to which the system attempts to conform,
768otherwise 0.
769.It Li KERN_PROC
770Return the entire process table, or a subset of it.
771An array of
772.Va struct kinfo_proc
773structures is returned,
774whose size depends on the current number of such objects in the system.
775The third and fourth level names are as follows:
776.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
777.It Sy Third level name	Fourth level is:
778.It KERN\_PROC\_ALL	None
779.It KERN\_PROC\_GID	A group ID
780.It KERN\_PROC\_PID	A process ID
781.It KERN\_PROC\_PGRP	A process group
782.It KERN\_PROC\_RGID	A real group ID
783.It KERN\_PROC\_RUID	A real user ID
784.It KERN\_PROC\_SESSION	A session ID
785.It KERN\_PROC\_TTY	A tty device
786.It KERN\_PROC\_UID	A user ID
787.El
788.It Li KERN_PROC2
789As for KERN_PROC, but an array of
790.Va struct kinfo_proc2
791structures are returned.
792The fifth level name is the size of the
793.Va struct kinfo_proc2
794and the sixth level name is the number of structures to return.
795.It Li KERN_PROC_ARGS
796Return the argv or environment strings (or the number thereof)
797of a process.
798Multiple strings are returned separated by NUL characters.
799The third level name is the process ID.
800The fourth level name is as follows:
801.Bl -column "Third level nameXXXXXX" -offset indent
802.It KERN\_PROC\_ARGV	The argv strings
803.It KERN\_PROC\_ENV	The environ strings
804.It KERN\_PROC\_NARGV	The number of argv strings
805.It KERN\_PROC\_NENV	The number of environ strings
806.El
807.It Li KERN_PROF
808Return profiling information about the kernel.
809If the kernel is not compiled for profiling,
810attempts to retrieve any of the KERN_PROF values will
811fail with EOPNOTSUPP.
812The third level names for the string and integer profiling information
813is detailed below.
814The changeable column shows whether a process with appropriate
815privilege may change the value.
816.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
817.It Sy Third level name	Type	Changeable
818.It GPROF\_COUNT	u_short[\|]	yes
819.It GPROF\_FROMS	u_short[\|]	yes
820.It GPROF\_GMONPARAM	struct gmonparam	no
821.It GPROF\_STATE	integer	yes
822.It GPROF\_TOS	struct tostruct	yes
823.El
824.Pp
825The variables are as follows:
826.Bl -tag -width "123456"
827.It Li GPROF_COUNT
828Array of statistical program counter counts.
829.It Li GPROF_FROMS
830Array indexed by program counter of call-from points.
831.It Li GPROF_GMONPARAM
832Structure giving the sizes of the above arrays.
833.It Li GPROF_STATE
834Profiling state.
835If set to GMON_PROF_ON, starts profiling.
836If set to GMON_PROF_OFF, stops profiling.
837.It Li GPROF_TOS
838Array of
839.Va struct tostruct
840describing destination of calls and their counts.
841.El
842.It Li KERN_RAWPARTITION
843The raw partition of a disk (a == 0).
844.It Li KERN_ROOT_DEVICE
845The name of the root device (e.g.,
846.Dq wd0 ) .
847.It Li KERN_ROOT_PARTITION
848The root partition on the root device (a == 0).
849.It Li KERN_RTC_OFFSET
850Return the offset of real time clock from UTC in minutes.
851.It Li KERN_SAVED_IDS
852Returns 1 if saved set-group and saved set-user ID is available.
853.It Li KERN_SBMAX
854Maximum socket buffer size.
855.It Li KERN_SECURELVL
856The system security level.
857This level may be raised by processes with appropriate privilege.
858It may only be lowered by process 1.
859.It Li KERN_SOMAXKVA
860Maximum amount of kernel memory to be used for socket buffers.
861.It Li KERN_SYNCHRONIZED_IO
862Returns 1 if the POSIX 1003.1b Synchronized I/O Option is available
863on this system,
864otherwise 0.
865.It Li KERN_SYSVIPC_INFO
866Return System V style IPC configuration and run-time information.
867The third level name selects the System V style IPC facility.
868.Bl -column "KERN_SYSVIPC_MSG_INFOXXX" "struct shm_sysctl_infoXXX" -offset indent
869.It Sy Third level name	Type
870.It KERN\_SYSVIPC\_MSG\_INFO	struct msg_sysctl_info
871.It KERN\_SYSVIPC\_SEM\_INFO	struct sem_sysctl_info
872.It KERN\_SYSVIPC\_SHM\_INFO	struct shm_sysctl_info
873.El
874.Pp
875.Bl -tag -width "123456"
876.It Li KERN_SYSVIPC_MSG_INFO
877Return information on the System V style message facility.
878The
879.Sy msg_sysctl_info
880structure is defined in
881.Aq Pa sys/msg.h .
882.It Li KERN_SYSVIPC_SEM_INFO
883Return information on the System V style semaphore facility.
884The
885.Sy sem_sysctl_info
886structure is defined in
887.Aq Pa sys/sem.h .
888.It Li KERN_SYSVIPC_SHM_INFO
889Return information on the System V style shared memory facility.
890The
891.Sy shm_sysctl_info
892structure is defined in
893.Aq Pa sys/shm.h .
894.El
895.It Li KERN_SYSVMSG
896Returns 1 if System V style message queue functionality is available
897on this system,
898otherwise 0.
899.It Li KERN_SYSVSEM
900Returns 1 if System V style semaphore functionality is available
901on this system,
902otherwise 0.
903.It Li KERN_SYSVSHM
904Returns 1 if System V style share memory functionality is available
905on this system,
906otherwise 0.
907.It Li KERN_TIMEX
908Not available.
909.It Li KERN_TKSTAT
910Return information about the number of characters sent and received
911on ttys.
912The third level names for the tty statistic variables are detailed below.
913The changeable column shows whether a process
914with appropriate privilege may change the value.
915.Bl -column "KERNXTKSTATXRAWCCXXX" "struct integerXXX" -offset indent
916.It Sy Third level name	Type	Changeable
917.It KERN\_TKSTAT\_CANCC	quad	no
918.It KERN\_TKSTAT\_NIN	quad	no
919.It KERN\_TKSTAT\_NOUT	quad	no
920.It KERN\_TKSTAT\_RAWCC	quad	no
921.El
922.Pp
923The variables are as follows:
924.Bl -tag -width "123456"
925.It Li KERN_TKSTAT_CANCC
926The number of canonical input characters.
927.It Li KERN_TKSTAT_NIN
928The total number of input characters.
929.It Li KERN_TKSTAT_NOUT
930The total number of output characters.
931.It Li KERN_TKSTAT_RAWCC
932The number of raw input characters.
933.El
934.It Li KERN_URND
935Random integer value.
936.It Li KERN_VERIEXEC
937Tunings for Verixec.
938Third level names for the Veriexec variables are detailed below.
939The changeable column shows whether a process with appropriate privilege may
940change the value or only raise it.
941Only the superuser can modify these variables.
942.Bl -column "VERIEXECXALGORITHMSXXX" "struct integerXXX" -offset indent
943.It Sy Third level name	Type	Changeable
944.It VERIEXEC\_ALGORITHMS	string	no
945.It VERIEXEC\_COUNT	node	not applicable
946.It VERIEXEC\_STRICT	integer	raise only
947.It VERIEXEC\_VERBOSE	integer	yes
948.El
949.Pp
950The variables are as follows:
951.Bl -tag -width "123456"
952.It Li VERIEXEC_ALGORITHMS
953Returns a string with the supported algorithms in Veriexec.
954.It Li VERIEXEC_COUNT
955Sub-nodes are added to this node as new mounts are monitored by Veriexec.
956Each mount will be under its own
957.No tableN
958node.
959Under each node there will be three variables, indicating the mount
960point, the file-system type, and the number of entries.
961.It Li VERIEXEC_STRICT
962Controls the strict level of Veriexec.
963The strict level defines how Veriexec will treat various situations.
964.Pp
965In strict level 0, the system is in learning mode and will only warn about
966fingerprint mismatches, as well as allow removal of fingerprinted files.
967It is the only level where fingerprints can be loaded.
968.Pp
969In strict level 1, the system is in IDS mode.
970It will deny access to files with mismatched fingerprints.
971Write access to monitored files will be permitted, but once modified, further
972access to them will be denied.
973Monitored files cannot be removed.
974If a disk will be opened for raw writing, Veriexec will invalidate all
975fingerprints on that disk, if it is monitored.
976.Pp
977In strict level 2, the system is in IPS mode.
978It has all effects of
979strict level 1, plus it will deny write access to monitored files and enforce
980access type (direct, indirect, file).
981Execution of non-monitored files is denied.
982Opening of raw disks for writing will be denied if the disk is monitored.
983Attempts to write to kernel memory, either via
984.Pa /dev/mem
985or
986.Pa /dev/kmem ,
987will be denied to protect Veriexec's internal data-structures.
988.Pp
989Strict level 3 operates as lockdown mode.
990It will have all effects of
991strict level 2, but it will also prevent access to non-monitored files.
992Furthermore, it will prevent addition of new files to the system, and
993allow writing only to files opened before the strict level was raised.
994All attempts to open a disk for raw writing will be denied.
995.It Li VERIEXEC_VERBOSE
996Controls the verbosity level of Veriexec.
997If 0, only the minimal
998indication required will be given about what's happening - fingerprint
999mismatches, removal of entries from the tables, modification of a
1000fingerprinted file.
1001If 1, more messages will be printed (ie., when a file with a valid
1002fingerprint is accessed).
1003Verbose level 2 is debug mode.
1004.El
1005.It Li KERN_VERSION
1006The system version string.
1007.It Li KERN_VNODE
1008Return the entire vnode table.
1009Note, the vnode table is not necessarily a consistent snapshot of
1010the system.
1011The returned data consists of an array whose size depends on the
1012current number of such objects in the system.
1013Each element of the array contains the kernel address of a vnode
1014.Va struct vnode *
1015followed by the vnode itself
1016.Va struct vnode .
1017.It Li kern.coredump.setid
1018Settings related to set-id processes coredumps.
1019By default, set-id processes do not dump core in situations where
1020other processes would.
1021The settings in this node allows an administrator to change this
1022behavior.
1023.Pp
1024.Bl -tag -width "123456"
1025.It Li kern.coredump.setid.dump
1026If non-zero, set-id processes will dump core.
1027.It Li kern.coredump.setid.group
1028The group-id for the set-id processes' coredump.
1029.It Li kern.coredump.setid.mode
1030The mode for the set-id processes' coredump.
1031See
1032.Xr chmod 1 .
1033.It Li kern.coredump.setid.owner
1034The user-id that will be used as the owner of the set-id processes'
1035coredump.
1036.It Li kern.coredump.setid.path
1037The path to which set-id processes' coredumps will be saved to.
1038Same syntax as kern.defcorename.
1039.El
1040.El
1041.Sh CTL_MACHDEP
1042The set of variables defined is architecture dependent.
1043Most architectures define at least the following variables.
1044.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
1045.It Sy Second level name	Type	Changeable
1046.It Li CPU_CONSDEV	dev_t	no
1047.El
1048.Sh CTL_NET
1049The string and integer information available for the CTL_NET level
1050is detailed below.
1051The changeable column shows whether a process with appropriate
1052privilege may change the value.
1053The second and third levels are typically the protocol family and
1054protocol number, though this is not always the case.
1055.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
1056.It Sy Second level name	Type	Changeable
1057.It PF\_ROUTE	routing messages	no
1058.It PF\_INET	IPv4 values	yes
1059.It PF\_INET6	IPv6 values	yes
1060.It PF\_KEY	IPsec key management values	yes
1061.El
1062.Pp
1063.Bl -tag -width "123456"
1064.It Li PF_ROUTE
1065Return the entire routing table or a subset of it.
1066The data is returned as a sequence of routing messages (see
1067.Xr route 4
1068for the header file, format and meaning).
1069The length of each message is contained in the message header.
1070.Pp
1071The third level name is a protocol number, which is currently always 0.
1072The fourth level name is an address family, which may be set to 0 to
1073select all address families.
1074The fifth and sixth level names are as follows:
1075.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
1076.It Sy Fifth level name	Sixth level is:
1077.It NET\_RT\_FLAGS	rtflags
1078.It NET\_RT\_DUMP	None
1079.It NET\_RT\_IFLIST	None
1080.El
1081.It Li PF_INET
1082Get or set various global information about the IPv4
1083.Pq Internet Protocol version 4 .
1084The third level name is the protocol.
1085The fourth level name is the variable name.
1086The currently defined protocols and names are:
1087.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
1088.It Sy Protocol name	Variable name	Type	Changeable
1089.It arp	down	integer	yes
1090.It arp	keep	integer	yes
1091.It arp	prune	integer	yes
1092.It arp	refresh	integer	yes
1093.It carp	allow	integer yes
1094.It carp	preempt	integer yes
1095.It carp	log	integer yes
1096.It carp	arpbalance	integer yes
1097.It icmp	errppslimit	integer	yes
1098.It icmp	maskrepl	integer	yes
1099.It icmp	rediraccept	integer	yes
1100.It icmp	redirtimeout	integer	yes
1101.It ip	allowsrcrt	integer	yes
1102.It ip	anonportmax	integer	yes
1103.It ip	anonportmin	integer	yes
1104.It ip	checkinterface	integer	yes
1105.It ip	directed-broadcast	integer	yes
1106.It ip	do_loopback_cksum	integer	yes
1107.It ip	forwarding	integer	yes
1108.It ip	forwsrcrt	integer	yes
1109.It ip	gifttl	integer	yes
1110.It ip	grettl	integer	yes
1111.It ip	hostzerobroadcast	integer	yes
1112.It ip	lowportmin	integer	yes
1113.It ip	lowportmax	integer	yes
1114.It ip	maxflows	integer	yes
1115.It ip	maxfragpackets	integer	yes
1116.It ip	mtudisc	integer	yes
1117.It ip	mtudisctimeout	integer	yes
1118.It ip	random_id	integer	yes
1119.It ip	redirect	integer	yes
1120.It ip	subnetsarelocal	integer	yes
1121.It ip	ttl	integer	yes
1122.It tcp	rfc1323	integer	yes
1123.It tcp	sendspace	integer	yes
1124.It tcp	recvspace	integer	yes
1125.It tcp	mssdflt	integer	yes
1126.It tcp	syn_cache_limit	integer	yes
1127.It tcp	syn_bucket_limit	integer	yes
1128.It tcp	syn_cache_interval	integer	yes
1129.It tcp	init_win	integer	yes
1130.It tcp	init_win_local	integer	yes
1131.It tcp	mss_ifmtu	integer	yes
1132.It tcp	sack	integer	yes
1133.It tcp	win_scale	integer	yes
1134.It tcp	timestamps	integer	yes
1135.It tcp	compat_42	integer	yes
1136.It tcp	cwm	integer	yes
1137.It tcp	cwm_burstsize	integer	yes
1138.It tcp	ack_on_push	integer	yes
1139.It tcp	keepidle	integer	yes
1140.It tcp	keepintvl	integer	yes
1141.It tcp	keepcnt	integer	yes
1142.It tcp	slowhz	integer	no
1143.It tcp	newreno	integer	yes
1144.It tcp	log_refused	integer	yes
1145.It tcp	rstppslimit	integer	yes
1146.It tcp	ident	struct	no
1147.It udp	checksum	integer	yes
1148.It udp	do_loopback_cksum	integer	yes
1149.It udp	recvspace	integer	yes
1150.It udp	sendspace	integer	yes
1151.El
1152.Pp
1153The variables are as follows:
1154.Bl -tag -width "123456"
1155.It Li arp.down
1156Failed ARP entry lifetime.
1157.It Li arp.keep
1158Valid ARP entry lifetime.
1159.It Li arp.prune
1160ARP cache pruning interval.
1161.It Li arp.refresh
1162ARP entry refresh interval.
1163.It Li carp.allow
1164If set to 0, incoming
1165.Xr carp 4
1166packets will not be processed.
1167If set to any other value, processing will occur.
1168Enabled by default.
1169.It Li carp.arpbalance
1170If set to any value other than 0, the ARP balancing functionality of
1171.Xr carp 4
1172is enabled.
1173When ARP requests are received for an IP address which is part of any virtual
1174host, carp will hash the source IP in the ARP request to select one of the
1175virtual hosts from the set of all the virtual hosts which have that IP address.
1176The master of that host will respond with the correct virtual MAC address.
1177Disabled by default.
1178.It Li carp.log
1179If set to any value other than 0,
1180.Xr carp 4
1181will log errors.
1182Disabled by default.
1183.It Li carp.preempt
1184If set to 0,
1185.Xr carp 4
1186will not attempt to become master if it is receiving advertisements from
1187another active master.
1188If set to any other value, carp will become master of the virtual host if it
1189believes it can send advertisements more frequently than the current master.
1190Disabled by default.
1191.It Li ip.allowsrcrt
1192If set to 1, the host accepts source routed packets.
1193.It Li ip.anonportmax
1194The highest port number to use for TCP and UDP ephemeral port allocation.
1195This cannot be set to less than 1024 or greater than 65535, and must
1196be greater than
1197.Li ip.anonportmin .
1198.It Li ip.anonportmin
1199The lowest port number to use for TCP and UDP ephemeral port allocation.
1200This cannot be set to less than 1024 or greater than 65535.
1201.It Li ip.checkinterface
1202If set to non-zero, the host will reject packets addressed to it
1203that arrive on an interface not bound to that address.
1204Currently, this must be disabled if ipnat is used to translate the
1205destination address to another local interface, or if addresses
1206are added to the loopback interface instead of the interface where
1207the packets for those packets are received.
1208.It Li ip.directed-broadcast
1209If set to 1, enables directed broadcast behavior for the host.
1210.It Li ip.do_loopback_cksum
1211Perform IP checksum on loopback.
1212.It Li ip.forwarding
1213If set to 1, enables IP forwarding for the host,
1214meaning that the host is acting as a router.
1215.It Li ip.forwsrcrt
1216If set to 1, enables forwarding of source-routed packets for the host.
1217This value may only be changed if the kernel security level is less than 1.
1218.It Li ip.gifttl
1219The maximum time-to-live (hop count) value for an IPv4 packet generated by
1220.Xr gif 4
1221tunnel interface.
1222.It Li ip.grettl
1223The maximum time-to-live (hop count) value for an IPv4 packet generated by
1224.Xr gre 4
1225tunnel interface.
1226.It Li ip.hostzerobroadcast
1227All zeroes address is broadcast address.
1228.It Li ip.lowportmax
1229The highest port number to use for TCP and UDP reserved port allocation.
1230This cannot be set to less than 0 or greater than 1024, and must
1231be greater than
1232.Li ip.lowportmin .
1233.It Li ip.lowportmin
1234The lowest port number to use for TCP and UDP reserved port allocation.
1235This cannot be set to less than 0 or greater than 1024, and must
1236be smaller than
1237.Li ip.lowportmax .
1238.It Li ip.maxflows
1239IP Fast Forwarding is enabled by default.
1240If set to 0, IP Fast Forwarding is disabled.
1241.Li ip.maxflows
1242controls the maximum amount of flows which can be created.
1243The default value is 256.
1244.It Li ip.maxfragpackets
1245The maximum number of fragmented packets the node will accept.
12460 means that the node will not accept any fragmented packets.
1247\-1 means that the node will accept as many fragmented packets as it receives.
1248The flag is provided basically for avoiding possible DoS attacks.
1249.It Li ip.mtudisc
1250If set to 1, enables Path MTU Discovery (RFC 1191).
1251When Path MTU Discovery is enabled, the transmitted TCP segment
1252size will be determined by the advertised maximum segment size
1253(MSS) from the remote end, as constrained by the path MTU.
1254If MTU Discovery is disabled, the transmitted segment size will
1255never be greater than
1256.Li tcp.mssdflt
1257(the local maximum segment size).
1258.It Li ip.mtudisctimeout
1259The number of seconds in which a route added by the Path MTU
1260Discovery engine will time out.
1261When the route times out, the Path
1262MTU Discovery engine will attempt to probe a larger path MTU.
1263.It Li ip.random_id
1264Assign random ip_id values.
1265.It Li ip.redirect
1266If set to 1, ICMP redirects may be sent by the host.
1267This option is ignored unless the host is routing IP packets,
1268and should normally be enabled on all systems.
1269.It Li ip.subnetsarelocal
1270If set to 1, subnets are to be considered local addresses.
1271.It Li ip.ttl
1272The maximum time-to-live (hop count) value for an IP packet sourced by
1273the system.
1274This value applies to normal transport protocols, not to ICMP.
1275.It Li icmp.errppslimit
1276The variable specifies the maximum number of outgoing ICMP error messages,
1277per second.
1278ICMP error messages that exceeded the value are subject to rate limitation
1279and will not go out from the node.
1280Negative value disables rate limitation.
1281.It Li icmp.maskrepl
1282If set to 1, ICMP network mask requests are to be answered.
1283.It Li icmp.rediraccept
1284If set to non-zero, the host will accept ICMP redirect packets.
1285Note that routers will never accept ICMP redirect packets,
1286and the variable is meaningful on IP hosts only.
1287.It Li icmp.redirtimeout
1288The variable specifies lifetime of routing entries generated by incoming
1289ICMP redirect.
1290This defaults to 600 seconds.
1291.It Li icmp.returndatabytes
1292Number of bytes to return in an ICMP error message.
1293.It Li tcp.ack_on_push
1294If set to 1, TCP is to immediately transmit an ACK upon reception of
1295a packet with PUSH set.
1296This can avoid losing a round trip time in some rare situations,
1297but has the caveat of potentially defeating TCP's delayed ACK algorithm.
1298Use of this option is generally not recommended, but
1299the variable exists in case your configuration really needs it.
1300.It Li tcp.compat_42
1301If set to 1, enables work-arounds for bugs in the 4.2BSD TCP implementation.
1302Use of this option is not recommended, although it may be
1303required in order to communicate with extremely old TCP implementations.
1304.It Li tcp.cwm
1305If set to 1, enables use of the Hughes/Touch/Heidemann Congestion Window
1306Monitoring algorithm.
1307This algorithm prevents line-rate bursts of packets that could
1308otherwise occur when data begins flowing on an idle TCP connection.
1309These line-rate bursts can contribute to network and router congestion.
1310This can be particularly useful on World Wide Web servers
1311which support HTTP/1.1, which has lingering connections.
1312.It Li tcp.cwm_burstsize
1313The Congestion Window Monitoring allowed burst size, in terms
1314of packet count.
1315.It Li tcp.delack_ticks
1316Number of ticks to delay sending an ACK.
1317.It Li tcp.do_loopback_cksum
1318Perform TCP checksum on loopback.
1319.It Li tcp.init_win
1320A value indicating the TCP initial congestion window.
1321If this value is 0, an auto-tuning algorithm designed to use an initial
1322window of approximately 4K bytes is in use.
1323Otherwise, this value indicates a fixed number of packets.
1324.It Li tcp.init_win_local
1325Like
1326.Li tcp.init_win ,
1327but used when communicating with hosts on a local network.
1328.It Li tcp.keepcnt
1329Number of keepalive probes sent before declaring a connection dead.
1330If set to zero, there is no limit;
1331keepalives will be sent until some kind of
1332response is received from the peer.
1333.It Li tcp.keepidle
1334Time a connection must be idle before keepalives are sent (if keepalives
1335are enabled for the connection).
1336See also tcp.slowhz.
1337.It Li tcp.keepintvl
1338Time after a keepalive probe is sent until, in the absence of any response,
1339another probe is sent.
1340See also tcp.slowhz.
1341.It Li tcp.log_refused
1342If set to 1, refused TCP connections to the host will be logged.
1343.It Li tcp.mss_ifmtu
1344If set to 1, TCP calculates the outgoing maximum segment size based on
1345the MTU of the appropriate interface.
1346If set to 0, it is calculated based on the greater of the MTU of the
1347interface, and the largest (non-loopback) interface MTU on the system.
1348.It Li tcp.mssdflt
1349The default maximum segment size both advertised to the peer
1350and to use when either the peer does not advertise a maximum segment size to
1351us during connection setup or Path MTU Discovery
1352.Li ( ip.mtudisc )
1353is disabled.
1354Do not change this value unless you really know what you are doing.
1355.It Li tcp.newreno
1356If set to 1, enables the use of J.
1357Hoe's NewReno congestion control algorithm.
1358This algorithm improves the start-up behavior of TCP connections.
1359.It Li tcp.recvspace
1360The default TCP receive buffer size.
1361.It Li tcp.rfc1323
1362If set to 1, enables RFC 1323 extensions to TCP.
1363.It Li tcp.rstppslimit
1364The variable specifies the maximum number of outgoing TCP RST packets,
1365per second.
1366TCP RST packet that exceeded the value are subject to rate limitation
1367and will not go out from the node.
1368Negative value disables rate limitation.
1369.It Li tcp.sack.enable
1370If set to 1, enables RFC 2018 Selective ACKnowledgement.
1371.It Li tcp.sack.globalholes
1372Global number of TCP SACK holes.
1373.It Li tcp.sack.globalmaxholes
1374Global maximum number of TCP SACK holes.
1375.It Li tcp.sack.maxholes
1376Maximum number of TCP SACK holes allowed per connection.
1377.It Li tcp.ecn.enable
1378If set to 1, enables RFC 3168 Explicit Congestion Notification.
1379.It Li tcp.ecn.maxretries
1380Number of times to retry sending the ECN-setup packet.
1381.It Li tcp.sendspace
1382The default TCP send buffer size.
1383.It Li tcp.slowhz
1384The units for tcp.keepidle and tcp.keepintvl; those variables are in ticks
1385of a clock that ticks tcp.slowhz times per second.
1386(That is, their values
1387must be divided by the tcp.slowhz value to get times in seconds.)
1388.It Li tcp.syn_bucket_limit
1389The maximum number of entries allowed per hash bucket in the TCP
1390compressed state engine.
1391.It Li tcp.syn_cache_limit
1392The maximum number of entries allowed in the TCP compressed state
1393engine.
1394.It Li tcp.timestamps
1395If rfc1323 is enabled, a value of 1 indicates RFC 1323 time stamp options,
1396used for measuring TCP round trip times, are enabled.
1397.It Li tcp.win_scale
1398If rfc1323 is enabled, a value of 1 indicates RFC 1323 window scale options,
1399for increasing the TCP window size, are enabled.
1400.It Li udp.checksum
1401If set to 1, UDP checksums are being computed.
1402Received non-zero UDP checksums are always checked.
1403Disabling UDP checksums is strongly discouraged.
1404.It Li udp.sendspace
1405The default UDP send buffer size.
1406.It Li udp.recvspace
1407The default UDP receive buffer size.
1408.El
1409.Pp
1410For variables net.*.ipsec, please refer to
1411.Xr ipsec 4 .
1412.It Li PF_INET6
1413Get or set various global information about the IPv6
1414.Pq Internet Protocol version 6 .
1415The third level name is the protocol.
1416The fourth level name is the variable name.
1417The currently defined protocols and names are:
1418.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
1419.It Sy Protocol name	Variable name	Type	Changeable
1420.It icmp6	errppslimit	integer	yes
1421.It icmp6	mtudisc_hiwat	integer	yes
1422.It icmp6	mtudisc_lowat	integer	yes
1423.It icmp6	nd6_debug	integer	yes
1424.It icmp6	nd6_delay	integer	yes
1425.It icmp6	nd6_maxnudhint	integer	yes
1426.It icmp6	nd6_mmaxtries	integer	yes
1427.It icmp6	nd6_prune	integer	yes
1428.It icmp6	nd6_umaxtries	integer	yes
1429.It icmp6	nd6_useloopback	integer	yes
1430.It icmp6	nodeinfo	integer	yes
1431.It icmp6	rediraccept	integer	yes
1432.It icmp6	redirtimeout	integer	yes
1433.It ip6	accept_rtadv	integer	yes
1434.It ip6	anonportmax	integer	yes
1435.It ip6	anonportmin	integer	yes
1436.It ip6	auto_flowlabel	integer	yes
1437.It ip6	dad_count	integer	yes
1438.It ip6	defmcasthlim	integer	yes
1439.It ip6	forwarding	integer	yes
1440.It ip6	gifhlim	integer	yes
1441.It ip6	hlim	integer	yes
1442.It ip6	hdrnestlimit	integer	yes
1443.It ip6	kame_version	string	no
1444.It ip6	keepfaith	integer	yes
1445.It ip6	log_interval	integer	yes
1446.It ip6	lowportmax	integer	yes
1447.It ip6	lowportmin	integer	yes
1448.It ip6	maxfragpackets	integer	yes
1449.It ip6	maxfrags	integer	yes
1450.It ip6	redirect	integer	yes
1451.It ip6	rr_prune	integer	yes
1452.It ip6	use_deprecated	integer	yes
1453.It ip6	v6only	integer	yes
1454.It udp6	do_loopback_cksum	integer	yes
1455.It udp6	recvspace	integer	yes
1456.It udp6	sendspace	integer	yes
1457.El
1458.Pp
1459The variables are as follows:
1460.Bl -tag -width "123456"
1461.It Li ip6.accept_rtadv
1462If set to non-zero, the node will accept ICMPv6 router advertisement packets
1463and autoconfigures address prefixes and default routers.
1464The node must be a host
1465.Pq not a router
1466for the option to be meaningful.
1467.It Li ip6.anonportmax
1468The highest port number to use for TCP and UDP ephemeral port allocation.
1469This cannot be set to less than 1024 or greater than 65535, and must
1470be greater than
1471.Li ip6.anonportmin .
1472.It Li ip6.anonportmin
1473The lowest port number to use for TCP and UDP ephemeral port allocation.
1474This cannot be set to less than 1024 or greater than 65535.
1475.It Li ip6.auto_flowlabel
1476On connected transport protocol packets,
1477fill IPv6 flowlabel field to help intermediate routers to identify packet flows.
1478.It Li ip6.dad_count
1479The variable configures number of IPv6 DAD
1480.Pq duplicated address detection
1481probe packets.
1482The packets will be generated when IPv6 interface addresses are configured.
1483.It Li ip6.defmcasthlim
1484The default hop limit value for an IPv6 multicast packet sourced by the node.
1485This value applies to all the transport protocols on top of IPv6.
1486There are APIs to override the value, as documented in
1487.Xr ip6 4 .
1488.It Li ip6.forwarding
1489If set to 1, enables IPv6 forwarding for the node,
1490meaning that the node is acting as a router.
1491If set to 0, disables IPv6 forwarding for the node,
1492meaning that the node is acting as a host.
1493IPv6 specification defines node behavior for
1494.Dq router
1495case and
1496.Dq host
1497case quite differently, and changing this variable during operation
1498may cause serious trouble.
1499It is recommended to configure the variable at bootstrap time,
1500and bootstrap time only.
1501.It Li ip6.gifhlim
1502The maximum hop limit value for an IPv6 packet generated by
1503.Xr gif 4
1504tunnel interface.
1505.It Li ip6.hdrnestlimit
1506The number of IPv6 extension headers permitted on incoming IPv6 packets.
1507If set to 0, the node will accept as many extension headers as possible.
1508.It Li ip6.hlim
1509The default hop limit value for an IPv6 unicast packet sourced by the node.
1510This value applies to all the transport protocols on top of IPv6.
1511There are APIs to override the value, as documented in
1512.Xr ip6 4 .
1513.It Li ip6.kame_version
1514The string identifies the version of KAME IPv6 stack implemented in the kernel.
1515.It Li ip6.keepfaith
1516If set to non-zero, it enables
1517.Dq FAITH
1518TCP relay IPv6-to-IPv4 translator code in the kernel.
1519Refer
1520.Xr faith 4
1521and
1522.Xr faithd 8
1523for detail.
1524.It Li ip6.log_interval
1525The variable controls amount of logs generated by IPv6 packet
1526forwarding engine, by setting interval between log output
1527.Pq in seconds .
1528.It Li ip6.lowportmax
1529The highest port number to use for TCP and UDP reserved port allocation.
1530This cannot be set to less than 0 or greater than 1024, and must
1531be greater than
1532.Li ip6.lowportmin .
1533.It Li ip6.lowportmin
1534The lowest port number to use for TCP and UDP reserved port allocation.
1535This cannot be set to less than 0 or greater than 1024, and must
1536be smaller than
1537.Li ip6.lowportmax .
1538.It Li ip6.maxfragpackets
1539The maximum number of fragmented packets the node will accept.
15400 means that the node will not accept any fragmented packets.
1541\-1 means that the node will accept as many fragmented packets as it receives.
1542The flag is provided basically for avoiding possible DoS attacks.
1543.It Li ip6.maxfrags
1544The maximum number of fragments the node will accept.
15450 means that the node will not accept any fragments.
1546\-1 means that the node will accept as many fragments as it receives.
1547The flag is provided basically for avoiding possible DoS attacks.
1548.It Li ip6.redirect
1549If set to 1, ICMPv6 redirects may be sent by the node.
1550This option is ignored unless the node is routing IP packets,
1551and should normally be enabled on all systems.
1552.It Li ip6.rr_prune
1553The variable specifies interval between IPv6 router renumbering prefix
1554babysitting, in seconds.
1555.It Li ip6.use_deprecated
1556The variable controls use of deprecated address, specified in RFC 2462 5.5.4.
1557.It Li ip6.v6only
1558The variable specifies initial value for
1559.Dv IPV6_V6ONLY
1560socket option for
1561.Dv AF_INET6
1562socket.
1563Please refer to
1564.Xr ip6 4
1565for detail.
1566.It Li icmp6.errppslimit
1567The variable specifies the maximum number of outgoing ICMPv6 error messages,
1568per second.
1569ICMPv6 error messages that exceeded the value are subject to rate limitation
1570and will not go out from the node.
1571Negative value disables rate limitation.
1572.It Li icmp6.mtudisc_hiwat
1573.It Li icmp6.mtudisc_lowat
1574The variables define the maximum number of routing table entries,
1575created due to path MTU discovery
1576.Pq prevents denial-of-service attacks with ICMPv6 too big messages .
1577When IPv6 path MTU discovery happens, we keep path MTU information into
1578the routing table.
1579If the number of routing table entries exceed the value,
1580the kernel will not attempt to keep the path MTU information.
1581.Li icmp6.mtudisc_hiwat
1582is used when we have verified ICMPv6 too big messages.
1583.Li icmp6.mtudisc_lowat
1584is used when we have unverified ICMPv6 too big messages.
1585Verification is performed by using address/port pairs kept in connected pcbs.
1586Negative value disables the upper limit.
1587.It Li icmp6.nd6_debug
1588If set to non-zero, kernel IPv6 neighbor discovery code will generate
1589debugging messages.
1590The debug outputs are useful to diagnose IPv6 interoperability issues.
1591The flag must be set to 0 for normal operation.
1592.It Li icmp6.nd6_delay
1593The variable specifies
1594.Dv DELAY_FIRST_PROBE_TIME
1595timing constant in IPv6 neighbor discovery specification
1596.Pq RFC 2461 ,
1597in seconds.
1598.It Li icmp6.nd6_maxnudhint
1599IPv6 neighbor discovery permits upper layer protocols to supply reachability
1600hints, to avoid unnecessary neighbor discovery exchanges.
1601The variable defines the number of consecutive hints the neighbor discovery
1602layer will take.
1603For example, by setting the variable to 3, neighbor discovery layer
1604will take 3 consecutive hints in maximum.
1605After receiving 3 hints, neighbor discovery layer will perform
1606normal neighbor discovery process.
1607.It Li icmp6.nd6_mmaxtries
1608The variable specifies
1609.Dv MAX_MULTICAST_SOLICIT
1610constant in IPv6 neighbor discovery specification
1611.Pq RFC 2461 .
1612.It Li icmp6.nd6_prune
1613The variable specifies interval between IPv6 neighbor cache babysitting,
1614in seconds.
1615.It Li icmp6.nd6_umaxtries
1616The variable specifies
1617.Dv MAX_UNICAST_SOLICIT
1618constant in IPv6 neighbor discovery specification
1619.Pq RFC 2461 .
1620.It Li icmp6.nd6_useloopback
1621If set to non-zero, kernel IPv6 stack will use loopback interface for
1622local traffic.
1623.It Li icmp6.nodeinfo
1624The variable enables responses to ICMPv6 node information queries.
1625If you set the variable to 0, responses will not be generated for
1626ICMPv6 node information queries.
1627Since node information queries can have a security impact, it is
1628possible to fine tune which responses should be answered.
1629Two separate bits can be set.
1630.Bl -tag -width "12345"
1631.It 1
1632Respond to ICMPv6 FQDN queries, e.g.
1633.Li ping6 -w .
1634.It 2
1635Respond to ICMPv6 node addresses queries, e.g.
1636.Li ping6 -a .
1637.El
1638.It Li icmp6.rediraccept
1639If set to non-zero, the host will accept ICMPv6 redirect packets.
1640Note that IPv6 routers will never accept ICMPv6 redirect packets,
1641and the variable is meaningful on IPv6 hosts
1642.Pq non-router
1643only.
1644.It Li icmp6.redirtimeout
1645The variable specifies lifetime of routing entries generated by incoming
1646ICMPv6 redirect.
1647.It Li udp6.do_loopback_cksum
1648Perform UDP checksum on loopback.
1649.It Li udp6.recvspace
1650Default UDP receive buffer size.
1651.It Li udp6.sendspace
1652Default UDP send buffer size.
1653.El
1654.Pp
1655We reuse net.*.tcp for
1656.Tn TCP
1657over
1658.Tn IPv6 ,
1659and therefore we do not have variables net.*.tcp6.
1660Variables net.inet6.udp6 have identical meaning to net.inet.udp.
1661Please refer to
1662.Li PF_INET
1663section above.
1664For variables net.*.ipsec6, please refer to
1665.Xr ipsec 4 .
1666.It Li PF_KEY
1667Get or set various global information about the IPsec key management.
1668The third level name is the variable name.
1669The currently defined variable and names are:
1670.Bl -column "blockacq_lifetime" "integer" "yes" -offset indent
1671.It Sy Variable name	Type	Changeable
1672.It debug	integer	yes
1673.It spi_try	integer	yes
1674.It spi_min_value	integer	yes
1675.It spi_max_value	integer	yes
1676.It larval_lifetime	integer	yes
1677.It blockacq_count	integer	yes
1678.It blockacq_lifetime	integer	yes
1679.It esp_keymin	integer	yes
1680.It esp_auth	integer	yes
1681.It ah_keymin	integer	yes
1682.El
1683The variables are as follows:
1684.Bl -tag -width "123456"
1685.It Li debug
1686Turn on debugging message from within the kernel.
1687The value is a bitmap, as defined in
1688.Pa /usr/include/netkey/key_debug.h .
1689.It Li spi_try
1690The number of times the kernel will try to obtain an unique SPI
1691when it generates it from random number generator.
1692.It Li spi_min_value
1693Minimum SPI value when generating it within the kernel.
1694.It Li spi_max_value
1695Maximum SPI value when generating it within the kernel.
1696.It Li larval_lifetime
1697Lifetime for LARVAL SAD entries, in seconds.
1698.It Li blockacq_count
1699Number of ACQUIRE PF_KEY messages to be blocked after an ACQUIRE message.
1700It avoids flood of ACQUIRE PF_KEY from being sent from the kernel to the
1701key management daemon.
1702.It Li blockacq_lifetime
1703Lifetime of ACQUIRE PF_KEY message.
1704.It Li esp_keymin
1705Minimum ESP key length, in bits.
1706The value is used when the kernel creates proposal payload
1707on ACQUIRE PF_KEY message.
1708.It Li esp_auth
1709Whether ESP authentication should be used or not.
1710Non-zero value indicates that ESP authentication should be used.
1711The value is used when the kernel creates proposal payload
1712on ACQUIRE PF_KEY message.
1713.It Li ah_keymin
1714Minimum AH key length, in bits,
1715The value is used when the kernel creates proposal payload
1716on ACQUIRE PF_KEY message.
1717.El
1718.El
1719.Sh CTL_PROC
1720The string and integer information available for the CTL_PROC
1721is detailed below.
1722The changeable column shows whether a process with appropriate
1723privilege may change the value.
1724These values are per-process,
1725and as such may change from one process to another.
1726When a process is created,
1727the default values are inherited from its parent.
1728When a set-user-ID or set-group-ID binary is executed, the
1729value of PROC_PID_CORENAME is reset to the system default value.
1730The second level name is either the magic value PROC_CURPROC, which
1731points to the current process, or the PID of the target process.
1732.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" "yes" -offset indent
1733.It Sy Third level name	Type	Changeable
1734.It PROC\_PID\_CORENAME	string	yes
1735.It PROC\_PID\_LIMIT	node	not applicable
1736.It PROC\_PID\_STOPFORK	int	yes
1737.It PROC\_PID\_STOPEXEC	int	yes
1738.It PROC\_PID\_STOPEXIT	int	yes
1739.El
1740.Bl -tag -width "123456"
1741.Pp
1742.It Li PROC_PID_CORENAME
1743The template used for the core dump file name (see
1744.Xr core 5
1745for details).
1746The base name must either be
1747.Nm core
1748or end with the suffix ``.core'' (the super-user may set arbitrary names).
1749By default it points to KERN_DEFCORENAME.
1750.It Li PROC_PID_LIMIT
1751Return resources limits, as defined for the
1752.Xr getrlimit 2
1753and
1754.Xr setrlimit 2
1755system calls.
1756The fourth level name is one of:
1757.Bl -tag -width PROC_PID_LIMIT_MEMLOCKAA
1758.It Li PROC_PID_LIMIT_CPU
1759The maximum amount of CPU time (in seconds) to be used by each process.
1760.It Li PROC_PID_LIMIT_FSIZE
1761The largest size (in bytes) file that may be created.
1762.It Li PROC_PID_LIMIT_DATA
1763The maximum size (in bytes) of the data segment for a process;
1764this defines how far a program may extend its break with the
1765.Xr sbrk 2
1766system call.
1767.It Li PROC_PID_LIMIT_STACK
1768The maximum size (in bytes) of the stack segment for a process;
1769this defines how far a program's stack segment may be extended.
1770Stack extension is performed automatically by the system.
1771.It Li PROC_PID_LIMIT_CORE
1772The largest size (in bytes)
1773.Pa core
1774file that may be created.
1775.It Li PROC_PID_LIMIT_RSS
1776The maximum size (in bytes) to which a process's resident set size may
1777grow.
1778This imposes a limit on the amount of physical memory to be given to
1779a process; if memory is tight, the system will prefer to take memory
1780from processes that are exceeding their declared resident set size.
1781.It Li PROC_PID_LIMIT_MEMLOCK
1782The maximum size (in bytes) which a process may lock into memory
1783using the
1784.Xr mlock 2
1785function.
1786.It Li PROC_PID_LIMIT_NPROC
1787The maximum number of simultaneous processes for this user id.
1788.It Li PROC_PID_LIMIT_NOFILE
1789The maximum number of open files for this process.
1790.El
1791.Pp
1792The fifth level name is one of PROC_PID_LIMIT_TYPE_SOFT or
1793PROC_PID_LIMIT_TYPE_HARD, to select respectively the soft or hard limit.
1794Both are of type integer.
1795.It Li PROC_PID_STOPFORK
1796If non zero, the process' children will be stopped after
1797.Xr fork 2
1798calls.
1799The children is created in the SSTOP state and is never scheduled
1800for running before being stopped.
1801This feature helps attaching a process with a debugger such as
1802.Xr gdb 1
1803before it had the opportunity to actually do anything.
1804.Pp
1805This value is inherited by the process's children, and it also
1806apply to emulation specific system calls that fork a new process, such as
1807.Fn sproc
1808or
1809.Fn clone .
1810.It Li PROC_PID_STOPEXEC
1811If non zero, the process will be stopped on next
1812.Xr exec 3
1813call.
1814The process created by
1815.Xr exec 3
1816is created in the SSTOP state and is never scheduled for running
1817before being stopped.
1818This feature helps attaching a process with a debugger such as
1819.Xr gdb 1
1820before it had the opportunity to actually do anything.
1821.Pp
1822This value is inherited by the process's children.
1823.It Li PROC_PID_STOPEXIT
1824If non zero, the process will be stopped on when it has cause to exit,
1825either by way of calling
1826.Xr exit 3 ,
1827.Xr _exit 2 ,
1828or by the receipt of a specific signal.
1829The process is stopped before any of its resources or vm space is
1830released allowing examination of the termination state of a process
1831before it disappears.
1832This feature can be used to examine the final conditions of the
1833process's vmspace via
1834.Xr pmap 1
1835or its resource settings with
1836.Xr sysctl 8
1837before it disappears.
1838.Pp
1839This value is also inherited by the process's children.
1840.El
1841.Sh CTL_USER
1842The string and integer information available for the CTL_USER level
1843is detailed below.
1844The changeable column shows whether a process with appropriate
1845privilege may change the value.
1846.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
1847.It Sy Second level name	Type	Changeable
1848.It USER\_BC\_BASE\_MAX	integer	no
1849.It USER\_BC\_DIM\_MAX	integer	no
1850.It USER\_BC\_SCALE\_MAX	integer	no
1851.It USER\_BC\_STRING\_MAX	integer	no
1852.It USER\_COLL\_WEIGHTS\_MAX	integer	no
1853.It USER\_CS\_PATH	string	no
1854.It USER\_EXPR\_NEST\_MAX	integer	no
1855.It USER\_LINE\_MAX	integer	no
1856.It USER\_POSIX2\_CHAR\_TERM	integer	no
1857.It USER\_POSIX2\_C\_BIND	integer	no
1858.It USER\_POSIX2\_C\_DEV	integer	no
1859.It USER\_POSIX2\_FORT\_DEV	integer	no
1860.It USER\_POSIX2\_FORT\_RUN	integer	no
1861.It USER\_POSIX2\_LOCALEDEF	integer	no
1862.It USER\_POSIX2\_SW\_DEV	integer	no
1863.It USER\_POSIX2\_UPE	integer	no
1864.It USER\_POSIX2\_VERSION	integer	no
1865.It USER\_RE\_DUP\_MAX	integer	no
1866.It USER\_STREAM\_MAX	integer	no
1867.It USER\_TZNAME\_MAX	integer	no
1868.It USER\_ATEXIT\_MAX	integer	no
1869.El
1870.Bl -tag -width "123456"
1871.Pp
1872.It Li USER_BC_BASE_MAX
1873The maximum ibase/obase values in the
1874.Xr bc 1
1875utility.
1876.It Li USER_BC_DIM_MAX
1877The maximum array size in the
1878.Xr bc 1
1879utility.
1880.It Li USER_BC_SCALE_MAX
1881The maximum scale value in the
1882.Xr bc 1
1883utility.
1884.It Li USER_BC_STRING_MAX
1885The maximum string length in the
1886.Xr bc 1
1887utility.
1888.It Li USER_COLL_WEIGHTS_MAX
1889The maximum number of weights that can be assigned to any entry of
1890the LC_COLLATE order keyword in the locale definition file.
1891.It Li USER_CS_PATH
1892Return a value for the
1893.Ev PATH
1894environment variable that finds all the standard utilities.
1895.It Li USER_EXPR_NEST_MAX
1896The maximum number of expressions that can be nested within
1897parenthesis by the
1898.Xr expr 1
1899utility.
1900.It Li USER_LINE_MAX
1901The maximum length in bytes of a text-processing utility's input
1902line.
1903.It Li USER_POSIX2_CHAR_TERM
1904Return 1 if the system supports at least one terminal type capable of
1905all operations described in POSIX 1003.2, otherwise 0.
1906.It Li USER_POSIX2_C_BIND
1907Return 1 if the system's C-language development facilities support the
1908C-Language Bindings Option, otherwise 0.
1909.It Li USER_POSIX2_C_DEV
1910Return 1 if the system supports the C-Language Development Utilities Option,
1911otherwise 0.
1912.It Li USER_POSIX2_FORT_DEV
1913Return 1 if the system supports the FORTRAN Development Utilities Option,
1914otherwise 0.
1915.It Li USER_POSIX2_FORT_RUN
1916Return 1 if the system supports the FORTRAN Runtime Utilities Option,
1917otherwise 0.
1918.It Li USER_POSIX2_LOCALEDEF
1919Return 1 if the system supports the creation of locales, otherwise 0.
1920.It Li USER_POSIX2_SW_DEV
1921Return 1 if the system supports the Software Development Utilities Option,
1922otherwise 0.
1923.It Li USER_POSIX2_UPE
1924Return 1 if the system supports the User Portability Utilities Option,
1925otherwise 0.
1926.It Li USER_POSIX2_VERSION
1927The version of POSIX 1003.2 with which the system attempts to comply.
1928.It Li USER_RE_DUP_MAX
1929The maximum number of repeated occurrences of a regular expression
1930permitted when using interval notation.
1931.ne 1i
1932.It Li USER_STREAM_MAX
1933The minimum maximum number of streams that a process may have open
1934at any one time.
1935.It Li USER_TZNAME_MAX
1936The minimum maximum number of types supported for the name of a
1937timezone.
1938.It Li USER_ATEXIT_MAX
1939The maximum number of functions that may be registered with
1940.Xr atexit 3 .
1941.El
1942.Sh CTL_VM
1943The string and integer information available for the CTL_VM level
1944is detailed below.
1945The changeable column shows whether a process with appropriate
1946privilege may change the value.
1947.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
1948.It Sy Second level name	Type	Changeable
1949.It VM\_ANONMAX	int	yes
1950.It VM\_ANONMIN	int	yes
1951.It VM\_BUFCACHE	int	yes
1952.It VM\_BUFMEM	int	no
1953.It VM\_BUFMEM_HIWATER	int	yes
1954.It VM\_BUFMEM_LOWATER	int	yes
1955.It VM\_EXECMAX	int	yes
1956.It VM\_EXECMIN	int	yes
1957.It VM\_FILEMAX	int	yes
1958.It VM\_FILEMIN	int	yes
1959.It VM\_LOADAVG	struct loadavg	no
1960.It VM\_MAXSLP	int	no
1961.It VM\_METER	struct vmtotal	no
1962.It VM\_NKMEMPAGES	int	no
1963.It VM\_USPACE	int	no
1964.It VM\_UVMEXP	struct uvmexp	no
1965.It VM\_UVMEXP2	struct uvmexp_sysctl	no
1966.El
1967.Pp
1968.Bl -tag -width "123456"
1969.It Li VM_ANONMAX
1970The percentage of physical memory which will be reclaimed
1971from other types of memory usage to store anonymous application data.
1972.It Li VM_ANONMIN
1973The percentage of physical memory which will be always be available for
1974anonymous application data.
1975.It Li VM_BUFCACHE
1976The percentage of kernel memory which will be available
1977for the buffer cache.
1978.It Li VM_BUFMEM
1979The amount of kernel memory that is being used by the buffer cache.
1980.It Li VM_BUFMEM_LOWATER
1981The minimum amount of kernel memory to reserve for the
1982buffer cache.
1983.It Li VM_BUFMEM_HIWATER
1984The maximum amount of kernel memory to be used for the
1985buffer cache.
1986.It Li VM_EXECMAX
1987The percentage of physical memory which will be reclaimed
1988from other types of memory usage to store cached executable data.
1989.It Li VM_EXECMIN
1990The percentage of physical memory which will be always be available for
1991cached executable data.
1992.It Li VM_FILEMAX
1993The percentage of physical memory which will be reclaimed
1994from other types of memory usage to store cached file data.
1995.It Li VM_FILEMIN
1996The percentage of physical memory which will be always be available for
1997cached file data.
1998.It Li VM_LOADAVG
1999Return the load average history.
2000The returned data consists of a
2001.Va struct loadavg .
2002.It Li VM_MAXSLP
2003The value of the maxslp kernel global variable.
2004.It Li VM_METER
2005Return system wide virtual memory statistics.
2006The returned data consists of a
2007.Va struct vmtotal .
2008.It Li VM_USPACE
2009The number of bytes allocated for each kernel stack.
2010.It Li VM_UVMEXP
2011Return system wide virtual memory statistics.
2012The returned data consists of a
2013.Va struct uvmexp .
2014.It Li VM_UVMEXP2
2015Return system wide virtual memory statistics.
2016The returned data consists of a
2017.Va struct uvmexp_sysctl .
2018.El
2019.Sh CTL_DDB
2020The integer information available for the CTL_DDB level is detailed below.
2021The changeable column shows whether a process with appropriate
2022privilege may change the value.
2023.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
2024.It Sy Second level name	Type	Changeable
2025.It DBCTL\_RADIX	integer	yes
2026.It DBCTL\_MAXOFF	integer	yes
2027.It DBCTL\_LINES	integer	yes
2028.It DBCTL\_TABSTOPS	integer	yes
2029.It DBCTL\_ONPANIC	integer	yes
2030.It DBCTL\_FROMCONSOLE	integer	yes
2031.El
2032.Pp
2033.Bl -tag -width "123456"
2034.It Li DBCTL_RADIX
2035The input and output radix.
2036.It Li DBCTL_MAXOFF
2037The maximum symbol offset.
2038.It Li DBCTL_LINES
2039Number of display lines.
2040.It Li DBCTL_TABSTOPS
2041Tab width.
2042.It Li DBCTL_ONPANIC
2043If non-zero, DDB will be entered when the kernel panics.
2044.It Li DBCTL_FROMCONSOLE
2045If not zero, DDB may be entered by sending a break on a serial
2046console or by a special key sequence on a graphics console.
2047.El
2048.Pp
2049These MIB nodes are also available as variables from within the DDB.
2050See
2051.Xr ddb 4
2052for more details.
2053.Sh CTL_SECURITY
2054The security level contains various security-related settings for
2055the system. Available settings are detailed below.
2056.Pp
2057.Bl -tag -width "123456"
2058.It Li security.curtain
2059If non-zero, will filter return objects according to the user-id
2060requesting information about them, preventing from users any
2061access to objects they don't own.
2062.Pp
2063At the moment, it affects
2064.Xr ps 1 ,
2065.Xr netstat 1
2066(for
2067.Dv PF_INET ,
2068.Dv PF_INET6 ,
2069and
2070.Dv PF_UNIX
2071PCBs), and
2072.Xr w 1 .
2073.It Li security.pax
2074Settings for PaX -- exploit mitigation features.
2075.Pp
2076.Bl -tag -width "123456"
2077.It Li security.pax.mprotect.enable
2078Enable PaX MPROTECT restrictions.
2079.Pp
2080These are
2081.Xr mprotect 2
2082restrictions to better enforce a W^X policy. The value of this
2083knob must be non-zero for PaX MPROTECT to be enabled, even if a
2084process is already marked with
2085.Em P_PAXMPROTECT .
2086.It Li security.pax.mprotect.global
2087Specifies the default global policy for programs without an
2088explicit enable/disable flag.
2089.Pp
2090When non-zero, all programs will get the PaX MPROTECT restrictions,
2091except those exempted with
2092.Xr paxctl 1  .
2093Otherwise, all programs will not get the PaX MPROTECT restrictions,
2094except those specifically marked as such with
2095.Xr paxctl 1 .
2096.El
2097.El
2098.Sh CTL_VENDOR
2099The "vendor" toplevel name is reserved to be used by vendors who wish to
2100have their own private MIB tree.
2101Intended use is to store values under
2102.Dq vendor.\*[Lt]yourname\*[Gt].* .
2103.Sh DYNAMIC OPERATIONS
2104Several meta-identifiers are provided to perform operations on the
2105.Nm
2106tree itself, or support alternate means of accessing the data
2107instrumented by the
2108.Nm
2109tree.
2110.Bl -column CTLXCREATESYMXXX
2111.It Sy Name	Description
2112.It CTL\_QUERY	Retrieve a mapping of names to numbers below a given node
2113.It CTL\_CREATE	Create a new node
2114.It CTL\_CREATESYM	Create a new node by its kernel symbol
2115.It CTL\_DESTROY	Destroy a node
2116.It CTL\_DESCRIBE	Retrieve node descriptions
2117.El
2118.Pp
2119The core interface to all of these meta-functions is the structure
2120that the kernel uses to describe the tree internally, as defined in
2121.Aq Pa sys/sysctl.h
2122as:
2123.Pp
2124.Bd -literal
2125struct sysctlnode {
2126        uint32_t sysctl_flags;          /* flags and type */
2127        int32_t sysctl_num;             /* mib number */
2128        char sysctl_name[SYSCTL_NAMELEN]; /* node name */
2129        uint32_t sysctl_ver;        /* node's version vs. rest of tree */
2130        uint32_t __rsvd;
2131        union {
2132                struct {
2133                        uint32_t suc_csize; /* size of child node array */
2134                        uint32_t suc_clen; /* number of valid children */
2135                        struct sysctlnode* suc_child; /* array of child nodes */
2136                } scu_child;
2137                struct {
2138                        void *sud_data; /* pointer to external data */
2139                        size_t sud_offset; /* offset to data */
2140                } scu_data;
2141                int32_t scu_alias;      /* node this node refers to */
2142                int32_t scu_idata;      /* immediate "int" data */
2143                u_quad_t scu_qdata;     /* immediate "u_quad_t" data */
2144        } sysctl_un;
2145        size_t _sysctl_size;            /* size of instrumented data */
2146        sysctlfn _sysctl_func;          /* access helper function */
2147        struct sysctlnode *sysctl_parent; /* parent of this node */
2148        const char *sysctl_desc;        /* description of node */
2149};
2150
2151#define sysctl_csize    sysctl_un.scu_child.suc_csize
2152#define sysctl_clen     sysctl_un.scu_child.suc_clen
2153#define sysctl_child    sysctl_un.scu_child.suc_child
2154#define sysctl_data     sysctl_un.scu_data.sud_data
2155#define sysctl_offset   sysctl_un.scu_data.sud_offset
2156#define sysctl_alias    sysctl_un.scu_alias
2157#define sysctl_idata    sysctl_un.scu_idata
2158#define sysctl_qdata    sysctl_un.scu_qdata
2159.Ed
2160.Pp
2161Querying the tree to discover the name to number mapping permits
2162dynamic discovery of all the data that the tree currently has
2163instrumented.
2164For example, to discover all the nodes below the
2165CTL_VFS node:
2166.Pp
2167.Bd -literal -offset indent -compact
2168struct sysctlnode query, vfs[128];
2169int mib[2];
2170size_t len;
2171.sp
2172mib[0] = CTL_VFS;
2173mib[1] = CTL_QUERY;
2174memset(\*[Am]query, 0, sizeof(query));
2175query.sysctl_flags = SYSCTL_VERSION;
2176len = sizeof(vfs);
2177sysctl(mib, 2, \*[Am]vfs[0], \*[Am]len, \*[Am]query, sizeof(query));
2178.Ed
2179.Pp
2180Note that a reference to an empty node with
2181.Fa sysctl_flags
2182set to
2183.Dv SYSCTL_VERSION
2184is passed to sysctl in order to indicate the version that the program
2185is using.
2186All dynamic operations passing nodes into sysctl require that the
2187version be explicitly specified.
2188.Pp
2189Creation and destruction of nodes works by constructing part of a new
2190node description (or a description of the existing node) and invoking
2191CTL_CREATE (or CTL_CREATESYM) or CTL_DESTROY at the parent of the new
2192node, with a pointer to the new node passed via the
2193.Fa new
2194and
2195.Fa newlen
2196arguments.
2197If valid values for
2198.Fa old
2199and
2200.Fa oldlenp
2201are passed, a copy of the new node once in the tree will be returned.
2202If the create operation fails because a node with the same name or MIB
2203number exists, a copy of the conflicting node will be returned.
2204.Pp
2205The minimum requirements for creating a node are setting the
2206.Fa sysctl_flags
2207to indicate the new node's type,
2208.Fa sysctl_num
2209to either the new node's number (or CTL_CREATE or CTL_CREATESYM if a
2210dynamically allocated MIB number is acceptable),
2211.Fa sysctl_size
2212to the size of the data to be instrumented (which must agree with the
2213given type), and
2214.Fa sysctl_name
2215must be set to the new node's name.
2216Nodes that are not of type
2217.Dq node
2218must also have some description of the data to be instrumented, which
2219will vary depending on what is to be instrumented.
2220.Pp
2221If existing kernel data is to be covered by this new node, its address
2222should be given in
2223.Fa sysctl_data
2224or, if CTL_CREATESYM is used,
2225.Fa sysctl_data
2226should be set to a string containing its name from the kernel's symbol
2227table.
2228If new data is to be instrumented and an initial value is available,
2229the new integer or quad type data should be placed into either
2230.Fa sysctl_idata
2231or
2232.Fa sysctl_qdata ,
2233respectively, along with the SYSCTL_IMMEDIATE flag being set, or
2234.Fa sysctl_data
2235should be set to point to a copy of the new data, and the
2236SYSCTL_OWNDATA flag must be set.
2237This latter method is the only way that new string and struct type
2238nodes can be initialized.
2239Invalid kernel addresses are accepted, but any attempt to access those
2240nodes will return an error.
2241.Pp
2242The
2243.Fa sysctl_csize ,
2244.Fa sysctl_clen ,
2245.Fa sysctl_child ,
2246.Fa sysctl_parent ,
2247and
2248.Fa sysctl_alias
2249members are used by the kernel to link the tree together and must be
2250.Dv NULL
2251or 0.
2252Nodes created in this manner cannot have helper functions, so
2253.Fa sysctl_func
2254must also be
2255.Dv NULL .
2256If the
2257.Fa sysctl_ver
2258member is non-zero, it must match either the version of the parent or
2259the version at the root of the MIB or an error is returned.
2260This can be used to ensure that nodes are only added or removed from a
2261known state of the tree.
2262Note: It may not be possible to determine the version at the root
2263of the tree.
2264.Pp
2265This example creates a new subtree and adds a node to it that controls the
2266.Fa audiodebug
2267kernel variable, thereby making it tunable at at any time, without
2268needing to use
2269.Xr ddb 4
2270or
2271.Xr kvm 3
2272to alter the kernel's memory directly.
2273.Pp
2274.Bd -literal -offset indent -compact
2275struct sysctlnode node;
2276int mib[2];
2277size_t len;
2278.sp
2279mib[0] = CTL_CREATE;		/* create at top-level */
2280len = sizeof(node);
2281memset(\*[Am]node, 0, len);
2282node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_NODE;
2283snprintf(node.sysctl_name, sizeof(node.sysctl_name), "local");
2284node.sysctl_num = CTL_CREATE;	/* request dynamic MIB number */
2285sysctl(\*[Am]mib[0], 1, \*[Am]node, \*[Am]len, \*[Am]node, len);
2286.sp
2287mib[0] = node.sysctl_num;	/* use new MIB number */
2288mib[1] = CTL_CREATESYM;		/* create at second level */
2289len = sizeof(node);
2290memset(\*[Am]node, 0, len);
2291node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_INT;
2292snprintf(node.sysctl_name, sizeof(node.sysctl_name), "audiodebug");
2293node.sysctl_num = CTL_CREATE;
2294node.sysctl_data = "audiodebug"; /* kernel symbol to be used */
2295sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len);
2296.Ed
2297.Pp
2298The process for deleting nodes is similar, but less data needs to
2299be supplied.
2300Only the
2301.Fa sysctl_num
2302field
2303needs to be filled in; almost all other fields must be left blank.
2304The
2305.Fa sysctl_name
2306and/or
2307.Fa sysctl_ver
2308fields can be filled in with the name and version of the existing node
2309as additional checks on what will be deleted.
2310If all the given data fail to match any node, nothing will be deleted.
2311If valid values for
2312.Fa old
2313and
2314.Fa oldlenp
2315are supplied and a node is deleted, a copy of what was in the MIB tree
2316will be returned.
2317.Pp
2318This sample code shows the deletion of the two nodes created in the
2319above example:
2320.Pp
2321.Bd -literal -offset indent -compact
2322int mib[2];
2323.sp
2324len = sizeof(node);
2325memset(\*[Am]node, 0, len);
2326node.sysctl_flags = SYSCTL_VERSION;
2327.sp
2328mib[0] = 3214;			/* assumed number for "local" */
2329mib[1] = CTL_DESTROY;
2330node.sysctl_num = 3215;		/* assumed number for "audiodebug" */
2331sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len);
2332.sp
2333mib[0] = CTL_DESTROY;
2334node.sysctl_num = 3214;		/* now deleting "local" */
2335sysctl(\*[Am]mib[0], 1, NULL, NULL, \*[Am]node, len);
2336.Ed
2337.Pp
2338Descriptions of each of the nodes can also be retrieved, if they are
2339available.
2340Descriptions can be retrieved in bulk at each level or on a per-node
2341basis.
2342The layout of the buffer into which the descriptions are returned is a
2343series of variable length structures, each of which describes its own
2344size.
2345The length indicated includes the terminating
2346.Sq nul
2347character.
2348Nodes that have no description or where the description is not
2349available are indicated by an empty string.
2350The
2351.Fa descr_ver
2352will match the
2353.Fa sysctl_ver
2354value for a given node, so that descriptions for nodes whose number
2355have been recycled can be detected and ignored or discarded.
2356.Pp
2357.Bd -literal
2358struct sysctldesc {
2359        int32_t         descr_num;      /* mib number of node */
2360        uint32_t        descr_ver;      /* version of node */
2361        uint32_t        descr_len;      /* length of description string */
2362        char            descr_str[1];   /* not really 1...see above */
2363};
2364.Ed
2365.Pp
2366The
2367.Fn NEXT_DESCR
2368macro can be used to skip to the next description in the retrieved
2369list.
2370.Pp
2371.Bd -literal -offset indent -compact
2372struct sysctlnode desc;
2373struct sysctldesc *d;
2374char buf[1024];
2375int mib[2];
2376size_t len;
2377.sp
2378/* retrieve kern-level descriptions */
2379mib[0] = CTL_KERN;
2380mib[1] = CTL_DESCRIBE;
2381d = (struct sysctldesc *)\*[Am]buf[0];
2382len = sizeof(buf);
2383sysctl(mib, 2, d, \*[Am]len, NULL, 0);
2384while ((caddr_t)d \*[Lt] (caddr_t)\*[Am]buf[len]) {
2385	printf("node %d: %.*s\\n", d-\*[Gt]descr_num, d-\*[Gt]descr_len,
2386	    d-\*[Gt]descr_str);
2387	d = NEXT_DESCR(d);
2388}
2389.sp
2390/* retrieve description for kern.securelevel */
2391memset(\*[Am]desc, 0, sizeof(desc));
2392desc.sysctl_flags = SYSCTL_VERSION;
2393desc.sysctl_num = KERN_SECURELEVEL;
2394d = (struct sysctldesc *)\*[Am]buf[0];
2395len = sizeof(buf);
2396sysctl(mib, 2, d, \*[Am]len, \*[Am]desc, sizeof(desc));
2397printf("kern.securelevel: %.*s\\n", d-\*[Gt]descr_len, d-\*[Gt]descr_str);
2398.Ed
2399.Pp
2400Descriptions can also be set as follows, subject to the following rules:
2401.Pp
2402.Bl -bullet -compact
2403.It
2404The kernel securelevel is at zero or lower
2405.It
2406The caller has super-user privileges
2407.It
2408The node does not currently have a description
2409.It
2410The node is not marked as
2411.Dq permanent
2412.El
2413.Pp
2414.Bd -literal -offset indent -compact
2415struct sysctlnode desc;
2416int mib[2];
2417.sp
2418/* presuming the given top-level node was just added... */
2419mib[0] = 3214; /* mib numbers taken from previous examples */
2420mib[1] = CTL_DESCRIBE;
2421memset(\*[Am]desc, 0, sizeof(desc));
2422desc.sysctl_flags = SYSCTL_VERSION;
2423desc.sysctl_num = 3215;
2424desc.sysctl_desc = "audio debug control knob";
2425sysctl(mib, 2, NULL, NULL, \*[Am]desc, sizeof(desc));
2426.Ed
2427.Pp
2428Upon successfully setting a description, the new description will be
2429returned in the space indicated by the
2430.Fa oldp
2431and
2432.Fa oldlenp
2433arguments.
2434.Pp
2435The
2436.Fa sysctl_flags
2437field in the struct sysctlnode contains the sysctl version, node type
2438information, and a number of flags.
2439The macros
2440.Fn SYSCTL_VERS ,
2441.Fn SYSCTL_TYPE ,
2442and
2443.Fn SYSCTL_FLAGS
2444can be used to access the different fields.
2445Valid flags are:
2446.Bl -column CTLFLAGXPERMANENTXXX
2447.It Sy Name	Description
2448.It CTLFLAG\_READONLY	Node is read-only
2449.It CTLFLAG\_READONLY1	Node becomes read-only at securelevel 1
2450.It CTLFLAG\_READONLY2	Node becomes read-only at securelevel 2
2451.It CTLFLAG\_READWRITE	Node is writable by the superuser
2452.It CTLFLAG\_ANYWRITE	Node is writable by anyone
2453.It CTLFLAG\_PRIVATE	Node is readable only by the superuser
2454.It CTLFLAG\_PERMANENT	Node cannot be removed (cannot be set by
2455processes)
2456.It CTLFLAG\_OWNDATA	Node owns data and does not instrument
2457existing data
2458.It CTLFLAG\_IMMEDIATE	Node contains instrumented data and does not
2459instrument existing data
2460.It CTLFLAG\_HEX	Node's contents should be displayed in a hexadecimal
2461form
2462.It CTLFLAG\_ROOT	Node is the root of a tree (cannot be set at
2463any time)
2464.It CTLFLAG\_ANYNUMBER	Node matches any MIB number (cannot be set by
2465processes)
2466.It CTLFLAG\_HIDDEN	Node not displayed by default
2467.It CTLFLAG\_ALIAS	Node refers to a sibling node (cannot be set
2468by processes)
2469.It CTLFLAG\_OWNDESC	Node owns its own description string space
2470.El
2471.Sh RETURN VALUES
2472If the call to
2473.Nm
2474is successful, the number of bytes copied out is returned.
2475Otherwise \-1 is returned and
2476.Va errno
2477is set appropriately.
2478.Sh FILES
2479.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact
2480.It Aq Pa sys/sysctl.h
2481definitions for top level identifiers, second level kernel and hardware
2482identifiers, and user level identifiers
2483.It Aq Pa sys/socket.h
2484definitions for second level network identifiers
2485.It Aq Pa sys/gmon.h
2486definitions for third level profiling identifiers
2487.It Aq Pa uvm/uvm_param.h
2488definitions for second level virtual memory identifiers
2489.It Aq Pa netinet/in.h
2490definitions for third level IPv4/v6 identifiers and
2491fourth level IPv4/v6 identifiers
2492.It Aq Pa netinet/icmp_var.h
2493definitions for fourth level ICMP identifiers
2494.It Aq Pa netinet/icmp6.h
2495definitions for fourth level ICMPv6 identifiers
2496.It Aq Pa netinet/tcp_var.h
2497definitions for fourth level TCP identifiers
2498.It Aq Pa netinet/udp_var.h
2499definitions for fourth level UDP identifiers
2500.It Aq Pa netinet6/udp6_var.h
2501definitions for fourth level IPv6 UDP identifiers
2502.It Aq Pa netinet6/ipsec.h
2503definitions for fourth level IPsec identifiers
2504.It Aq Pa netkey/key_var.h
2505definitions for third level PF_KEY identifiers
2506.It Aq Pa machine/cpu.h
2507definitions for second level machdep identifiers
2508.El
2509.Sh ERRORS
2510The following errors may be reported:
2511.Bl -tag -width Er
2512.It Bq Er EFAULT
2513The buffer
2514.Fa name ,
2515.Fa oldp ,
2516.Fa newp ,
2517or length pointer
2518.Fa oldlenp
2519contains an invalid address, or the requested value is temporarily
2520unavailable.
2521.It Bq Er EINVAL
2522The
2523.Fa name
2524array is zero or greater than CTL_MAXNAME.
2525.It Bq Er EINVAL
2526A non-null
2527.Fa newp
2528is given and its specified length in
2529.Fa newlen
2530is too large or too small, or the given value is not acceptable for
2531the given node.
2532.It Bq Er ENOMEM
2533The length pointed to by
2534.Fa oldlenp
2535is too short to hold the requested value.
2536.It Bq Er EISDIR
2537The
2538.Fa name
2539array specifies an intermediate rather than terminal name.
2540.It Bq Er ENOTDIR
2541The
2542.Fa name
2543array specifies a node below a node that addresses data.
2544.It Bq Er ENOENT
2545The
2546.Fa name
2547array specifies a node that does not exist in the tree.
2548.It Bq Er ENOENT
2549An attempt was made to destroy a node that does not exist, or to
2550create or destroy a node below a node that does not exist.
2551.It Bq Er ENOTEMPTY
2552An attempt was made to destroy a node that still has children.
2553.It Bq Er EOPNOTSUPP
2554The
2555.Fa name
2556array specifies a value that is unknown or a meta-operation was
2557attempted that the requested node does not support.
2558.It Bq Er EPERM
2559An attempt is made to set a read-only value.
2560.It Bq Er EPERM
2561A process without appropriate privilege attempts to set a value or to
2562create or destroy a node.
2563.It Bq Er EPERM
2564An attempt to change a value protected by the current kernel security
2565level is made.
2566.El
2567.Sh SEE ALSO
2568.Xr ipsec 4 ,
2569.Xr tcp 4 ,
2570.Xr sysctl 8
2571.\" .Xr sysctl 9
2572.Sh HISTORY
2573The
2574.Nm
2575function first appeared in
2576.Bx 4.4 .
2577