xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision d48f14661dda8638fee055ba15d35bdfb29b9fa8)
1.\"	$NetBSD: sysctl.3,v 1.170 2006/05/16 00:08:24 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 April 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 Verified Exec.
938Third level names for the veriexec variables are detailed below.
939The changeable column shows whether a process with appropriate
940privilege may change 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 Verified Exec.
954.It Li VERIEXEC_COUNT
955Variables are added to this node as new hash tables are created to
956contain Verified Exec data for a new device.
957Each variable in the node
958will have a name in the form of
959.No dev_ Ns Aq id
960where
961.Aq id
962is the device id.
963For example, the variable for the root device may be dev_0.
964The value of this
965variable will be the amount of fingerprinted files on the device.
966.It Li VERIEXEC_STRICT
967Controls the strict level of Verified Exec.
968The strict level defines how
969Verified Exec will treat various situations.
970In strict level 0, the system is in learning mode and will only warn about
971fingerprint mismatches, aswell as allow removal of fingerprinted files.
972It is the only level where fingerprints can be loaded.
973In strict level 1, the system is in IDS mode.
974It will deny access to files with mismatched fingerprints.
975In strict level 2, the system is in IPS mode.
976It has all effects of
977strict level 1, plus it will deny write access to monitored files,
978prevent their removal, and enforce access type (direct, indirect, file).
979Strict level 3 operates as lockdown mode.
980It will have all effects of
981strict level 2, but it will also prevent access to non-monitored files.
982Furthermore, it will prevent addition of new files to the system, and
983allow writing only to files opened before the strict level was raised.
984.It Li VERIEXEC_VERBOSE
985Controls the verbosity level of Verified Exec.
986If 0, only the minimal
987indication required will be given about what's happening - fingerprint
988mismatches, removal of entries from the tables, modification of a
989fingerprinted file.
990If 1, more messages will be printed (ie., when a file with a valid
991fingerprint is accessed).
992Verbose level 2 is debug mode.
993.El
994.It Li KERN_VERSION
995The system version string.
996.It Li KERN_VNODE
997Return the entire vnode table.
998Note, the vnode table is not necessarily a consistent snapshot of
999the system.
1000The returned data consists of an array whose size depends on the
1001current number of such objects in the system.
1002Each element of the array contains the kernel address of a vnode
1003.Va struct vnode *
1004followed by the vnode itself
1005.Va struct vnode .
1006.El
1007.Sh CTL_MACHDEP
1008The set of variables defined is architecture dependent.
1009Most architectures define at least the following variables.
1010.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
1011.It Sy Second level name	Type	Changeable
1012.It Li CPU_CONSDEV	dev_t	no
1013.El
1014.Sh CTL_NET
1015The string and integer information available for the CTL_NET level
1016is detailed below.
1017The changeable column shows whether a process with appropriate
1018privilege may change the value.
1019The second and third levels are typically the protocol family and
1020protocol number, though this is not always the case.
1021.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
1022.It Sy Second level name	Type	Changeable
1023.It PF\_ROUTE	routing messages	no
1024.It PF\_INET	IPv4 values	yes
1025.It PF\_INET6	IPv6 values	yes
1026.It PF\_KEY	IPsec key management values	yes
1027.El
1028.Pp
1029.Bl -tag -width "123456"
1030.It Li PF_ROUTE
1031Return the entire routing table or a subset of it.
1032The data is returned as a sequence of routing messages (see
1033.Xr route 4
1034for the header file, format and meaning).
1035The length of each message is contained in the message header.
1036.Pp
1037The third level name is a protocol number, which is currently always 0.
1038The fourth level name is an address family, which may be set to 0 to
1039select all address families.
1040The fifth and sixth level names are as follows:
1041.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
1042.It Sy Fifth level name	Sixth level is:
1043.It NET\_RT\_FLAGS	rtflags
1044.It NET\_RT\_DUMP	None
1045.It NET\_RT\_IFLIST	None
1046.El
1047.It Li PF_INET
1048Get or set various global information about the IPv4
1049.Pq Internet Protocol version 4 .
1050The third level name is the protocol.
1051The fourth level name is the variable name.
1052The currently defined protocols and names are:
1053.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
1054.It Sy Protocol name	Variable name	Type	Changeable
1055.It arp	down	integer	yes
1056.It arp	keep	integer	yes
1057.It arp	prune	integer	yes
1058.It arp	refresh	integer	yes
1059.It icmp	errppslimit	integer	yes
1060.It icmp	maskrepl	integer	yes
1061.It icmp	rediraccept	integer	yes
1062.It icmp	redirtimeout	integer	yes
1063.It ip	allowsrcrt	integer	yes
1064.It ip	anonportmax	integer	yes
1065.It ip	anonportmin	integer	yes
1066.It ip	checkinterface	integer	yes
1067.It ip	directed-broadcast	integer	yes
1068.It ip	do_loopback_cksum	integer	yes
1069.It ip	forwarding	integer	yes
1070.It ip	forwsrcrt	integer	yes
1071.It ip	gifttl	integer	yes
1072.It ip	grettl	integer	yes
1073.It ip	hostzerobroadcast	integer	yes
1074.It ip	lowportmin	integer	yes
1075.It ip	lowportmax	integer	yes
1076.It ip	maxfragpackets	integer	yes
1077.It ip	mtudisc	integer	yes
1078.It ip	mtudisctimeout	integer	yes
1079.It ip	random_id	integer	yes
1080.It ip	redirect	integer	yes
1081.It ip	subnetsarelocal	integer	yes
1082.It ip	ttl	integer	yes
1083.It tcp	rfc1323	integer	yes
1084.It tcp	sendspace	integer	yes
1085.It tcp	recvspace	integer	yes
1086.It tcp	mssdflt	integer	yes
1087.It tcp	syn_cache_limit	integer	yes
1088.It tcp	syn_bucket_limit	integer	yes
1089.It tcp	syn_cache_interval	integer	yes
1090.It tcp	init_win	integer	yes
1091.It tcp	init_win_local	integer	yes
1092.It tcp	mss_ifmtu	integer	yes
1093.It tcp	sack	integer	yes
1094.It tcp	win_scale	integer	yes
1095.It tcp	timestamps	integer	yes
1096.It tcp	compat_42	integer	yes
1097.It tcp	cwm	integer	yes
1098.It tcp	cwm_burstsize	integer	yes
1099.It tcp	ack_on_push	integer	yes
1100.It tcp	keepidle	integer	yes
1101.It tcp	keepintvl	integer	yes
1102.It tcp	keepcnt	integer	yes
1103.It tcp	slowhz	integer	no
1104.It tcp	newreno	integer	yes
1105.It tcp	log_refused	integer	yes
1106.It tcp	rstppslimit	integer	yes
1107.It tcp	ident	struct	no
1108.It udp	checksum	integer	yes
1109.It udp	do_loopback_cksum	integer	yes
1110.It udp	recvspace	integer	yes
1111.It udp	sendspace	integer	yes
1112.El
1113.Pp
1114The variables are as follows:
1115.Bl -tag -width "123456"
1116.It Li arp.down
1117Failed ARP entry lifetime.
1118.It Li arp.keep
1119Valid ARP entry lifetime.
1120.It Li arp.prune
1121ARP cache pruning interval.
1122.It Li arp.refresh
1123ARP entry refresh interval.
1124.It Li ip.allowsrcrt
1125If set to 1, the host accepts source routed packets.
1126.It Li ip.anonportmax
1127The highest port number to use for TCP and UDP ephemeral port allocation.
1128This cannot be set to less than 1024 or greater than 65535, and must
1129be greater than
1130.Li ip.anonportmin .
1131.It Li ip.anonportmin
1132The lowest port number to use for TCP and UDP ephemeral port allocation.
1133This cannot be set to less than 1024 or greater than 65535.
1134.It Li ip.checkinterface
1135If set to non-zero, the host will reject packets addressed to it
1136that arrive on an interface not bound to that address.
1137Currently, this must be disabled if ipnat is used to translate the
1138destination address to another local interface, or if addresses
1139are added to the loopback interface instead of the interface where
1140the packets for those packets are received.
1141.It Li ip.directed-broadcast
1142If set to 1, enables directed broadcast behavior for the host.
1143.It Li ip.do_loopback_cksum
1144Perform IP checksum on loopback.
1145.It Li ip.forwarding
1146If set to 1, enables IP forwarding for the host,
1147meaning that the host is acting as a router.
1148.It Li ip.forwsrcrt
1149If set to 1, enables forwarding of source-routed packets for the host.
1150This value may only be changed if the kernel security level is less than 1.
1151.It Li ip.gifttl
1152The maximum time-to-live (hop count) value for an IPv4 packet generated by
1153.Xr gif 4
1154tunnel interface.
1155.It Li ip.grettl
1156The maximum time-to-live (hop count) value for an IPv4 packet generated by
1157.Xr gre 4
1158tunnel interface.
1159.It Li ip.hostzerobroadcast
1160All zeroes address is broadcast address.
1161.It Li ip.lowportmax
1162The highest port number to use for TCP and UDP reserved port allocation.
1163This cannot be set to less than 0 or greater than 1024, and must
1164be greater than
1165.Li ip.lowportmin .
1166.It Li ip.lowportmin
1167The lowest port number to use for TCP and UDP reserved port allocation.
1168This cannot be set to less than 0 or greater than 1024, and must
1169be smaller than
1170.Li ip.lowportmax .
1171.It Li ip.maxfragpackets
1172The maximum number of fragmented packets the node will accept.
11730 means that the node will not accept any fragmented packets.
1174\-1 means that the node will accept as many fragmented packets as it receives.
1175The flag is provided basically for avoiding possible DoS attacks.
1176.It Li ip.mtudisc
1177If set to 1, enables Path MTU Discovery (RFC 1191).
1178When Path MTU Discovery is enabled, the transmitted TCP segment
1179size will be determined by the advertised maximum segment size
1180(MSS) from the remote end, as constrained by the path MTU.
1181If MTU Discovery is disabled, the transmitted segment size will
1182never be greater than
1183.Li tcp.mssdflt
1184(the local maximum segment size).
1185.It Li ip.mtudisctimeout
1186The number of seconds in which a route added by the Path MTU
1187Discovery engine will time out.
1188When the route times out, the Path
1189MTU Discovery engine will attempt to probe a larger path MTU.
1190.It Li ip.random_id
1191Assign random ip_id values.
1192.It Li ip.redirect
1193If set to 1, ICMP redirects may be sent by the host.
1194This option is ignored unless the host is routing IP packets,
1195and should normally be enabled on all systems.
1196.It Li ip.subnetsarelocal
1197If set to 1, subnets are to be considered local addresses.
1198.It Li ip.ttl
1199The maximum time-to-live (hop count) value for an IP packet sourced by
1200the system.
1201This value applies to normal transport protocols, not to ICMP.
1202.It Li icmp.errppslimit
1203The variable specifies the maximum number of outgoing ICMP error messages,
1204per second.
1205ICMP error messages that exceeded the value are subject to rate limitation
1206and will not go out from the node.
1207Negative value disables rate limitation.
1208.It Li icmp.maskrepl
1209If set to 1, ICMP network mask requests are to be answered.
1210.It Li icmp.rediraccept
1211If set to non-zero, the host will accept ICMP redirect packets.
1212Note that routers will never accept ICMP redirect packets,
1213and the variable is meaningful on IP hosts only.
1214.It Li icmp.redirtimeout
1215The variable specifies lifetime of routing entries generated by incoming
1216ICMP redirect.
1217This defaults to 600 seconds.
1218.It Li icmp.returndatabytes
1219Number of bytes to return in an ICMP error message.
1220.It Li tcp.ack_on_push
1221If set to 1, TCP is to immediately transmit an ACK upon reception of
1222a packet with PUSH set.
1223This can avoid losing a round trip time in some rare situations,
1224but has the caveat of potentially defeating TCP's delayed ACK algorithm.
1225Use of this option is generally not recommended, but
1226the variable exists in case your configuration really needs it.
1227.It Li tcp.compat_42
1228If set to 1, enables work-arounds for bugs in the 4.2BSD TCP implementation.
1229Use of this option is not recommended, although it may be
1230required in order to communicate with extremely old TCP implementations.
1231.It Li tcp.cwm
1232If set to 1, enables use of the Hughes/Touch/Heidemann Congestion Window
1233Monitoring algorithm.
1234This algorithm prevents line-rate bursts of packets that could
1235otherwise occur when data begins flowing on an idle TCP connection.
1236These line-rate bursts can contribute to network and router congestion.
1237This can be particularly useful on World Wide Web servers
1238which support HTTP/1.1, which has lingering connections.
1239.It Li tcp.cwm_burstsize
1240The Congestion Window Monitoring allowed burst size, in terms
1241of packet count.
1242.It Li tcp.delack_ticks
1243Number of ticks to delay sending an ACK.
1244.It Li tcp.do_loopback_cksum
1245Perform TCP checksum on loopback.
1246.It Li tcp.init_win
1247A value indicating the TCP initial congestion window.
1248If this value is 0, an auto-tuning algorithm designed to use an initial
1249window of approximately 4K bytes is in use.
1250Otherwise, this value indicates a fixed number of packets.
1251.It Li tcp.init_win_local
1252Like
1253.Li tcp.init_win ,
1254but used when communicating with hosts on a local network.
1255.It Li tcp.keepcnt
1256Number of keepalive probes sent before declaring a connection dead.
1257If set to zero, there is no limit;
1258keepalives will be sent until some kind of
1259response is received from the peer.
1260.It Li tcp.keepidle
1261Time a connection must be idle before keepalives are sent (if keepalives
1262are enabled for the connection).
1263See also tcp.slowhz.
1264.It Li tcp.keepintvl
1265Time after a keepalive probe is sent until, in the absence of any response,
1266another probe is sent.
1267See also tcp.slowhz.
1268.It Li tcp.log_refused
1269If set to 1, refused TCP connections to the host will be logged.
1270.It Li tcp.mss_ifmtu
1271If set to 1, TCP calculates the outgoing maximum segment size based on
1272the MTU of the appropriate interface.
1273If set to 0, it is calculated based on the greater of the MTU of the
1274interface, and the largest (non-loopback) interface MTU on the system.
1275.It Li tcp.mssdflt
1276The default maximum segment size both advertised to the peer
1277and to use when either the peer does not advertise a maximum segment size to
1278us during connection setup or Path MTU Discovery
1279.Li ( ip.mtudisc )
1280is disabled.
1281Do not change this value unless you really know what you are doing.
1282.It Li tcp.newreno
1283If set to 1, enables the use of J.
1284Hoe's NewReno congestion control algorithm.
1285This algorithm improves the start-up behavior of TCP connections.
1286.It Li tcp.recvspace
1287The default TCP receive buffer size.
1288.It Li tcp.rfc1323
1289If set to 1, enables RFC 1323 extensions to TCP.
1290.It Li tcp.rstppslimit
1291The variable specifies the maximum number of outgoing TCP RST packets,
1292per second.
1293TCP RST packet that exceeded the value are subject to rate limitation
1294and will not go out from the node.
1295Negative value disables rate limitation.
1296.It Li tcp.sack.enable
1297If set to 1, enables RFC 2018 Selective ACKnowledgement.
1298.It Li tcp.sack.globalholes
1299Global number of TCP SACK holes.
1300.It Li tcp.sack.globalmaxholes
1301Global maximum number of TCP SACK holes.
1302.It Li tcp.sack.maxholes
1303Maximum number of TCP SACK holes allowed per connection.
1304.It Li tcp.sendspace
1305The default TCP send buffer size.
1306.It Li tcp.slowhz
1307The units for tcp.keepidle and tcp.keepintvl; those variables are in ticks
1308of a clock that ticks tcp.slowhz times per second.
1309(That is, their values
1310must be divided by the tcp.slowhz value to get times in seconds.)
1311.It Li tcp.syn_bucket_limit
1312The maximum number of entries allowed per hash bucket in the TCP
1313compressed state engine.
1314.It Li tcp.syn_cache_limit
1315The maximum number of entries allowed in the TCP compressed state
1316engine.
1317.It Li tcp.timestamps
1318If rfc1323 is enabled, a value of 1 indicates RFC 1323 time stamp options,
1319used for measuring TCP round trip times, are enabled.
1320.It Li tcp.win_scale
1321If rfc1323 is enabled, a value of 1 indicates RFC 1323 window scale options,
1322for increasing the TCP window size, are enabled.
1323.It Li udp.checksum
1324If set to 1, UDP checksums are being computed.
1325Received non-zero UDP checksums are always checked.
1326Disabling UDP checksums is strongly discouraged.
1327.It Li udp.sendspace
1328The default UDP send buffer size.
1329.It Li udp.recvspace
1330The default UDP receive buffer size.
1331.El
1332.Pp
1333For variables net.*.ipsec, please refer to
1334.Xr ipsec 4 .
1335.It Li PF_INET6
1336Get or set various global information about the IPv6
1337.Pq Internet Protocol version 6 .
1338The third level name is the protocol.
1339The fourth level name is the variable name.
1340The currently defined protocols and names are:
1341.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
1342.It Sy Protocol name	Variable name	Type	Changeable
1343.It icmp6	errppslimit	integer	yes
1344.It icmp6	mtudisc_hiwat	integer	yes
1345.It icmp6	mtudisc_lowat	integer	yes
1346.It icmp6	nd6_debug	integer	yes
1347.It icmp6	nd6_delay	integer	yes
1348.It icmp6	nd6_maxnudhint	integer	yes
1349.It icmp6	nd6_mmaxtries	integer	yes
1350.It icmp6	nd6_prune	integer	yes
1351.It icmp6	nd6_umaxtries	integer	yes
1352.It icmp6	nd6_useloopback	integer	yes
1353.It icmp6	nodeinfo	integer	yes
1354.It icmp6	rediraccept	integer	yes
1355.It icmp6	redirtimeout	integer	yes
1356.It ip6	accept_rtadv	integer	yes
1357.It ip6	anonportmax	integer	yes
1358.It ip6	anonportmin	integer	yes
1359.It ip6	auto_flowlabel	integer	yes
1360.It ip6	dad_count	integer	yes
1361.It ip6	defmcasthlim	integer	yes
1362.It ip6	forwarding	integer	yes
1363.It ip6	gifhlim	integer	yes
1364.It ip6	hlim	integer	yes
1365.It ip6	hdrnestlimit	integer	yes
1366.It ip6	kame_version	string	no
1367.It ip6	keepfaith	integer	yes
1368.It ip6	log_interval	integer	yes
1369.It ip6	lowportmax	integer	yes
1370.It ip6	lowportmin	integer	yes
1371.It ip6	maxfragpackets	integer	yes
1372.It ip6	maxfrags	integer	yes
1373.It ip6	redirect	integer	yes
1374.It ip6	rr_prune	integer	yes
1375.It ip6	use_deprecated	integer	yes
1376.It ip6	v6only	integer	yes
1377.It udp6	do_loopback_cksum	integer	yes
1378.It udp6	recvspace	integer	yes
1379.It udp6	sendspace	integer	yes
1380.El
1381.Pp
1382The variables are as follows:
1383.Bl -tag -width "123456"
1384.It Li ip6.accept_rtadv
1385If set to non-zero, the node will accept ICMPv6 router advertisement packets
1386and autoconfigures address prefixes and default routers.
1387The node must be a host
1388.Pq not a router
1389for the option to be meaningful.
1390.It Li ip6.anonportmax
1391The highest port number to use for TCP and UDP ephemeral port allocation.
1392This cannot be set to less than 1024 or greater than 65535, and must
1393be greater than
1394.Li ip6.anonportmin .
1395.It Li ip6.anonportmin
1396The lowest port number to use for TCP and UDP ephemeral port allocation.
1397This cannot be set to less than 1024 or greater than 65535.
1398.It Li ip6.auto_flowlabel
1399On connected transport protocol packets,
1400fill IPv6 flowlabel field to help intermediate routers to identify packet flows.
1401.It Li ip6.dad_count
1402The variable configures number of IPv6 DAD
1403.Pq duplicated address detection
1404probe packets.
1405The packets will be generated when IPv6 interface addresses are configured.
1406.It Li ip6.defmcasthlim
1407The default hop limit value for an IPv6 multicast packet sourced by the node.
1408This value applies to all the transport protocols on top of IPv6.
1409There are APIs to override the value, as documented in
1410.Xr ip6 4 .
1411.It Li ip6.forwarding
1412If set to 1, enables IPv6 forwarding for the node,
1413meaning that the node is acting as a router.
1414If set to 0, disables IPv6 forwarding for the node,
1415meaning that the node is acting as a host.
1416IPv6 specification defines node behavior for
1417.Dq router
1418case and
1419.Dq host
1420case quite differently, and changing this variable during operation
1421may cause serious trouble.
1422It is recommended to configure the variable at bootstrap time,
1423and bootstrap time only.
1424.It Li ip6.gifhlim
1425The maximum hop limit value for an IPv6 packet generated by
1426.Xr gif 4
1427tunnel interface.
1428.It Li ip6.hdrnestlimit
1429The number of IPv6 extension headers permitted on incoming IPv6 packets.
1430If set to 0, the node will accept as many extension headers as possible.
1431.It Li ip6.hlim
1432The default hop limit value for an IPv6 unicast packet sourced by the node.
1433This value applies to all the transport protocols on top of IPv6.
1434There are APIs to override the value, as documented in
1435.Xr ip6 4 .
1436.It Li ip6.kame_version
1437The string identifies the version of KAME IPv6 stack implemented in the kernel.
1438.It Li ip6.keepfaith
1439If set to non-zero, it enables
1440.Dq FAITH
1441TCP relay IPv6-to-IPv4 translator code in the kernel.
1442Refer
1443.Xr faith 4
1444and
1445.Xr faithd 8
1446for detail.
1447.It Li ip6.log_interval
1448The variable controls amount of logs generated by IPv6 packet
1449forwarding engine, by setting interval between log output
1450.Pq in seconds .
1451.It Li ip6.lowportmax
1452The highest port number to use for TCP and UDP reserved port allocation.
1453This cannot be set to less than 0 or greater than 1024, and must
1454be greater than
1455.Li ip6.lowportmin .
1456.It Li ip6.lowportmin
1457The lowest port number to use for TCP and UDP reserved port allocation.
1458This cannot be set to less than 0 or greater than 1024, and must
1459be smaller than
1460.Li ip6.lowportmax .
1461.It Li ip6.maxfragpackets
1462The maximum number of fragmented packets the node will accept.
14630 means that the node will not accept any fragmented packets.
1464\-1 means that the node will accept as many fragmented packets as it receives.
1465The flag is provided basically for avoiding possible DoS attacks.
1466.It Li ip6.maxfrags
1467The maximum number of fragments the node will accept.
14680 means that the node will not accept any fragments.
1469\-1 means that the node will accept as many fragments as it receives.
1470The flag is provided basically for avoiding possible DoS attacks.
1471.It Li ip6.redirect
1472If set to 1, ICMPv6 redirects may be sent by the node.
1473This option is ignored unless the node is routing IP packets,
1474and should normally be enabled on all systems.
1475.It Li ip6.rr_prune
1476The variable specifies interval between IPv6 router renumbering prefix
1477babysitting, in seconds.
1478.It Li ip6.use_deprecated
1479The variable controls use of deprecated address, specified in RFC 2462 5.5.4.
1480.It Li ip6.v6only
1481The variable specifies initial value for
1482.Dv IPV6_V6ONLY
1483socket option for
1484.Dv AF_INET6
1485socket.
1486Please refer to
1487.Xr ip6 4
1488for detail.
1489.It Li icmp6.errppslimit
1490The variable specifies the maximum number of outgoing ICMPv6 error messages,
1491per second.
1492ICMPv6 error messages that exceeded the value are subject to rate limitation
1493and will not go out from the node.
1494Negative value disables rate limitation.
1495.It Li icmp6.mtudisc_hiwat
1496.It Li icmp6.mtudisc_lowat
1497The variables define the maximum number of routing table entries,
1498created due to path MTU discovery
1499.Pq prevents denial-of-service attacks with ICMPv6 too big messages .
1500When IPv6 path MTU discovery happens, we keep path MTU information into
1501the routing table.
1502If the number of routing table entries exceed the value,
1503the kernel will not attempt to keep the path MTU information.
1504.Li icmp6.mtudisc_hiwat
1505is used when we have verified ICMPv6 too big messages.
1506.Li icmp6.mtudisc_lowat
1507is used when we have unverified ICMPv6 too big messages.
1508Verification is performed by using address/port pairs kept in connected pcbs.
1509Negative value disables the upper limit.
1510.It Li icmp6.nd6_debug
1511If set to non-zero, kernel IPv6 neighbor discovery code will generate
1512debugging messages.
1513The debug outputs are useful to diagnose IPv6 interoperability issues.
1514The flag must be set to 0 for normal operation.
1515.It Li icmp6.nd6_delay
1516The variable specifies
1517.Dv DELAY_FIRST_PROBE_TIME
1518timing constant in IPv6 neighbor discovery specification
1519.Pq RFC 2461 ,
1520in seconds.
1521.It Li icmp6.nd6_maxnudhint
1522IPv6 neighbor discovery permits upper layer protocols to supply reachability
1523hints, to avoid unnecessary neighbor discovery exchanges.
1524The variable defines the number of consecutive hints the neighbor discovery
1525layer will take.
1526For example, by setting the variable to 3, neighbor discovery layer
1527will take 3 consecutive hints in maximum.
1528After receiving 3 hints, neighbor discovery layer will perform
1529normal neighbor discovery process.
1530.It Li icmp6.nd6_mmaxtries
1531The variable specifies
1532.Dv MAX_MULTICAST_SOLICIT
1533constant in IPv6 neighbor discovery specification
1534.Pq RFC 2461 .
1535.It Li icmp6.nd6_prune
1536The variable specifies interval between IPv6 neighbor cache babysitting,
1537in seconds.
1538.It Li icmp6.nd6_umaxtries
1539The variable specifies
1540.Dv MAX_UNICAST_SOLICIT
1541constant in IPv6 neighbor discovery specification
1542.Pq RFC 2461 .
1543.It Li icmp6.nd6_useloopback
1544If set to non-zero, kernel IPv6 stack will use loopback interface for
1545local traffic.
1546.It Li icmp6.nodeinfo
1547The variable enables responses to ICMPv6 node information queries.
1548If you set the variable to 0, responses will not be generated for
1549ICMPv6 node information queries.
1550Since node information queries can have a security impact, it is
1551possible to fine tune which responses should be answered.
1552Two separate bits can be set.
1553.Bl -tag -width "12345"
1554.It 1
1555Respond to ICMPv6 FQDN queries, e.g.
1556.Li ping6 -w .
1557.It 2
1558Respond to ICMPv6 node addresses queries, e.g.
1559.Li ping6 -a .
1560.El
1561.It Li icmp6.rediraccept
1562If set to non-zero, the host will accept ICMPv6 redirect packets.
1563Note that IPv6 routers will never accept ICMPv6 redirect packets,
1564and the variable is meaningful on IPv6 hosts
1565.Pq non-router
1566only.
1567.It Li icmp6.redirtimeout
1568The variable specifies lifetime of routing entries generated by incoming
1569ICMPv6 redirect.
1570.It Li udp6.do_loopback_cksum
1571Perform UDP checksum on loopback.
1572.It Li udp6.recvspace
1573Default UDP receive buffer size.
1574.It Li udp6.sendspace
1575Default UDP send buffer size.
1576.El
1577.Pp
1578We reuse net.*.tcp for
1579.Tn TCP
1580over
1581.Tn IPv6 ,
1582and therefore we do not have variables net.*.tcp6.
1583Variables net.inet6.udp6 have identical meaning to net.inet.udp.
1584Please refer to
1585.Li PF_INET
1586section above.
1587For variables net.*.ipsec6, please refer to
1588.Xr ipsec 4 .
1589.It Li PF_KEY
1590Get or set various global information about the IPsec key management.
1591The third level name is the variable name.
1592The currently defined variable and names are:
1593.Bl -column "blockacq_lifetime" "integer" "yes" -offset indent
1594.It Sy Variable name	Type	Changeable
1595.It debug	integer	yes
1596.It spi_try	integer	yes
1597.It spi_min_value	integer	yes
1598.It spi_max_value	integer	yes
1599.It larval_lifetime	integer	yes
1600.It blockacq_count	integer	yes
1601.It blockacq_lifetime	integer	yes
1602.It esp_keymin	integer	yes
1603.It esp_auth	integer	yes
1604.It ah_keymin	integer	yes
1605.El
1606The variables are as follows:
1607.Bl -tag -width "123456"
1608.It Li debug
1609Turn on debugging message from within the kernel.
1610The value is a bitmap, as defined in
1611.Pa /usr/include/netkey/key_debug.h .
1612.It Li spi_try
1613The number of times the kernel will try to obtain an unique SPI
1614when it generates it from random number generator.
1615.It Li spi_min_value
1616Minimum SPI value when generating it within the kernel.
1617.It Li spi_max_value
1618Maximum SPI value when generating it within the kernel.
1619.It Li larval_lifetime
1620Lifetime for LARVAL SAD entries, in seconds.
1621.It Li blockacq_count
1622Number of ACQUIRE PF_KEY messages to be blocked after an ACQUIRE message.
1623It avoids flood of ACQUIRE PF_KEY from being sent from the kernel to the
1624key management daemon.
1625.It Li blockacq_lifetime
1626Lifetime of ACQUIRE PF_KEY message.
1627.It Li esp_keymin
1628Minimum ESP key length, in bits.
1629The value is used when the kernel creates proposal payload
1630on ACQUIRE PF_KEY message.
1631.It Li esp_auth
1632Whether ESP authentication should be used or not.
1633Non-zero value indicates that ESP authentication should be used.
1634The value is used when the kernel creates proposal payload
1635on ACQUIRE PF_KEY message.
1636.It Li ah_keymin
1637Minimum AH key length, in bits,
1638The value is used when the kernel creates proposal payload
1639on ACQUIRE PF_KEY message.
1640.El
1641.El
1642.Sh CTL_PROC
1643The string and integer information available for the CTL_PROC
1644is detailed below.
1645The changeable column shows whether a process with appropriate
1646privilege may change the value.
1647These values are per-process,
1648and as such may change from one process to another.
1649When a process is created,
1650the default values are inherited from its parent.
1651When a set-user-ID or set-group-ID binary is executed, the
1652value of PROC_PID_CORENAME is reset to the system default value.
1653The second level name is either the magic value PROC_CURPROC, which
1654points to the current process, or the PID of the target process.
1655.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" "yes" -offset indent
1656.It Sy Third level name	Type	Changeable
1657.It PROC\_PID\_CORENAME	string	yes
1658.It PROC\_PID\_LIMIT	node	not applicable
1659.It PROC\_PID\_STOPFORK	int	yes
1660.It PROC\_PID\_STOPEXEC	int	yes
1661.It PROC\_PID\_STOPEXIT	int	yes
1662.El
1663.Bl -tag -width "123456"
1664.Pp
1665.It Li PROC_PID_CORENAME
1666The template used for the core dump file name (see
1667.Xr core 5
1668for details).
1669The base name must either be
1670.Nm core
1671or end with the suffix ``.core'' (the super-user may set arbitrary names).
1672By default it points to KERN_DEFCORENAME.
1673.It Li PROC_PID_LIMIT
1674Return resources limits, as defined for the
1675.Xr getrlimit 2
1676and
1677.Xr setrlimit 2
1678system calls.
1679The fourth level name is one of:
1680.Bl -tag -width PROC_PID_LIMIT_MEMLOCKAA
1681.It Li PROC_PID_LIMIT_CPU
1682The maximum amount of CPU time (in seconds) to be used by each process.
1683.It Li PROC_PID_LIMIT_FSIZE
1684The largest size (in bytes) file that may be created.
1685.It Li PROC_PID_LIMIT_DATA
1686The maximum size (in bytes) of the data segment for a process;
1687this defines how far a program may extend its break with the
1688.Xr sbrk 2
1689system call.
1690.It Li PROC_PID_LIMIT_STACK
1691The maximum size (in bytes) of the stack segment for a process;
1692this defines how far a program's stack segment may be extended.
1693Stack extension is performed automatically by the system.
1694.It Li PROC_PID_LIMIT_CORE
1695The largest size (in bytes)
1696.Pa core
1697file that may be created.
1698.It Li PROC_PID_LIMIT_RSS
1699The maximum size (in bytes) to which a process's resident set size may
1700grow.
1701This imposes a limit on the amount of physical memory to be given to
1702a process; if memory is tight, the system will prefer to take memory
1703from processes that are exceeding their declared resident set size.
1704.It Li PROC_PID_LIMIT_MEMLOCK
1705The maximum size (in bytes) which a process may lock into memory
1706using the
1707.Xr mlock 2
1708function.
1709.It Li PROC_PID_LIMIT_NPROC
1710The maximum number of simultaneous processes for this user id.
1711.It Li PROC_PID_LIMIT_NOFILE
1712The maximum number of open files for this process.
1713.El
1714.Pp
1715The fifth level name is one of PROC_PID_LIMIT_TYPE_SOFT or
1716PROC_PID_LIMIT_TYPE_HARD, to select respectively the soft or hard limit.
1717Both are of type integer.
1718.It Li PROC_PID_STOPFORK
1719If non zero, the process' children will be stopped after
1720.Xr fork 2
1721calls.
1722The children is created in the SSTOP state and is never scheduled
1723for running before being stopped.
1724This feature helps attaching a process with a debugger such as
1725.Xr gdb 1
1726before it had the opportunity to actually do anything.
1727.Pp
1728This value is inherited by the process's children, and it also
1729apply to emulation specific system calls that fork a new process, such as
1730.Fn sproc
1731or
1732.Fn clone .
1733.It Li PROC_PID_STOPEXEC
1734If non zero, the process will be stopped on next
1735.Xr exec 3
1736call.
1737The process created by
1738.Xr exec 3
1739is created in the SSTOP state and is never scheduled for running
1740before being stopped.
1741This feature helps attaching a process with a debugger such as
1742.Xr gdb 1
1743before it had the opportunity to actually do anything.
1744.Pp
1745This value is inherited by the process's children.
1746.It Li PROC_PID_STOPEXIT
1747If non zero, the process will be stopped on when it has cause to exit,
1748either by way of calling
1749.Xr exit 3 ,
1750.Xr _exit 2 ,
1751or by the receipt of a specific signal.
1752The process is stopped before any of its resources or vm space is
1753released allowing examination of the termination state of a process
1754before it disappears.
1755This feature can be used to examine the final conditions of the
1756process's vmspace via
1757.Xr pmap 1
1758or its resource settings with
1759.Xr sysctl 8
1760before it disappears.
1761.Pp
1762This value is also inherited by the process's children.
1763.El
1764.Sh CTL_USER
1765The string and integer information available for the CTL_USER level
1766is detailed below.
1767The changeable column shows whether a process with appropriate
1768privilege may change the value.
1769.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
1770.It Sy Second level name	Type	Changeable
1771.It USER\_BC\_BASE\_MAX	integer	no
1772.It USER\_BC\_DIM\_MAX	integer	no
1773.It USER\_BC\_SCALE\_MAX	integer	no
1774.It USER\_BC\_STRING\_MAX	integer	no
1775.It USER\_COLL\_WEIGHTS\_MAX	integer	no
1776.It USER\_CS\_PATH	string	no
1777.It USER\_EXPR\_NEST\_MAX	integer	no
1778.It USER\_LINE\_MAX	integer	no
1779.It USER\_POSIX2\_CHAR\_TERM	integer	no
1780.It USER\_POSIX2\_C\_BIND	integer	no
1781.It USER\_POSIX2\_C\_DEV	integer	no
1782.It USER\_POSIX2\_FORT\_DEV	integer	no
1783.It USER\_POSIX2\_FORT\_RUN	integer	no
1784.It USER\_POSIX2\_LOCALEDEF	integer	no
1785.It USER\_POSIX2\_SW\_DEV	integer	no
1786.It USER\_POSIX2\_UPE	integer	no
1787.It USER\_POSIX2\_VERSION	integer	no
1788.It USER\_RE\_DUP\_MAX	integer	no
1789.It USER\_STREAM\_MAX	integer	no
1790.It USER\_TZNAME\_MAX	integer	no
1791.It USER\_ATEXIT\_MAX	integer	no
1792.El
1793.Bl -tag -width "123456"
1794.Pp
1795.It Li USER_BC_BASE_MAX
1796The maximum ibase/obase values in the
1797.Xr bc 1
1798utility.
1799.It Li USER_BC_DIM_MAX
1800The maximum array size in the
1801.Xr bc 1
1802utility.
1803.It Li USER_BC_SCALE_MAX
1804The maximum scale value in the
1805.Xr bc 1
1806utility.
1807.It Li USER_BC_STRING_MAX
1808The maximum string length in the
1809.Xr bc 1
1810utility.
1811.It Li USER_COLL_WEIGHTS_MAX
1812The maximum number of weights that can be assigned to any entry of
1813the LC_COLLATE order keyword in the locale definition file.
1814.It Li USER_CS_PATH
1815Return a value for the
1816.Ev PATH
1817environment variable that finds all the standard utilities.
1818.It Li USER_EXPR_NEST_MAX
1819The maximum number of expressions that can be nested within
1820parenthesis by the
1821.Xr expr 1
1822utility.
1823.It Li USER_LINE_MAX
1824The maximum length in bytes of a text-processing utility's input
1825line.
1826.It Li USER_POSIX2_CHAR_TERM
1827Return 1 if the system supports at least one terminal type capable of
1828all operations described in POSIX 1003.2, otherwise 0.
1829.It Li USER_POSIX2_C_BIND
1830Return 1 if the system's C-language development facilities support the
1831C-Language Bindings Option, otherwise 0.
1832.It Li USER_POSIX2_C_DEV
1833Return 1 if the system supports the C-Language Development Utilities Option,
1834otherwise 0.
1835.It Li USER_POSIX2_FORT_DEV
1836Return 1 if the system supports the FORTRAN Development Utilities Option,
1837otherwise 0.
1838.It Li USER_POSIX2_FORT_RUN
1839Return 1 if the system supports the FORTRAN Runtime Utilities Option,
1840otherwise 0.
1841.It Li USER_POSIX2_LOCALEDEF
1842Return 1 if the system supports the creation of locales, otherwise 0.
1843.It Li USER_POSIX2_SW_DEV
1844Return 1 if the system supports the Software Development Utilities Option,
1845otherwise 0.
1846.It Li USER_POSIX2_UPE
1847Return 1 if the system supports the User Portability Utilities Option,
1848otherwise 0.
1849.It Li USER_POSIX2_VERSION
1850The version of POSIX 1003.2 with which the system attempts to comply.
1851.It Li USER_RE_DUP_MAX
1852The maximum number of repeated occurrences of a regular expression
1853permitted when using interval notation.
1854.ne 1i
1855.It Li USER_STREAM_MAX
1856The minimum maximum number of streams that a process may have open
1857at any one time.
1858.It Li USER_TZNAME_MAX
1859The minimum maximum number of types supported for the name of a
1860timezone.
1861.It Li USER_ATEXIT_MAX
1862The maximum number of functions that may be registered with
1863.Xr atexit 3 .
1864.El
1865.Sh CTL_VM
1866The string and integer information available for the CTL_VM level
1867is detailed below.
1868The changeable column shows whether a process with appropriate
1869privilege may change the value.
1870.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
1871.It Sy Second level name	Type	Changeable
1872.It VM\_ANONMAX	int	yes
1873.It VM\_ANONMIN	int	yes
1874.It VM\_BUFCACHE	int	yes
1875.It VM\_BUFMEM	int	no
1876.It VM\_BUFMEM_HIWATER	int	yes
1877.It VM\_BUFMEM_LOWATER	int	yes
1878.It VM\_EXECMAX	int	yes
1879.It VM\_EXECMIN	int	yes
1880.It VM\_FILEMAX	int	yes
1881.It VM\_FILEMIN	int	yes
1882.It VM\_LOADAVG	struct loadavg	no
1883.It VM\_MAXSLP	int	no
1884.It VM\_METER	struct vmtotal	no
1885.It VM\_NKMEMPAGES	int	no
1886.It VM\_USPACE	int	no
1887.It VM\_UVMEXP	struct uvmexp	no
1888.It VM\_UVMEXP2	struct uvmexp_sysctl	no
1889.El
1890.Pp
1891.Bl -tag -width "123456"
1892.It Li VM_ANONMAX
1893The percentage of physical memory which will be reclaimed
1894from other types of memory usage to store anonymous application data.
1895.It Li VM_ANONMIN
1896The percentage of physical memory which will be always be available for
1897anonymous application data.
1898.It Li VM_BUFCACHE
1899The percentage of kernel memory which will be available
1900for the buffer cache.
1901.It Li VM_BUFMEM
1902The amount of kernel memory that is being used by the buffer cache.
1903.It Li VM_BUFMEM_LOWATER
1904The minimum amount of kernel memory to reserve for the
1905buffer cache.
1906.It Li VM_BUFMEM_HIWATER
1907The maximum amount of kernel memory to be used for the
1908buffer cache.
1909.It Li VM_EXECMAX
1910The percentage of physical memory which will be reclaimed
1911from other types of memory usage to store cached executable data.
1912.It Li VM_EXECMIN
1913The percentage of physical memory which will be always be available for
1914cached executable data.
1915.It Li VM_FILEMAX
1916The percentage of physical memory which will be reclaimed
1917from other types of memory usage to store cached file data.
1918.It Li VM_FILEMIN
1919The percentage of physical memory which will be always be available for
1920cached file data.
1921.It Li VM_LOADAVG
1922Return the load average history.
1923The returned data consists of a
1924.Va struct loadavg .
1925.It Li VM_MAXSLP
1926The value of the maxslp kernel global variable.
1927.It Li VM_METER
1928Return system wide virtual memory statistics.
1929The returned data consists of a
1930.Va struct vmtotal .
1931.It Li VM_USPACE
1932The number of bytes allocated for each kernel stack.
1933.It Li VM_UVMEXP
1934Return system wide virtual memory statistics.
1935The returned data consists of a
1936.Va struct uvmexp .
1937.It Li VM_UVMEXP2
1938Return system wide virtual memory statistics.
1939The returned data consists of a
1940.Va struct uvmexp_sysctl .
1941.El
1942.Sh CTL_DDB
1943The integer information available for the CTL_DDB level is detailed below.
1944The changeable column shows whether a process with appropriate
1945privilege may change the value.
1946.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
1947.It Sy Second level name	Type	Changeable
1948.It DBCTL\_RADIX	integer	yes
1949.It DBCTL\_MAXOFF	integer	yes
1950.It DBCTL\_LINES	integer	yes
1951.It DBCTL\_TABSTOPS	integer	yes
1952.It DBCTL\_ONPANIC	integer	yes
1953.It DBCTL\_FROMCONSOLE	integer	yes
1954.El
1955.Pp
1956.Bl -tag -width "123456"
1957.It Li DBCTL_RADIX
1958The input and output radix.
1959.It Li DBCTL_MAXOFF
1960The maximum symbol offset.
1961.It Li DBCTL_LINES
1962Number of display lines.
1963.It Li DBCTL_TABSTOPS
1964Tab width.
1965.It Li DBCTL_ONPANIC
1966If non-zero, DDB will be entered when the kernel panics.
1967.It Li DBCTL_FROMCONSOLE
1968If not zero, DDB may be entered by sending a break on a serial
1969console or by a special key sequence on a graphics console.
1970.El
1971.Pp
1972These MIB nodes are also available as variables from within the DDB.
1973See
1974.Xr ddb 4
1975for more details.
1976.Sh CTL_SECURITY
1977The security level contains various security-related settings for
1978the system. Available settings are detailed below.
1979.Pp
1980.Bl -tag -width "123456"
1981.It Li security.curtain
1982If non-zero, will filter return objects according to the user-id
1983requesting information about them, preventing from users any
1984access to objects they don't own.
1985.Pp
1986At the moment, it affects
1987.Xr ps 1 ,
1988.Xr netstat 1
1989(for
1990.Dv PF_INET ,
1991.Dv PF_INET6 ,
1992and
1993.Dv PF_UNIX
1994PCBs), and
1995.Xr w 1 .
1996.It Li security.pax
1997Settings for PaX -- exploit mitigation features.
1998.Pp
1999.Bl -tag -width "123456"
2000.It Li security.pax.mprotect.enable
2001Enable PaX MPROTECT restrictions.
2002.Pp
2003These are
2004.Xr mprotect 2
2005restrictions to better enforce a W^X policy. The value of this
2006knob must be non-zero for PaX MPROTECT to be enabled, even if a
2007process is already marked with
2008.Em P_PAXMPROTECT .
2009.It Li security.pax.mprotect.global_protection
2010Specifies the default global policy for programs without an
2011explicit enable/disable flag.
2012.Pp
2013When non-zero, all programs will get the PaX MPROTECT restrictions,
2014except those exempted with
2015.Xr paxctl 1 .
2016Otherwise, all programs will not get the PaX MPROTECT restrictions,
2017except those specifically marked as such with
2018.Xr paxctl 1.
2019.El
2020.It Li security.setid_core
2021Settings related to set-id processes coredumps.
2022By default, set-id processes do not dump core in situations where
2023other processes would.
2024The settings in this node allows an administrator to change this
2025behavior.
2026.Pp
2027.Bl -tag -width "123456"
2028.It Li security.setid_core.dump
2029If non-zero, set-id processes will dump core.
2030.It Li security.setid_core.group
2031The group-id for the set-id processes' coredump.
2032.It Li security.setid_core.mode
2033The mode for the set-id processes' coredump.
2034See
2035.Xr chmod 1 .
2036.It Li security.setid_core.owner
2037The user-id that will be used as the owner of the set-id processes'
2038coredump.
2039.It Li security.setid_core.path
2040The path to which set-id processes' coredumps will be saved to.
2041Same syntax as kern.defcorename.
2042.El
2043.El
2044.Sh CTL_VENDOR
2045The "vendor" toplevel name is reserved to be used by vendors who wish to
2046have their own private MIB tree.
2047Intended use is to store values under
2048.Dq vendor.\*[Lt]yourname\*[Gt].* .
2049.Sh DYNAMIC OPERATIONS
2050Several meta-identifiers are provided to perform operations on the
2051.Nm
2052tree itself, or support alternate means of accessing the data
2053instrumented by the
2054.Nm
2055tree.
2056.Bl -column CTLXCREATESYMXXX
2057.It Sy Name	Description
2058.It CTL\_QUERY	Retrieve a mapping of names to numbers below a given node
2059.It CTL\_CREATE	Create a new node
2060.It CTL\_CREATESYM	Create a new node by its kernel symbol
2061.It CTL\_DESTROY	Destroy a node
2062.It CTL\_DESCRIBE	Retrieve node descriptions
2063.El
2064.Pp
2065The core interface to all of these meta-functions is the structure
2066that the kernel uses to describe the tree internally, as defined in
2067.Aq Pa sys/sysctl.h
2068as:
2069.Pp
2070.Bd -literal
2071struct sysctlnode {
2072        uint32_t sysctl_flags;          /* flags and type */
2073        int32_t sysctl_num;             /* mib number */
2074        char sysctl_name[SYSCTL_NAMELEN]; /* node name */
2075        uint32_t sysctl_ver;        /* node's version vs. rest of tree */
2076        uint32_t __rsvd;
2077        union {
2078                struct {
2079                        uint32_t suc_csize; /* size of child node array */
2080                        uint32_t suc_clen; /* number of valid children */
2081                        struct sysctlnode* suc_child; /* array of child nodes */
2082                } scu_child;
2083                struct {
2084                        void *sud_data; /* pointer to external data */
2085                        size_t sud_offset; /* offset to data */
2086                } scu_data;
2087                int32_t scu_alias;      /* node this node refers to */
2088                int32_t scu_idata;      /* immediate "int" data */
2089                u_quad_t scu_qdata;     /* immediate "u_quad_t" data */
2090        } sysctl_un;
2091        size_t _sysctl_size;            /* size of instrumented data */
2092        sysctlfn _sysctl_func;          /* access helper function */
2093        struct sysctlnode *sysctl_parent; /* parent of this node */
2094        const char *sysctl_desc;        /* description of node */
2095};
2096
2097#define sysctl_csize    sysctl_un.scu_child.suc_csize
2098#define sysctl_clen     sysctl_un.scu_child.suc_clen
2099#define sysctl_child    sysctl_un.scu_child.suc_child
2100#define sysctl_data     sysctl_un.scu_data.sud_data
2101#define sysctl_offset   sysctl_un.scu_data.sud_offset
2102#define sysctl_alias    sysctl_un.scu_alias
2103#define sysctl_idata    sysctl_un.scu_idata
2104#define sysctl_qdata    sysctl_un.scu_qdata
2105.Ed
2106.Pp
2107Querying the tree to discover the name to number mapping permits
2108dynamic discovery of all the data that the tree currently has
2109instrumented.
2110For example, to discover all the nodes below the
2111CTL_VFS node:
2112.Pp
2113.Bd -literal -offset indent -compact
2114struct sysctlnode query, vfs[128];
2115int mib[2];
2116size_t len;
2117.sp
2118mib[0] = CTL_VFS;
2119mib[1] = CTL_QUERY;
2120memset(\*[Am]query, 0, sizeof(query));
2121query.sysctl_flags = SYSCTL_VERSION;
2122len = sizeof(vfs);
2123sysctl(mib, 2, \*[Am]vfs[0], \*[Am]len, \*[Am]query, sizeof(query));
2124.Ed
2125.Pp
2126Note that a reference to an empty node with
2127.Fa sysctl_flags
2128set to
2129.Dv SYSCTL_VERSION
2130is passed to sysctl in order to indicate the version that the program
2131is using.
2132All dynamic operations passing nodes into sysctl require that the
2133version be explicitly specified.
2134.Pp
2135Creation and destruction of nodes works by constructing part of a new
2136node description (or a description of the existing node) and invoking
2137CTL_CREATE (or CTL_CREATESYM) or CTL_DESTROY at the parent of the new
2138node, with a pointer to the new node passed via the
2139.Fa new
2140and
2141.Fa newlen
2142arguments.
2143If valid values for
2144.Fa old
2145and
2146.Fa oldlenp
2147are passed, a copy of the new node once in the tree will be returned.
2148If the create operation fails because a node with the same name or MIB
2149number exists, a copy of the conflicting node will be returned.
2150.Pp
2151The minimum requirements for creating a node are setting the
2152.Fa sysctl_flags
2153to indicate the new node's type,
2154.Fa sysctl_num
2155to either the new node's number (or CTL_CREATE or CTL_CREATESYM if a
2156dynamically allocated MIB number is acceptable),
2157.Fa sysctl_size
2158to the size of the data to be instrumented (which must agree with the
2159given type), and
2160.Fa sysctl_name
2161must be set to the new node's name.
2162Nodes that are not of type
2163.Dq node
2164must also have some description of the data to be instrumented, which
2165will vary depending on what is to be instrumented.
2166.Pp
2167If existing kernel data is to be covered by this new node, its address
2168should be given in
2169.Fa sysctl_data
2170or, if CTL_CREATESYM is used,
2171.Fa sysctl_data
2172should be set to a string containing its name from the kernel's symbol
2173table.
2174If new data is to be instrumented and an initial value is available,
2175the new integer or quad type data should be placed into either
2176.Fa sysctl_idata
2177or
2178.Fa sysctl_qdata ,
2179respectively, along with the SYSCTL_IMMEDIATE flag being set, or
2180.Fa sysctl_data
2181should be set to point to a copy of the new data, and the
2182SYSCTL_OWNDATA flag must be set.
2183This latter method is the only way that new string and struct type
2184nodes can be initialized.
2185Invalid kernel addresses are accepted, but any attempt to access those
2186nodes will return an error.
2187.Pp
2188The
2189.Fa sysctl_csize ,
2190.Fa sysctl_clen ,
2191.Fa sysctl_child ,
2192.Fa sysctl_parent ,
2193and
2194.Fa sysctl_alias
2195members are used by the kernel to link the tree together and must be
2196.Dv NULL
2197or 0.
2198Nodes created in this manner cannot have helper functions, so
2199.Fa sysctl_func
2200must also be
2201.Dv NULL .
2202If the
2203.Fa sysctl_ver
2204member is non-zero, it must match either the version of the parent or
2205the version at the root of the MIB or an error is returned.
2206This can be used to ensure that nodes are only added or removed from a
2207known state of the tree.
2208Note: It may not be possible to determine the version at the root
2209of the tree.
2210.Pp
2211This example creates a new subtree and adds a node to it that controls the
2212.Fa audiodebug
2213kernel variable, thereby making it tunable at at any time, without
2214needing to use
2215.Xr ddb 4
2216or
2217.Xr kvm 3
2218to alter the kernel's memory directly.
2219.Pp
2220.Bd -literal -offset indent -compact
2221struct sysctlnode node;
2222int mib[2];
2223size_t len;
2224.sp
2225mib[0] = CTL_CREATE;		/* create at top-level */
2226len = sizeof(node);
2227memset(\*[Am]node, 0, len);
2228node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_NODE;
2229snprintf(node.sysctl_name, sizeof(node.sysctl_name), "local");
2230node.sysctl_num = CTL_CREATE;	/* request dynamic MIB number */
2231sysctl(\*[Am]mib[0], 1, \*[Am]node, \*[Am]len, \*[Am]node, len);
2232.sp
2233mib[0] = node.sysctl_num;	/* use new MIB number */
2234mib[1] = CTL_CREATESYM;		/* create at second level */
2235len = sizeof(node);
2236memset(\*[Am]node, 0, len);
2237node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_INT;
2238snprintf(node.sysctl_name, sizeof(node.sysctl_name), "audiodebug");
2239node.sysctl_num = CTL_CREATE;
2240node.sysctl_data = "audiodebug"; /* kernel symbol to be used */
2241sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len);
2242.Ed
2243.Pp
2244The process for deleting nodes is similar, but less data needs to
2245be supplied.
2246Only the
2247.Fa sysctl_num
2248field
2249needs to be filled in; almost all other fields must be left blank.
2250The
2251.Fa sysctl_name
2252and/or
2253.Fa sysctl_ver
2254fields can be filled in with the name and version of the existing node
2255as additional checks on what will be deleted.
2256If all the given data fail to match any node, nothing will be deleted.
2257If valid values for
2258.Fa old
2259and
2260.Fa oldlenp
2261are supplied and a node is deleted, a copy of what was in the MIB tree
2262will be returned.
2263.Pp
2264This sample code shows the deletion of the two nodes created in the
2265above example:
2266.Pp
2267.Bd -literal -offset indent -compact
2268int mib[2];
2269.sp
2270len = sizeof(node);
2271memset(\*[Am]node, 0, len);
2272node.sysctl_flags = SYSCTL_VERSION;
2273.sp
2274mib[0] = 3214;			/* assumed number for "local" */
2275mib[1] = CTL_DESTROY;
2276node.sysctl_num = 3215;		/* assumed number for "audiodebug" */
2277sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len);
2278.sp
2279mib[0] = CTL_DESTROY;
2280node.sysctl_num = 3214;		/* now deleting "local" */
2281sysctl(\*[Am]mib[0], 1, NULL, NULL, \*[Am]node, len);
2282.Ed
2283.Pp
2284Descriptions of each of the nodes can also be retrieved, if they are
2285available.
2286Descriptions can be retrieved in bulk at each level or on a per-node
2287basis.
2288The layout of the buffer into which the descriptions are returned is a
2289series of variable length structures, each of which describes its own
2290size.
2291The length indicated includes the terminating
2292.Sq nul
2293character.
2294Nodes that have no description or where the description is not
2295available are indicated by an empty string.
2296The
2297.Fa descr_ver
2298will match the
2299.Fa sysctl_ver
2300value for a given node, so that descriptions for nodes whose number
2301have been recycled can be detected and ignored or discarded.
2302.Pp
2303.Bd -literal
2304struct sysctldesc {
2305        int32_t         descr_num;      /* mib number of node */
2306        uint32_t        descr_ver;      /* version of node */
2307        uint32_t        descr_len;      /* length of description string */
2308        char            descr_str[1];   /* not really 1...see above */
2309};
2310.Ed
2311.Pp
2312The
2313.Fn NEXT_DESCR
2314macro can be used to skip to the next description in the retrieved
2315list.
2316.Pp
2317.Bd -literal -offset indent -compact
2318struct sysctlnode desc;
2319struct sysctldesc *d;
2320char buf[1024];
2321int mib[2];
2322size_t len;
2323.sp
2324/* retrieve kern-level descriptions */
2325mib[0] = CTL_KERN;
2326mib[1] = CTL_DESCRIBE;
2327d = (struct sysctldesc *)\*[Am]buf[0];
2328len = sizeof(buf);
2329sysctl(mib, 2, d, \*[Am]len, NULL, 0);
2330while ((caddr_t)d \*[Lt] (caddr_t)\*[Am]buf[len]) {
2331	printf("node %d: %.*s\\n", d-\*[Gt]descr_num, d-\*[Gt]descr_len,
2332	    d-\*[Gt]descr_str);
2333	d = NEXT_DESCR(d);
2334}
2335.sp
2336/* retrieve description for kern.securelevel */
2337memset(\*[Am]desc, 0, sizeof(desc));
2338desc.sysctl_flags = SYSCTL_VERSION;
2339desc.sysctl_num = KERN_SECURELEVEL;
2340d = (struct sysctldesc *)\*[Am]buf[0];
2341len = sizeof(buf);
2342sysctl(mib, 2, d, \*[Am]len, \*[Am]desc, sizeof(desc));
2343printf("kern.securelevel: %.*s\\n", d-\*[Gt]descr_len, d-\*[Gt]descr_str);
2344.Ed
2345.Pp
2346Descriptions can also be set as follows, subject to the following rules:
2347.Pp
2348.Bl -bullet -compact
2349.It
2350The kernel securelevel is at zero or lower
2351.It
2352The caller has super-user privileges
2353.It
2354The node does not currently have a description
2355.It
2356The node is not marked as
2357.Dq permanent
2358.El
2359.Pp
2360.Bd -literal -offset indent -compact
2361struct sysctlnode desc;
2362int mib[2];
2363.sp
2364/* presuming the given top-level node was just added... */
2365mib[0] = 3214; /* mib numbers taken from previous examples */
2366mib[1] = CTL_DESCRIBE;
2367memset(\*[Am]desc, 0, sizeof(desc));
2368desc.sysctl_flags = SYSCTL_VERSION;
2369desc.sysctl_num = 3215;
2370desc.sysctl_desc = "audio debug control knob";
2371sysctl(mib, 2, NULL, NULL, \*[Am]desc, sizeof(desc));
2372.Ed
2373.Pp
2374Upon successfully setting a description, the new description will be
2375returned in the space indicated by the
2376.Fa oldp
2377and
2378.Fa oldlenp
2379arguments.
2380.Pp
2381The
2382.Fa sysctl_flags
2383field in the struct sysctlnode contains the sysctl version, node type
2384information, and a number of flags.
2385The macros
2386.Fn SYSCTL_VERS ,
2387.Fn SYSCTL_TYPE ,
2388and
2389.Fn SYSCTL_FLAGS
2390can be used to access the different fields.
2391Valid flags are:
2392.Bl -column CTLFLAGXPERMANENTXXX
2393.It Sy Name	Description
2394.It CTLFLAG\_READONLY	Node is read-only
2395.It CTLFLAG\_READONLY1	Node becomes read-only at securelevel 1
2396.It CTLFLAG\_READONLY2	Node becomes read-only at securelevel 2
2397.It CTLFLAG\_READWRITE	Node is writable by the superuser
2398.It CTLFLAG\_ANYWRITE	Node is writable by anyone
2399.It CTLFLAG\_PRIVATE	Node is readable only by the superuser
2400.It CTLFLAG\_PERMANENT	Node cannot be removed (cannot be set by
2401processes)
2402.It CTLFLAG\_OWNDATA	Node owns data and does not instrument
2403existing data
2404.It CTLFLAG\_IMMEDIATE	Node contains instrumented data and does not
2405instrument existing data
2406.It CTLFLAG\_HEX	Node's contents should be displayed in a hexadecimal
2407form
2408.It CTLFLAG\_ROOT	Node is the root of a tree (cannot be set at
2409any time)
2410.It CTLFLAG\_ANYNUMBER	Node matches any MIB number (cannot be set by
2411processes)
2412.It CTLFLAG\_HIDDEN	Node not displayed by default
2413.It CTLFLAG\_ALIAS	Node refers to a sibling node (cannot be set
2414by processes)
2415.It CTLFLAG\_OWNDESC	Node owns its own description string space
2416.El
2417.Sh RETURN VALUES
2418If the call to
2419.Nm
2420is successful, the number of bytes copied out is returned.
2421Otherwise \-1 is returned and
2422.Va errno
2423is set appropriately.
2424.Sh FILES
2425.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact
2426.It Aq Pa sys/sysctl.h
2427definitions for top level identifiers, second level kernel and hardware
2428identifiers, and user level identifiers
2429.It Aq Pa sys/socket.h
2430definitions for second level network identifiers
2431.It Aq Pa sys/gmon.h
2432definitions for third level profiling identifiers
2433.It Aq Pa uvm/uvm_param.h
2434definitions for second level virtual memory identifiers
2435.It Aq Pa netinet/in.h
2436definitions for third level IPv4/v6 identifiers and
2437fourth level IPv4/v6 identifiers
2438.It Aq Pa netinet/icmp_var.h
2439definitions for fourth level ICMP identifiers
2440.It Aq Pa netinet/icmp6.h
2441definitions for fourth level ICMPv6 identifiers
2442.It Aq Pa netinet/tcp_var.h
2443definitions for fourth level TCP identifiers
2444.It Aq Pa netinet/udp_var.h
2445definitions for fourth level UDP identifiers
2446.It Aq Pa netinet6/udp6_var.h
2447definitions for fourth level IPv6 UDP identifiers
2448.It Aq Pa netinet6/ipsec.h
2449definitions for fourth level IPsec identifiers
2450.It Aq Pa netkey/key_var.h
2451definitions for third level PF_KEY identifiers
2452.It Aq Pa machine/cpu.h
2453definitions for second level machdep identifiers
2454.El
2455.Sh ERRORS
2456The following errors may be reported:
2457.Bl -tag -width Er
2458.It Bq Er EFAULT
2459The buffer
2460.Fa name ,
2461.Fa oldp ,
2462.Fa newp ,
2463or length pointer
2464.Fa oldlenp
2465contains an invalid address, or the requested value is temporarily
2466unavailable.
2467.It Bq Er EINVAL
2468The
2469.Fa name
2470array is zero or greater than CTL_MAXNAME.
2471.It Bq Er EINVAL
2472A non-null
2473.Fa newp
2474is given and its specified length in
2475.Fa newlen
2476is too large or too small, or the given value is not acceptable for
2477the given node.
2478.It Bq Er ENOMEM
2479The length pointed to by
2480.Fa oldlenp
2481is too short to hold the requested value.
2482.It Bq Er EISDIR
2483The
2484.Fa name
2485array specifies an intermediate rather than terminal name.
2486.It Bq Er ENOTDIR
2487The
2488.Fa name
2489array specifies a node below a node that addresses data.
2490.It Bq Er ENOENT
2491The
2492.Fa name
2493array specifies a node that does not exist in the tree.
2494.It Bq Er ENOENT
2495An attempt was made to destroy a node that does not exist, or to
2496create or destroy a node below a node that does not exist.
2497.It Bq Er ENOTEMPTY
2498An attempt was made to destroy a node that still has children.
2499.It Bq Er EOPNOTSUPP
2500The
2501.Fa name
2502array specifies a value that is unknown or a meta-operation was
2503attempted that the requested node does not support.
2504.It Bq Er EPERM
2505An attempt is made to set a read-only value.
2506.It Bq Er EPERM
2507A process without appropriate privilege attempts to set a value or to
2508create or destroy a node.
2509.It Bq Er EPERM
2510An attempt to change a value protected by the current kernel security
2511level is made.
2512.El
2513.Sh SEE ALSO
2514.Xr ipsec 4 ,
2515.Xr tcp 4 ,
2516.Xr sysctl 8
2517.\" .Xr sysctl 9
2518.Sh HISTORY
2519The
2520.Nm
2521function first appeared in
2522.Bx 4.4 .
2523