xref: /netbsd/lib/libc/gen/sysctl.3 (revision bf9ec67e)
1.\"	$NetBSD: sysctl.3,v 1.94 2002/05/28 03:17:27 itojun 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. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
35.\"
36.Dd June 24, 1999
37.Dt SYSCTL 3
38.Os
39.Sh NAME
40.Nm sysctl
41.Nd get or set system information
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.Fd #include \*[Lt]sys/param.h\*[Gt]
46.Fd #include \*[Lt]sys/sysctl.h\*[Gt]
47.Ft int
48.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
49.Sh DESCRIPTION
50The
51.Nm
52function retrieves system information and allows processes with
53appropriate privileges to set system information.
54The information available from
55.Nm
56consists of integers, strings, and tables.
57Information may be retrieved and set from the command interface
58using the
59.Xr sysctl 8
60utility.
61.Pp
62Unless explicitly noted below,
63.Nm
64returns a consistent snapshot of the data requested.
65Consistency is obtained by locking the destination
66buffer into memory so that the data may be copied out without blocking.
67Calls to
68.Nm
69are serialized to avoid deadlock.
70.Pp
71The state is described using a ``Management Information Base'' (MIB)
72style name, listed in
73.Fa name ,
74which is a
75.Fa namelen
76length array of integers.
77.Pp
78The information is copied into the buffer specified by
79.Fa oldp .
80The size of the buffer is given by the location specified by
81.Fa oldlenp
82before the call,
83and that location gives the amount of data copied after a successful call.
84If the amount of data available is greater
85than the size of the buffer supplied,
86the call supplies as much data as fits in the buffer provided
87and returns with the error code ENOMEM.
88If the old value is not desired,
89.Fa oldp
90and
91.Fa oldlenp
92should be set to NULL.
93.Pp
94The size of the available data can be determined by calling
95.Nm
96with a NULL parameter for
97.Fa oldp .
98The size of the available data will be returned in the location pointed to by
99.Fa oldlenp .
100For some operations, the amount of space may change often.
101For these operations,
102the system attempts to round up so that the returned size is
103large enough for a call to return the data shortly thereafter.
104.Pp
105To set a new value,
106.Fa newp
107is set to point to a buffer of length
108.Fa newlen
109from which the requested value is to be taken.
110If a new value is not to be set,
111.Fa newp
112should be set to NULL and
113.Fa newlen
114set to 0.
115.Pp
116The top level names are defined with a CTL_ prefix in
117.Pa Aq sys/sysctl.h ,
118and are as follows.
119The next and subsequent levels down are found in the include files
120listed here, and described in separate sections below.
121.Pp
122.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
123.It Sy Pa Name	Next level names	Description
124.It CTL\_KERN	sys/sysctl.h	High kernel limits
125.It CTL\_VM	uvm/uvm_param.h	Virtual memory
126.It CTL\_VFS	sys/mount.h	Filesystem
127.It CTL\_NET	sys/socket.h	Networking
128.It CTL\_DEBUG	sys/sysctl.h	Debugging
129.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
130.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
131.It CTL\_USER	sys/sysctl.h	User-level
132.It CTL\_DDB	sys/sysctl.h	In-kernel debugger
133.It CTL\_PROC	sys/sysctl.h	Per-process
134.It CTL\_VENDOR	?	Vendor specific
135.El
136.Pp
137For example, the following retrieves the maximum number of processes allowed
138in the system:
139.Bd -literal -offset indent -compact
140int mib[2], maxproc;
141size_t len;
142.sp
143mib[0] = CTL_KERN;
144mib[1] = KERN_MAXPROC;
145len = sizeof(maxproc);
146sysctl(mib, 2, \*[Am]maxproc, \*[Am]len, NULL, 0);
147.Ed
148.sp
149To retrieve the standard search path for the system utilities:
150.Bd -literal -offset indent -compact
151int mib[2];
152size_t len;
153char *p;
154.sp
155mib[0] = CTL_USER;
156mib[1] = USER_CS_PATH;
157sysctl(mib, 2, NULL, \*[Am]len, NULL, 0);
158p = malloc(len);
159sysctl(mib, 2, p, \*[Am]len, NULL, 0);
160.Ed
161.Sh CTL_DEBUG
162The debugging variables vary from system to system.
163A debugging variable may be added or deleted without need to recompile
164.Nm
165to know about it.
166Each time it runs,
167.Nm
168gets the list of debugging variables from the kernel and
169displays their current values.
170The system defines twenty
171.Ns ( Va struct ctldebug )
172variables named
173.Dv debug0
174through
175.Dv debug19 .
176They are declared as separate variables so that they can be
177individually initialized at the location of their associated variable.
178The loader prevents multiple use of the same variable by issuing errors
179if a variable is initialized in more than one place.
180For example, to export the variable
181.Dv dospecialcheck
182as a debugging variable, the following declaration would be used:
183.Bd -literal -offset indent -compact
184int dospecialcheck = 1;
185struct ctldebug debug5 = { "dospecialcheck", \*[Am]dospecialcheck };
186.Ed
187.Sh CTL_VFS
188A distinguished second level name, VFS_GENERIC,
189is used to get general information about all filesystems.
190One of its third level identifiers is VFS_MAXTYPENUM
191that gives the highest valid filesystem type number.
192Its other third level identifier is VFS_CONF that
193returns configuration information about the filesystem
194type given as a fourth level identifier.
195The remaining second level identifiers are the
196filesystem type number returned by a
197.Xr statfs 2
198call or from VFS_CONF.
199The third level identifiers available for each filesystem
200are given in the header file that defines the mount
201argument structure for that filesystem.
202.Sh CTL_HW
203The string and integer information available for the CTL_HW level
204is detailed below.
205The changeable column shows whether a process with appropriate
206privilege may change the value.
207.Bl -column "Second level nameXXXXXX" "struct disk_sysctlXXX" -offset indent
208.It Sy Pa Second level name	Type	Changeable
209.It HW\_MACHINE	string	no
210.It HW\_MODEL	string	no
211.It HW\_NCPU	integer	no
212.It HW\_BYTEORDER	integer	no
213.It HW\_PHYSMEM	integer	no
214.It HW\_USERMEM	integer	no
215.It HW\_PAGESIZE	integer	no
216.\".It HW\_DISKNAMES	struct	no
217.\".It HW\_DISKSTATS	struct	no
218.It HW\_MACHINE\_ARCH	string	no
219.It HW\_ALIGNBYTES	integer	no
220.It HW\_DISKNAMES	string	no
221.It HW\_DISKSTATS	struct disk_sysctl	no
222.El
223.Pp
224.Bl -tag -width "123456"
225.It Li HW_MACHINE
226The machine class.
227.It Li HW_MODEL
228The machine model
229.It Li HW_NCPU
230The number of cpus.
231.ne 1i
232.It Li HW_BYTEORDER
233The byteorder (4,321, or 1,234).
234.It Li HW_PHYSMEM
235The bytes of physical memory.
236.It Li HW_USERMEM
237The bytes of non-kernel memory.
238.It Li HW_PAGESIZE
239The software page size.
240.It Li HW_DISKNAMES
241The list of (space separated) disk device names on the system.
242.It Li HW_DISKSTATS
243Return statistical information on the disk devices on the system.
244An array of
245.Va struct disk_sysctl
246structures is returned,
247whose size depends on the current number of such objects in the system.
248The third level name is the size of the
249.Va struct disk_sysctl .
250.It Li HW_MACHINE_ARCH
251The machine cpu class.
252.It Li HW_ALIGNBYTES
253Alignment constraint for all possible data types.
254This shows the value
255.Dv ALIGNBYTES
256in
257.Pa /usr/include/machine/param.h ,
258at the kernel compilation time.
259.El
260.Sh CTL_KERN
261The string and integer information available for the CTL_KERN level
262is detailed below.
263The changeable column shows whether a process with appropriate
264privilege may change the value.
265The types of data currently available are process information,
266system vnodes, the open file entries, routing table entries,
267virtual memory statistics, load average history, and clock rate
268information.
269.Bl -column "KERNXCHOWNXRESTRICTEDXXX" "struct clockrateXXX" -offset indent
270.It Sy Pa Second level name	Type	Changeable
271.It KERN\_ARGMAX	integer	no
272.It KERN\_AUTONICETIME	integer	yes
273.It KERN\_AUTONICEVAL	integer	yes
274.It KERN\_BOOTTIME	struct timeval	no
275.It KERN\_CCPU	integer	no
276.It KERN\_CLOCKRATE	struct clockinfo	no
277.It KERN\_CP\_TIME	long[\|]	no
278.It KERN\_DEFCORENAME	string	yes
279.It KERN\_DOMAINNAME	string	yes
280.It KERN\_FILE	struct file	no
281.It KERN\_FSCALE	integer	no
282.It KERN\_FSYNC	integer	no
283.It KERN\_HOSTID	integer	yes
284.It KERN\_HOSTNAME	string	yes
285.It KERN\_IOV\_MAX	integer	no
286.It KERN\_JOB\_CONTROL	integer	no
287.It KERN\_LOGIN\_NAME\_MAX	integer	no
288.It KERN\_LOGSIGEXIT	integer	yes
289.It KERN\_MAPPED\_FILES	integer	no
290.It KERN\_MAXFILES	integer	yes
291.It KERN\_MAXPARTITIONS	integer	no
292.It KERN\_MAXPROC	integer	yes
293.It KERN\_MAXPTYS	integer	yes
294.It KERN\_MAXVNODES	integer	yes
295.It KERN\_MBUF	node	not applicable
296.It KERN\_MEMLOCK	integer	no
297.It KERN\_MEMLOCK\_RANGE	integer	no
298.It KERN\_MEMORY\_PROTECTION	integer	no
299.It KERN\_MONOTONIC\_CLOCK	integer	no
300.It KERN\_MSGBUF	char[\|]	no
301.It KERN\_MSGBUFSIZE	integer	no
302.It KERN\_NGROUPS	integer	no
303.It KERN\_NTPTIME	struct ntptimeval	no
304.It KERN\_OSRELEASE	string	no
305.It KERN\_OSREV	integer	no
306.It KERN\_OSTYPE	string	no
307.It KERN\_POSIX1	integer	no
308.It KERN\_PROC	struct kinfo_proc	no
309.It KERN\_PROC2	struct kinfo_proc2	no
310.It KERN\_PROC\_ARGS	string	no
311.It KERN\_PROF	node	not applicable
312.It KERN\_RAWPARTITION	integer	no
313.It KERN\_ROOT\_DEVICE	string	no
314.It KERN\_RTC\_OFFSET	integer	no
315.It KERN\_SAVED\_IDS	integer	no
316.It KERN\_SECURELVL	integer	raise only
317.It KERN\_SYNCHRONIZED\_IO	integer	no
318.It KERN\_SYSVIPC\_INFO	node	not applicable
319.It KERN\_SYSVMSG	integer	no
320.It KERN\_SYSVSEM	integer	no
321.It KERN\_SYSVSHM	integer	no
322.It KERN\_TKSTAT	node	not applicable
323.It KERN\_VERSION	string	no
324.It KERN\_VNODE	struct vnode	no
325.El
326.ne 1i
327.Pp
328.Bl -tag -width "123456"
329.It Li KERN_ARGMAX
330The maximum bytes of argument to
331.Xr execve 2 .
332.It Li KERN_AUTONICETIME
333The number of seconds of cpu-time a non-root process may accumulate before
334having its priority lowered from the default to the value of KERN_AUTONICEVAL.
335If set to 0, automatic lowering of priority is not performed, and if set to -1
336all non-root processes are immediately lowered.
337.It Li KERN_AUTONICEVAL
338The priority assigned for automatically niced processes.
339.It Li KERN_BOOTTIME
340A
341.Va struct timeval
342structure is returned.
343This structure contains the time that the system was booted.
344.It Li KERN_CCPU
345The scheduler exponential decay value.
346.It Li KERN_CLOCKRATE
347A
348.Va struct clockinfo
349structure is returned.
350This structure contains the clock, statistics clock and profiling clock
351frequencies, the number of micro-seconds per hz tick, and the clock
352skew rate.
353.It Li KERN_CP_TIME
354Return an array if CPUSTATES longs is returned.  This array contains the
355number of clock ticks spent in different CPU states.
356.It Li KERN_DEFCORENAME
357Default template for the name of core dump files (see also PROC_PID_CORENAME
358in the per-process variables CTL_PROC, and
359.Xr core 5
360for format of this template).  The default value is
361.Nm %n.core
362and can be changed with the kernel configuration option
363.Cd options DEFCORENAME
364(see
365.Xr options 4
366).
367.It Li KERN_DOMAINNAME
368Get or set the YP domain name.
369.It Li KERN_FILE
370Return the entire file table.
371The returned data consists of a single
372.Va struct filehead
373followed by an array of
374.Va struct file ,
375whose size depends on the current number of such objects in the system.
376.It Li KERN_FSCALE
377The kernel fixed-point scale factor.
378.It Li KERN_FSYNC
379Return 1 if the POSIX 1003.1b File Synchronization Option is available
380on this system,
381otherwise 0.
382.It Li KERN_HOSTID
383Get or set the host id.
384.It Li KERN_HOSTNAME
385Get or set the hostname.
386.It Li KERN_IOV_MAX
387Return the maximum number of
388.Va iovec
389structures that a process has available for use with
390.Xr preadv 2 ,
391.Xr pwritev 2 ,
392.Xr readv 2 ,
393.Xr recvmsg 2 ,
394.Xr sendmsg 2
395and
396.Xr writev 2 .
397.It Li KERN_JOB_CONTROL
398Return 1 if job control is available on this system, otherwise 0.
399.It Li KERN_LOGIN_NAME_MAX
400The size of the storage required for a login name, in bytes,
401including the terminating NUL.
402.It Li KERN_LOGSIGEXIT
403If this flag is non-zero, the kernel will
404.Xr log 9
405all process exits due to signals which create a
406.Xr core 5
407file, and whether the coredump was created.
408.It Li KERN_MAPPED_FILES
409Returns 1 if the POSIX 1003.1b Memory Mapped Files Option is available
410on this system,
411otherwise 0.
412.It Li KERN_MAXFILES
413The maximum number of open files that may be open in the system.
414.It Li KERN_MAXPARTITIONS
415The maximum number of partitions allowed per disk.
416.It Li KERN_MAXPROC
417The maximum number of simultaneous processes the system will allow.
418.It Li KERN_MAXPTYS
419The maximum number of pseudo terminals. This value can be both
420raised and lowered, though it cannot
421be set lower than number of currently used ptys.  See also
422.Xr pty 4 .
423.It Li KERN_MAXVNODES
424The maximum number of vnodes available on the system. This can only
425be raised.
426.It Li KERN_MBUF
427Return information about the mbuf control variables.
428the third level names for the mbuf variables are detailed below.
429The changeable column shows whether a process with appropriate
430privilege may change the value.
431.Bl -column "MBUFXNMBCLUSTERSXXX" "struct integerXXX" -offset indent
432.It Sy Pa Third level name	Type	Changeable
433.It MBUF\_MSIZE	integer	yes
434.It MBUF\_MCLBYTES	integer	yes
435.It MBUF\_NMBCLUSTERS	integer	yes
436.It MBUF\_MBLOWAT	integer	yes
437.It MBUF\_MCLLOWAT	integer	yes
438.El
439.Pp
440The variables are as follows:
441.Bl -tag -width "123456"
442.It Li MBUF_MSIZE
443The mbuf base size.
444.It Li MBUF_MCLBYTES
445The mbuf cluster size.
446.It Li MBUF_NMBCLUSTERS
447The limit on the number of mbuf clusters.
448The variable can only be increased, and only increased on machines with
449direct-mapped pool pages
450.It Li MBUF_MBLOWAT
451The mbuf low water mark.
452.It Li MBUF_MCLLOWAT
453The mbuf cluster low water mark.
454.El
455.It Li KERN_MEMLOCK
456Returns 1 if the POSIX 1003.1b Process Memory Locking Option is available
457on this system,
458otherwise 0.
459.It Li KERN_MEMLOCK_RANGE
460Returns 1 if the POSIX 1003.1b Range Memory Locking Option is available
461on this system,
462otherwise 0.
463.It Li KERN_MEMORY_PROTECTION
464Returns 1 if the POSIX 1003.1b Memory Protection Option is available
465on this system,
466otherwise 0.
467.It Li KERN_MONOTONIC_CLOCK
468Returns the standard version the implementation of the POSIX 1003.1b
469Monotonic Clock Option conforms to,
470otherwise 0.
471.It Li KERN_MSGBUF
472The kernel message buffer, rotated so that the head of the circular kernel
473message buffer is returned at the start of the buffer specified by
474.Fa oldp .
475The returned data may contain NUL bytes.
476.It Li KERN_MSGBUFSIZE
477The maximum number of characters that the kernel message buffer can hold.
478.It Li KERN_NGROUPS
479The maximum number of supplemental groups.
480.It Li KERN_NO_TRUNC
481Return 1 if file names longer than KERN_NAME_MAX are truncated.
482.It Li KERN_NTPTIME
483A
484.Va struct ntptimeval
485structure is returned.
486This structure contains data used by the
487.Xr ntpd 8
488program.
489.It Li KERN_OSRELEASE
490The system release string.
491.It Li KERN_OSREV
492The system revision string.
493.It Li KERN_OSTYPE
494The system type string.
495.It Li KERN_PATH_MAX
496The maximum number of bytes in a pathname.
497.It Li KERN_POSIX1
498The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
499attempts to comply.
500.It Li KERN_PROC
501Return the entire process table, or a subset of it.
502An array of
503.Va struct kinfo_proc
504structures is returned,
505whose size depends on the current number of such objects in the system.
506The third and fourth level names are as follows:
507.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
508.It Pa Third level name	Fourth level is:
509.It KERN\_PROC\_ALL	None
510.It KERN\_PROC\_PID	A process ID
511.It KERN\_PROC\_PGRP	A process group
512.It KERN\_PROC\_SESSION	A session ID
513.It KERN\_PROC\_TTY	A tty device
514.It KERN\_PROC\_UID	A user ID
515.It KERN\_PROC\_RUID	A real user ID
516.It KERN\_PROC\_GID	A group ID
517.It KERN\_PROC\_RGID	A real group ID
518.El
519.It Li KERN_PROC2
520As for KERN_PROC, but an array of
521.Va struct kinfo_proc2
522structures are returned.  The fifth level name is the size of the
523.Va struct kinfo_proc2
524and the sixth level name is the number of structures to return.
525.It Li KERN_PROC_ARGS
526Return the argv or environment strings (or the number thereof)
527of a process.  Multiple strings are returned separated by NUL
528characters.  The third level name is the process ID.  The fourth
529level name is as follows:
530.Bl -column "Third level nameXXXXXX" -offset indent
531.It KERN\_PROC\_ARGV	The argv strings
532.It KERN\_PROC\_NARGV	The number of argv strings
533.It KERN\_PROC\_ENV	The environ strings
534.It KERN\_PROC\_NENV	The number of environ strings
535.El
536.It Li KERN_PROF
537Return profiling information about the kernel.
538If the kernel is not compiled for profiling,
539attempts to retrieve any of the KERN_PROF values will
540fail with EOPNOTSUPP.
541The third level names for the string and integer profiling information
542is detailed below.
543The changeable column shows whether a process with appropriate
544privilege may change the value.
545.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
546.It Sy Pa Third level name	Type	Changeable
547.It GPROF\_STATE	integer	yes
548.It GPROF\_COUNT	u_short[\|]	yes
549.It GPROF\_FROMS	u_short[\|]	yes
550.It GPROF\_TOS	struct tostruct	yes
551.It GPROF\_GMONPARAM	struct gmonparam	no
552.El
553.Pp
554The variables are as follows:
555.Bl -tag -width "123456"
556.It Li GPROF_STATE
557Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
558is running or stopped.
559.It Li GPROF_COUNT
560Array of statistical program counter counts.
561.It Li GPROF_FROMS
562Array indexed by program counter of call-from points.
563.It Li GPROF_TOS
564Array of
565.Va struct tostruct
566describing destination of calls and their counts.
567.It Li GPROF_GMONPARAM
568Structure giving the sizes of the above arrays.
569.El
570.It Li KERN_RAWPARTITION
571The raw partition of a disk (a == 0).
572.It Li KERN_ROOT_DEVICE
573The name of the root device.
574.It Li KERN_RTC_OFFSET
575Return the offset of real time clock from UTC in minutes.
576.It Li KERN_SAVED_IDS
577Returns 1 if saved set-group and saved set-user ID is available.
578.It Li KERN_SECURELVL
579The system security level.
580This level may be raised by processes with appropriate privilege.
581It may only be lowered by process 1.
582.It Li KERN_SYNCHRONIZED_IO
583Returns 1 if the POSIX 1003.1b Synchronized I/O Option is available
584on this system,
585otherwise 0.
586.It Li KERN_SYSVIPC_INFO
587Return System V style IPC configuration and run-time information.
588The third level name selects the System V style IPC facility.
589.Bl -column "KERN_SYSVIPC_MSG_INFOXXX" "struct shm_sysctl_infoXXX" -offset indent
590.It Sy Pa Third level name	Type
591.It KERN\_SYSVIPC\_MSG\_INFO	struct msg_sysctl_info
592.It KERN\_SYSVIPC\_SEM\_INFO	struct sem_sysctl_info
593.It KERN\_SYSVIPC\_SHM\_INFO	struct shm_sysctl_info
594.El
595.Pp
596.Bl -tag -width "123456"
597.It Li KERN_SYSVIPC_MSG_INFO
598Return information on the System V style message facility.  The
599.Sy msg_sysctl_info
600structure is defined in
601.Aq Pa sys/msg.h .
602.It Li KERN_SYSVIPC_SEM_INFO
603Return information on the System V style semaphore facility.  The
604.Sy sem_sysctl_info
605structure is defined in
606.Aq Pa sys/sem.h .
607.It Li KERN_SYSVIPC_SHM_INFO
608Return information on the System V style shared memory facility.  The
609.Sy shm_sysctl_info
610structure is defined in
611.Aq Pa sys/shm.h .
612.El
613.It Li KERN_SYSVMSG
614Returns 1 if System V style message queue functionality is available
615on this system,
616otherwise 0.
617.It Li KERN_SYSVSEM
618Returns 1 if System V style semaphore functionality is available
619on this system,
620otherwise 0.
621.It Li KERN_SYSVSHM
622Returns 1 if System V style share memory functionality is available
623on this system,
624otherwise 0.
625.It Li KERN_TKSTAT
626Return information about the number of characters sent and received
627on ttys.  The third level names for the tty statistic variables
628are detailed below.  The changeable column shows whether a process
629with appropriate privilege may change the value.
630.Bl -column "KERNXTKSTATXRAWCCXXX" "struct integerXXX" -offset indent
631.It Sy Pa Third level name	Type	Changeable
632.It KERN\_TKSTAT\_NIN	quad	no
633.It KERN\_TKSTAT\_NOUT	quad	no
634.It KERN\_TKSTAT\_CANCC	quad	no
635.It KERN\_TKSTAT\_RAWCC	quad	no
636.El
637.Pp
638The variables are as follows:
639.Bl -tag -width "123456"
640.It Li KERN_TKSTAT_NIN
641The total number of input characters.
642.It Li KERN_TKSTAT_NOUT
643The total number of output characters.
644.It Li KERN_TKSTAT_CANCC
645The number of canonical input characters.
646.It Li KERN_TKSTAT_RAWCC
647The number of raw input characters.
648.El
649.It Li KERN_VERSION
650The system version string.
651.It Li KERN_VNODE
652Return the entire vnode table.
653Note, the vnode table is not necessarily a consistent snapshot of
654the system.
655The returned data consists of an array whose size depends on the
656current number of such objects in the system.
657Each element of the array contains the kernel address of a vnode
658.Va struct vnode *
659followed by the vnode itself
660.Va struct vnode .
661.El
662.Sh CTL_MACHDEP
663The set of variables defined is architecture dependent.
664Most architectures define at least the following variables.
665.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
666.It Sy Pa Second level name	Type	Changeable
667.It Li CPU_CONSDEV	dev_t	no
668.El
669.Sh CTL_NET
670The string and integer information available for the CTL_NET level
671is detailed below.
672The changeable column shows whether a process with appropriate
673privilege may change the value.
674.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
675.It Sy Pa Second level name	Type	Changeable
676.It PF\_ROUTE	routing messages	no
677.It PF\_INET	IPv4 values	yes
678.It PF\_INET6	IPv6 values	yes
679.It PF\_KEY	IPsec key management values	yes
680.El
681.Pp
682.Bl -tag -width "123456"
683.It Li PF_ROUTE
684Return the entire routing table or a subset of it.
685The data is returned as a sequence of routing messages (see
686.Xr route 4
687for the header file, format and meaning).
688The length of each message is contained in the message header.
689.Pp
690The third level name is a protocol number, which is currently always 0.
691The fourth level name is an address family, which may be set to 0 to
692select all address families.
693The fifth and sixth level names are as follows:
694.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
695.It Pa Fifth level name	Sixth level is:
696.It NET\_RT\_FLAGS	rtflags
697.It NET\_RT\_DUMP	None
698.It NET\_RT\_IFLIST	None
699.El
700.It Li PF_INET
701Get or set various global information about the IPv4
702.Pq Internet Protocol version 4 .
703The third level name is the protocol.
704The fourth level name is the variable name.
705The currently defined protocols and names are:
706.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
707.It Pa Protocol name	Variable name	Type	Changeable
708.It ip	forwarding	integer	yes
709.It ip	redirect	integer	yes
710.It ip	ttl	integer	yes
711.It ip	forwsrcrt	integer	yes
712.It ip	directed-broadcast	integer	yes
713.It ip	allowsrcrt	integer	yes
714.It ip	subnetsarelocal	integer	yes
715.It ip	mtudisc	integer	yes
716.It ip	anonportmin	integer	yes
717.It ip	anonportmax	integer	yes
718.It ip	mtudisctimeout	integer	yes
719.It ip	gifttl	integer	yes
720.It ip	grettl	integer	yes
721.It ip	lowportmin	integer	yes
722.It ip	lowportmax	integer	yes
723.It ip	maxfragpacket	integer	yes
724.It icmp	maskrepl	integer	yes
725.It icmp	errppslimit	integer	yes
726.It icmp	rediraccept	integer	yes
727.It icmp	redirtimeout	integer	yes
728.It tcp	rfc1323	integer	yes
729.It tcp	sendspace	integer	yes
730.It tcp	recvspace	integer	yes
731.It tcp	mssdflt	integer	yes
732.It tcp	syn_cache_limit	integer	yes
733.It tcp	syn_bucket_limit	integer	yes
734.It tcp	syn_cache_interval	integer	yes
735.It tcp	init_win	integer	yes
736.It tcp	mss_ifmtu	integer	yes
737.It tcp	sack	integer	yes
738.It tcp	win_scale	integer	yes
739.It tcp	timestamps	integer	yes
740.It tcp	compat_42	integer	yes
741.It tcp	cwm	integer	yes
742.It tcp	cwm_burstsize	integer	yes
743.It tcp	ack_on_push	integer	yes
744.It tcp	keepidle	integer	yes
745.It tcp	keepintvl	integer	yes
746.It tcp	keepcnt	integer	yes
747.It tcp	slowhz	integer	no
748.It tcp	newreno	integer	yes
749.It tcp	log_refused	integer	yes
750.It tcp	rstppslimit	integer	yes
751.It udp	checksum	integer	yes
752.It udp	sendspace	integer	yes
753.It udp	recvspace	integer	yes
754.El
755.Pp
756The variables are as follows:
757.Bl -tag -width "123456"
758.It Li ip.forwarding
759Returns 1 when IP forwarding is enabled for the host,
760meaning that the host is acting as a router.
761.It Li ip.redirect
762Returns 1 when ICMP redirects may be sent by the host.
763This option is ignored unless the host is routing IP packets,
764and should normally be enabled on all systems.
765.It Li ip.ttl
766The maximum time-to-live (hop count) value for an IP packet sourced by
767the system.
768This value applies to normal transport protocols, not to ICMP.
769.It Li ip.forwsrcrt
770Returns 1 when forwarding of source-routed packets is enabled for
771the host.  This value may only be changed if the kernel security
772level is less than 1.
773.It Li ip.directed-broadcast
774Returns 1 if directed broadcast behavior is enabled for the host.
775.It Li ip.allowsrcrt
776Returns 1 if the host accepts source routed packets.
777.It Li ip.subnetsarelocal
778Returns 1 if subnets are to be considered local addresses.
779.It Li ip.mtudisc
780Returns 1 if Path MTU Discovery is enabled.
781.It Li ip.anonportmin
782The lowest port number to use for TCP and UDP ephemeral port allocation.
783This cannot be set to less than 1024 or greater than 65535.
784.It Li ip.anonportmax
785The highest port number to use for TCP and UDP ephemeral port allocation.
786This cannot be set to less than 1024 or greater than 65535, and must
787be greater than
788.Li ip.anonportmin .
789.It Li ip.mtudisctimeout
790Returns the number of seconds in which a route added by the Path MTU
791Discovery engine will time out.  When the route times out, the Path
792MTU Discovery engine will attempt to probe a larger path MTU.
793.It Li ip.gifttl
794The maximum time-to-live (hop count) value for an IPv4 packet generated by
795.Xr gif 4
796tunnel interface.
797.It Li ip.grettl
798The maximum time-to-live (hop count) value for an IPv4 packet generated by
799.Xr gre 4
800tunnel interface.
801.It Li ip.lowportmin
802The lowest port number to use for TCP and UDP reserved port allocation.
803This cannot be set to less than 0 or greater than 1024, and must
804be smaller than
805.Li ip.lowportmax .
806.It Li ip.lowportmax
807The highest port number to use for TCP and UDP reserved port allocation.
808This cannot be set to less than 0 or greater than 1024, and must
809be greater than
810.Li ip.lowportmin .
811.It Li ip.maxfragpackets
812The maximum number of fragmented packets the node will accept.
8130 means that the node will not accept any fragmented packets.
814-1 means that the node will accept as many fragmented packets as it receives.
815The flag is provided basically for avoiding possible DoS attacks.
816.It Li icmp.maskrepl
817Returns 1 if ICMP network mask requests are to be answered.
818.It Li icmp.errppslimit
819The variable specifies the maximum number of outgoing ICMP error messages,
820per second.
821ICMP error messages that exceeded the value are subject to rate limitation
822and will not go out from the node.
823Negative value disables rate limitation.
824.It Li icmp.rediraccept
825If set to non-zero, the host will accept ICMP redirect packets.
826Note that routers will never accept ICMP redirect packets,
827and the variable is meaningful on IP hosts only.
828.It Li icmp.redirtimeout
829The variable specifies lifetime of routing entries generated by incoming
830ICMP redirect.  This defaults to zero;  if the system is not running
831a routing daemon like
832.Xr routed 8
833than this value can be set to remove the routes added by redirect.
834A reasonable value to use would be 600 seconds.
835.It Li tcp.rfc1323
836Returns 1 if RFC1323 extensions to TCP are enabled.
837.It Li tcp.sendspace
838Returns the default TCP send buffer size.
839.It Li tcp.recvspace
840Returns the default TCP receive buffer size.
841.It Li tcp.mssdflt
842Returns the default maximum segment size both advertsized to the peer
843and to use when the peer does not advertize a maximum segment size to
844us during connection setup.  Do not change this value unless you really
845know what you are doing.
846.It Li tcp.syn_cache_limit
847Returns the maximum number of entries allowed in the TCP compressed state
848engine.
849.It Li tcp.syn_bucket_limit
850Returns the maximum number of entries allowed per hash bucket in the TCP
851compressed state engine.
852.It Li tcp.syn_cache_interval
853Returns the TCP compressed state engine's timer interval.
854.It Li tcp.init_win
855Returns a value indicating the TCP initial congestion window.  If this
856value is 0, an auto-tuning algorithm designed to use an initial window
857of approximately 4K bytes is in use.  Otherwise, this value indicates
858a fixed number of packets.
859.It Li tcp.mss_ifmtu
860Returns 1 if TCP calculates the outgoing maximum segment size based on
861the MTU of the appropriate interface.  Otherwise, it is calculated based on
862the greater of the MTU of the interface, and the largest (non-loopback)
863interface MTU on the system.
864.It Li tcp.sack
865TCP Selective ACKnowledgement (RFC 2018) is not implemented in
866.Nx
867at this time.
868Changing this value will have no effect.
869.It Li tcp.win_scale
870If rfc1323 is enabled, a value of 1 indicates RFC1323 window scale options,
871for increasing the TCP window size, are enabled.
872.It Li tcp.timestamps
873If rfc1323 is enabled, a value of 1 indicates RFC1323 time stamp options,
874used for measuring TCP round trip times, are enabled.
875.It Li tcp.compat_42
876Returns 1 if work-arounds for bugs in the 4.2BSD TCP implementation are
877enabled.  Use of this option is not recommended, although it may be
878required in order to communicate with extremely old TCP implementations.
879.It Li tcp.cwm
880Returns 1 if use of the Hughes/Touch/Heidemann Congestion Window Monitoring
881algorithm is enabled.  This algorithm prevents line-rate bursts of packets
882that could otherwise occur when data begins flowing on an idle TCP
883connection.  These line-rate bursts can contribute to network and router
884congestion.  This can be particularly useful on World Wide Web servers
885which support HTTP/1.1, which has lingering connections.
886.It Li tcp.cwm_burstsize
887Returns the Congestion Window Monitoring allowed burst size, in terms
888of packet count.
889.It Li tcp.ack_on_push
890Returns 1 if TCP is to immediately transmit an ACK upon reception of
891a packet with PUSH set.  This can avoid losing a round trip time in some
892rare situations, but has the caveat of potentially defeating TCP's delayed
893ACK algorithm.  Use of this option is generally not recommended, but
894the variable exists in case your configuration really needs it.
895.It Li tcp.keepidle
896Time a connection must be idle before keepalives are sent (if keepalives
897are enabled for the connection).  See also tcp.slowhz.
898.It Li tcp.keepintvl
899Time after a keepalive probe is sent until, in the absence of any response,
900another probe is sent.  See also tcp.slowhz.
901.It Li tcp.keepcnt
902Number of keepalive probes sent before declaring a connection dead.  If
903set to zero, there is no limit; keepalives will be sent until some kind of
904response is received from the peer.
905.It Li tcp.slowhz
906The units for tcp.keepidle and tcp.keepintvl; those variables are in ticks
907of a clock that ticks tcp.slowhz times per second.  (That is, their values
908must be divided by the tcp.slowhz value to get times in seconds.)
909.It Li tcp.newreno
910Returns 1 if the use of J. Hoe's NewReno congestion control algorithm is
911enabled.  This algorithm improves the start-up behavior of TCP connections.
912.It Li tcp.log_refused
913Returns 1 if refused TCP connections to the host will be logged.
914.It Li tcp.rstppslimit
915The variable specifies the maximum number of outgoing TCP RST packets,
916per second.
917TCP RST packet that exceeded the value are subject to rate limitation
918and will not go out from the node.
919Negative value disables rate limitation.
920.It Li udp.checksum
921Returns 1 when UDP checksums are being computed and checked.
922Disabling UDP checksums is strongly discouraged.
923.It Li udp.sendspace
924Returns the default UDP send buffer size.
925.It Li udp.recvspace
926Returns the default UDP receive buffer size.
927.El
928.Pp
929For variables net.*.ipsec, please refer to
930.Xr ipsec 4 .
931.It Li PF_INET6
932Get or set various global information about the IPv6
933.Pq Internet Protocol version 6 .
934The third level name is the protocol.
935The fourth level name is the variable name.
936The currently defined protocols and names are:
937.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
938.It Pa Protocol name	Variable name	Type	Changeable
939.It ip6	forwarding	integer	yes
940.It ip6	redirect	integer	yes
941.It ip6	hlim	integer	yes
942.It ip6	maxfragpackets	integer	yes
943.It ip6	accept_rtadv	integer	yes
944.It ip6	keepfaith	integer	yes
945.It ip6	log_interval	integer	yes
946.It ip6	hdrnestlimit	integer	yes
947.It ip6	dad_count	integer	yes
948.It ip6	auto_flowlabel	integer	yes
949.It ip6	defmcasthlim	integer	yes
950.It ip6	gif_hlim	integer	yes
951.It ip6	kame_version	string	no
952.It ip6	use_deprecated	integer	yes
953.It ip6	rr_prune	integer	yes
954.It ip6	v6only	integer	yes
955.It ip6	anonportmin	integer	yes
956.It ip6	anonportmax	integer	yes
957.It ip6	lowportmin	integer	yes
958.It ip6	lowportmax	integer	yes
959.It ip6	maxfrags	integer	yes
960.It icmp6	rediraccept	integer	yes
961.It icmp6	redirtimeout	integer	yes
962.It icmp6	nd6_prune	integer	yes
963.It icmp6	nd6_delay	integer	yes
964.It icmp6	nd6_umaxtries	integer	yes
965.It icmp6	nd6_mmaxtries	integer	yes
966.It icmp6	nd6_useloopback	integer	yes
967.It icmp6	nodeinfo	integer	yes
968.It icmp6	errppslimit	integer	yes
969.It icmp6	nd6_maxnudhint	integer	yes
970.It icmp6	mtudisc_hiwat	integer	yes
971.It icmp6	mtudisc_lowat	integer	yes
972.It icmp6	nd6_debug	integer	yes
973.It udp6	sendspace	integer	yes
974.It udp6	recvspace	integer	yes
975.El
976.Pp
977The variables are as follows:
978.Bl -tag -width "123456"
979.It Li ip6.forwarding
980Returns 1 when IPv6 forwarding is enabled for the node,
981meaning that the node is acting as a router.
982Returns 0 when IPv6 forwarding is disabled for the node,
983meaning that the node is acting as a host.
984IPv6 specification defines node behavior for
985.Dq router
986case and
987.Dq host
988case quite differently, and changing this variable during operation
989may cause serious trouble.
990It is recommended to configure the variable at bootstrap time,
991and bootstrap time only.
992.It Li ip6.redirect
993Returns 1 when ICMPv6 redirects may be sent by the node.
994This option is ignored unless the node is routing IP packets,
995and should normally be enabled on all systems.
996.It Li ip6.hlim
997The default hop limit value for an IPv6 unicast packet sourced by the node.
998This value applies to all the transport protocols on top of IPv6.
999There are APIs to override the value, as documented in
1000.Xr ip6 4 .
1001.It Li ip6.maxfragpackets
1002The maximum number of fragmented packets the node will accept.
10030 means that the node will not accept any fragmented packets.
1004-1 means that the node will accept as many fragmented packets as it receives.
1005The flag is provided basically for avoiding possible DoS attacks.
1006.It Li ip6.accept_rtadv
1007If set to non-zero, the node will accept ICMPv6 router advertisement packets
1008and autoconfigures address prefixes and default routers.
1009The node must be a host
1010.Pq not a router
1011for the option to be meaningful.
1012.It Li ip6.keepfaith
1013If set to non-zero, it enables
1014.Dq FAITH
1015TCP relay IPv6-to-IPv4 translator code in the kernel.
1016Refer
1017.Xr faith 4
1018and
1019.Xr faithd 8
1020for detail.
1021.It Li ip6.log_interval
1022The variable controls amount of logs generated by IPv6 packet
1023forwarding engine, by seting interval between log output
1024.Pq in seconds .
1025.It Li ip6.hdrnestlimit
1026The number of IPv6 extension headers permitted on incoming IPv6 packets.
1027If set to 0, the node will accept as many extension headers as possible.
1028.It Li ip6.dad_count
1029The variable cofigures number of IPv6 DAD
1030.Pq duplicated address detection
1031probe packets.
1032The packets will be generated when IPv6 interface addresses are configured.
1033.It Li ip6.auto_flowlabel
1034On connected transport protocol packets,
1035fill IPv6 flowlabel field to help intermediate routers to identify packet flows.
1036.It Li ip6.defmcasthlim
1037The default hop limit value for an IPv6 multicast packet sourced by the node.
1038This value applies to all the transport protocols on top of IPv6.
1039There are APIs to override the value, as documented in
1040.Xr ip6 4 .
1041.It Li ip6.gif_hlim
1042The maximum hop limit value for an IPv6 packet generated by
1043.Xr gif 4
1044tunnel interface.
1045.It Li ip6.kame_version
1046The string identifies the version of KAME IPv6 stack implemented in the kernel.
1047.It Li ip6.use_deprecated
1048The variable controls use of deprecated address, specified in RFC2462 5.5.4.
1049.It Li ip6.rr_prune
1050The variable specifies interval between IPv6 router renumbering prefix
1051babysitting, in seconds.
1052.It Li ip6.v6only
1053The variable specifies initial value for
1054.Dv IPV6_V6ONLY
1055socket option for
1056.Dv AF_INET6
1057socket.
1058Please refer to
1059.Xr ip6 4
1060for detail.
1061.It Li ip6.anonportmin
1062The lowest port number to use for TCP and UDP ephemeral port allocation.
1063This cannot be set to less than 1024 or greater than 65535.
1064.It Li ip6.anonportmax
1065The highest port number to use for TCP and UDP ephemeral port allocation.
1066This cannot be set to less than 1024 or greater than 65535, and must
1067be greater than
1068.Li ip6.anonportmin .
1069.It Li ip6.lowportmin
1070The lowest port number to use for TCP and UDP reserved port allocation.
1071This cannot be set to less than 0 or greater than 1024, and must
1072be smaller than
1073.Li ip6.lowportmax .
1074.It Li ip6.lowportmax
1075The highest port number to use for TCP and UDP reserved port allocation.
1076This cannot be set to less than 0 or greater than 1024, and must
1077be greater than
1078.Li ip6.lowportmin .
1079.It Li ip6.maxfrags
1080The maximum number of fragments the node will accept.
10810 means that the node will not accept any fragments.
1082-1 means that the node will accept as many fragments as it receives.
1083The flag is provided basically for avoiding possible DoS attacks.
1084.It Li icmp6.rediraccept
1085If set to non-zero, the host will accept ICMPv6 redirect packets.
1086Note that IPv6 routers will never accept ICMPv6 redirect packets,
1087and the variable is meaningful on IPv6 hosts
1088.Pq non-router
1089only.
1090.It Li icmp6.redirtimeout
1091The variable specifies lifetime of routing entries generated by incoming
1092ICMPv6 redirect.
1093.It Li icmp6.nd6_prune
1094The variable specifies interval between IPv6 neighbor cache babysitting,
1095in seconds.
1096.It Li icmp6.nd6_delay
1097The variable specifies
1098.Dv DELAY_FIRST_PROBE_TIME
1099timing constant in IPv6 neighbor discovery specification
1100.Pq RFC2461 ,
1101in seconds.
1102.It Li icmp6.nd6_umaxtries
1103The variable specifies
1104.Dv MAX_UNICAST_SOLICIT
1105constant in IPv6 neighbor discovery specification
1106.Pq RFC2461 .
1107.It Li icmp6.nd6_mmaxtries
1108The variable specifies
1109.Dv MAX_MULTICAST_SOLICIT
1110constant in IPv6 neighbor discovery specification
1111.Pq RFC2461 .
1112.It Li icmp6.nd6_useloopback
1113If set to non-zero, kernel IPv6 stack will use loopback interface for
1114local traffic.
1115.It Li icmp6.nodeinfo
1116The variable enables responses to ICMPv6 node information queries.
1117If you set the variable to 0, reponses will not be generated for
1118ICMPv6 node information queries.
1119Since node information queries can have a security impact, it is
1120possible to fine tune which responses should be answered.
1121Two separate bits can be set.
1122.Bl -tag -width "12345"
1123.It 1
1124Respond to ICMPv6 FQDN queries, e.g.
1125.Li ping6 -w .
1126.It 2
1127Respond to ICMPv6 node addresses queries, e.g.
1128.Li ping6 -a .
1129.El
1130.It Li icmp6.errppslimit
1131The variable specifies the maximum number of outgoing ICMPv6 error messages,
1132per second.
1133ICMPv6 error messages that exceeded the value are subject to rate limitation
1134and will not go out from the node.
1135Negative value disables rate limitation.
1136.It Li icmp6.nd6_maxnudhint
1137IPv6 neighbor discovery permits upper layer protocols to supply reachability
1138hints, to avoid unnecessary neighbor discovery exchanges.
1139The variable defines the number of consecutive hints the neighbor discovery
1140layer will take.
1141For example, by setting the variable to 3, neighbor discovery layer
1142will take 3 consecutive hints in maximum.
1143After receiving 3 hints, neighbor discovery layer will perform
1144normal neighbor discovery process.
1145.It Li icmp6.mtudisc_hiwat
1146.It Li icmp6.mtudisc_lowat
1147The variables define the maximum number of routing table entries,
1148created due to path MTU discovery
1149.Pq prevents denial-of-service attacks with ICMPv6 too big messages .
1150When IPv6 path MTU discovery happens, we keep path MTU information into
1151the routing table.
1152If the number of routing table entries exceed the value,
1153the kernel will not attempt to keep the path MTU information.
1154.Li icmp6.mtudisc_hiwat
1155is used when we have verified ICMPv6 too big messages.
1156.Li icmp6.mtudisc_lowat
1157is used when we have unverified ICMPv6 too big messages.
1158Verification is performed by using address/port pairs kept in connected pcbs.
1159Negative value disables the upper limit.
1160.It Li icmp6.nd6_debug
1161If set to non-zero, kernel IPv6 neighbor discovery code will generate
1162debugging messages.
1163The debug outputs are useful to diagnose IPv6 interoperability issues.
1164The flag must be set to 0 for normal operation.
1165.El
1166.Pp
1167We reuse net.*.tcp for
1168.Tn TCP
1169over
1170.Tn IPv6 ,
1171and therefore we do not have variables net.*.tcp6.
1172Variables net.inet6.udp6 have identical meaning to net.inet.udp.
1173Please refer to
1174.Li PF_INET
1175section above.
1176For variables net.*.ipsec6, please refer to
1177.Xr ipsec 4 .
1178.It Li PF_KEY
1179Get or set various global information about the IPsec key management.
1180The third level name is the variable name.
1181The currently defined variable and names are:
1182.Bl -column "blockacq_lifetime" "integer" "yes" -offset indent
1183.It Pa Variable name	Type	Changeable
1184.It debug	integer	yes
1185.It spi_try	integer	yes
1186.It spi_min_value	integer	yes
1187.It spi_max_value	integer	yes
1188.It random_int	integer	yes
1189.It larval_lifetime	integer	yes
1190.It blockacq_count	integer	yes
1191.It blockacq_lifetime	integer	yes
1192.It esp_keymin	integer	yes
1193.It esp_auth	integer	yes
1194.It ah_keymin	integer	yes
1195.El
1196The variables are as follows:
1197.Bl -tag -width "123456"
1198.It Li debug
1199Turn on debugging message from within the kernel.
1200The value is a bitmap, as defined in
1201.Pa /usr/include/netkey/key_debug.h .
1202.It Li spi_try
1203The number of times the kernel will try to obtain an unique SPI
1204when it generates it from random number generator.
1205.It Li spi_min_value
1206Minimum SPI value when generating it within the kernel.
1207.It Li spi_max_value
1208Maximum SPI value when generating it within the kernel.
1209.It Li random_int
1210Interval to stir pseudo-random number generator, in seconds.
1211Pseudo-random number generator is used only as a last resort when
1212random number source
1213.Pq Pa /dev/urandom
1214is not available.
1215It should not really be used, and if it were used,
1216kernel will warn about it.
1217.It Li larval_lifetime
1218Lifetime for LARVAL SAD entries, in seconds.
1219.It Li blockacq_count
1220Number of ACQUIRE PF_KEY messages to be blocked after an ACQUIRE message.
1221It avoids flood of ACQUIRE PF_KEY from being sent from the kernel to the
1222key management daemon.
1223.It Li blockacq_lifetime
1224Lifetime of ACQUIRE PF_KEY message.
1225.It Li esp_keymin
1226Minimum ESP key length, in bits.
1227The value is used when the kernel creates proposal payload
1228on ACQUIRE PF_KEY message.
1229.It Li esp_auth
1230Whether ESP authentication should be used or not.
1231Non-zero value indicates that ESP authentication should be used.
1232The value is used when the kernel creates proposal payload
1233on ACQUIRE PF_KEY message.
1234.It Li ah_keymin
1235Minimum AH key length, in bits,
1236The value is used when the kernel creates proposal payload
1237on ACQUIRE PF_KEY message.
1238.El
1239.El
1240.Sh CTL_PROC
1241The string and integer information available for the CTL_PROC
1242is detailed below.
1243The changeable column shows whether a process with appropriate
1244privilege may change the value.
1245These values are per-process, and as such may change from one process
1246to another. When a process is created, the default values are inherited from
1247its parent. When a set-user-ID or set-group-ID binary is executed, the
1248value of PROC_PID_CORENAME is reset to the system default value.
1249The second level name is either the magic value PROC_CURPROC, which
1250points to the current process, or the PID of the target process.
1251.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" "yes" -offset indent
1252.It Sy Pa Third level name	Type	Changeable
1253.It PROC\_PID\_CORENAME	string	yes
1254.It PROC\_PID\_LIMIT	node	not applicable
1255.El
1256.Bl -tag -width "123456"
1257.Pp
1258.It Li PROC_PID_CORENAME
1259The template used for the core dump file name (see
1260.Xr core 5
1261for details). The base name must either be
1262.Nm core
1263or end with the suffix ``.core'' (the super-user may set arbitrary names). By
1264default it points to KERN_DEFCORENAME.
1265.It Li PROC_PID_LIMIT
1266Return resources limits, as defined for the
1267.Xr getrlimit 2
1268and
1269.Xr setrlimit 2
1270system calls.
1271The fourth level name is one of:
1272.Bl -tag -width PROC_PID_LIMIT_MEMLOCKAA
1273.It Li PROC_PID_LIMIT_CPU
1274The maximum amount of cpu time (in seconds) to be used by each process.
1275.It Li PROC_PID_LIMIT_FSIZE
1276The largest size (in bytes) file that may be created.
1277.It Li PROC_PID_LIMIT_DATA
1278The maximum size (in bytes) of the data segment for a process;
1279this defines how far a program may extend its break with the
1280.Xr sbrk 2
1281system call.
1282.It Li PROC_PID_LIMIT_STACK
1283The maximum size (in bytes) of the stack segment for a process;
1284this defines how far a program's stack segment may be extended.
1285Stack extension is performed automatically by the system.
1286.It Li PROC_PID_LIMIT_CORE
1287The largest size (in bytes)
1288.Pa core
1289file that may be created.
1290.It Li PROC_PID_LIMIT_RSS
1291The maximum size (in bytes) to which a process's resident set size may
1292grow.
1293This imposes a limit on the amount of physical memory to be given to
1294a process; if memory is tight, the system will prefer to take memory
1295from processes that are exceeding their declared resident set size.
1296.It Li PROC_PID_LIMIT_MEMLOCK
1297The maximum size (in bytes) which a process may lock into memory
1298using the
1299.Xr mlock 2
1300function.
1301.It Li PROC_PID_LIMIT_NPROC
1302The maximum number of simultaneous processes for this user id.
1303.It Li PROC_PID_LIMIT_NOFILE
1304The maximum number of open files for this process.
1305.El
1306.Pp
1307The fifth level name is one of PROC_PID_LIMIT_TYPE_SOFT or
1308PROC_PID_LIMIT_TYPE_HARD, to select respectively the soft or hard limit.
1309Both are of type integer.
1310.El
1311.Sh CTL_USER
1312The string and integer information available for the CTL_USER level
1313is detailed below.
1314The changeable column shows whether a process with appropriate
1315privilege may change the value.
1316.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
1317.It Sy Pa Second level name	Type	Changeable
1318.It USER\_BC\_BASE\_MAX	integer	no
1319.It USER\_BC\_DIM\_MAX	integer	no
1320.It USER\_BC\_SCALE\_MAX	integer	no
1321.It USER\_BC\_STRING\_MAX	integer	no
1322.It USER\_COLL\_WEIGHTS\_MAX	integer	no
1323.It USER\_CS\_PATH	string	no
1324.It USER\_EXPR\_NEST\_MAX	integer	no
1325.It USER\_LINE\_MAX	integer	no
1326.It USER\_POSIX2\_CHAR\_TERM	integer	no
1327.It USER\_POSIX2\_C\_BIND	integer	no
1328.It USER\_POSIX2\_C\_DEV	integer	no
1329.It USER\_POSIX2\_FORT\_DEV	integer	no
1330.It USER\_POSIX2\_FORT\_RUN	integer	no
1331.It USER\_POSIX2\_LOCALEDEF	integer	no
1332.It USER\_POSIX2\_SW\_DEV	integer	no
1333.It USER\_POSIX2\_UPE	integer	no
1334.It USER\_POSIX2\_VERSION	integer	no
1335.It USER\_RE\_DUP\_MAX	integer	no
1336.It USER\_STREAM\_MAX	integer	no
1337.It USER\_TZNAME\_MAX	integer	no
1338.El
1339.Bl -tag -width "123456"
1340.Pp
1341.It Li USER_BC_BASE_MAX
1342The maximum ibase/obase values in the
1343.Xr bc 1
1344utility.
1345.It Li USER_BC_DIM_MAX
1346The maximum array size in the
1347.Xr bc 1
1348utility.
1349.It Li USER_BC_SCALE_MAX
1350The maximum scale value in the
1351.Xr bc 1
1352utility.
1353.It Li USER_BC_STRING_MAX
1354The maximum string length in the
1355.Xr bc 1
1356utility.
1357.It Li USER_COLL_WEIGHTS_MAX
1358The maximum number of weights that can be assigned to any entry of
1359the LC_COLLATE order keyword in the locale definition file.
1360.It Li USER_CS_PATH
1361Return a value for the
1362.Ev PATH
1363environment variable that finds all the standard utilities.
1364.It Li USER_EXPR_NEST_MAX
1365The maximum number of expressions that can be nested within
1366parenthesis by the
1367.Xr expr 1
1368utility.
1369.It Li USER_LINE_MAX
1370The maximum length in bytes of a text-processing utility's input
1371line.
1372.It Li USER_POSIX2_CHAR_TERM
1373Return 1 if the system supports at least one terminal type capable of
1374all operations described in POSIX 1003.2, otherwise 0.
1375.It Li USER_POSIX2_C_BIND
1376Return 1 if the system's C-language development facilities support the
1377C-Language Bindings Option, otherwise 0.
1378.It Li USER_POSIX2_C_DEV
1379Return 1 if the system supports the C-Language Development Utilities Option,
1380otherwise 0.
1381.It Li USER_POSIX2_FORT_DEV
1382Return 1 if the system supports the FORTRAN Development Utilities Option,
1383otherwise 0.
1384.It Li USER_POSIX2_FORT_RUN
1385Return 1 if the system supports the FORTRAN Runtime Utilities Option,
1386otherwise 0.
1387.It Li USER_POSIX2_LOCALEDEF
1388Return 1 if the system supports the creation of locales, otherwise 0.
1389.It Li USER_POSIX2_SW_DEV
1390Return 1 if the system supports the Software Development Utilities Option,
1391otherwise 0.
1392.It Li USER_POSIX2_UPE
1393Return 1 if the system supports the User Portability Utilities Option,
1394otherwise 0.
1395.It Li USER_POSIX2_VERSION
1396The version of POSIX 1003.2 with which the system attempts to comply.
1397.It Li USER_RE_DUP_MAX
1398The maximum number of repeated occurrences of a regular expression
1399permitted when using interval notation.
1400.ne 1i
1401.It Li USER_STREAM_MAX
1402The minimum maximum number of streams that a process may have open
1403at any one time.
1404.It Li USER_TZNAME_MAX
1405The minimum maximum number of types supported for the name of a
1406timezone.
1407.El
1408.Sh CTL_VM
1409The string and integer information available for the CTL_VM level
1410is detailed below.
1411The changeable column shows whether a process with appropriate
1412privilege may change the value.
1413.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
1414.It Sy Pa Second level name	Type	Changeable
1415.It VM\_ANONMAX	int	yes
1416.It VM\_ANONMIN	int	yes
1417.It VM\_EXECMAX	int	yes
1418.It VM\_EXECMIN	int	yes
1419.It VM\_FILEMAX	int	yes
1420.It VM\_FILEMIN	int	yes
1421.It VM\_LOADAVG	struct loadavg	no
1422.It VM\_MAXSLP	int	no
1423.It VM\_METER	struct vmtotal	no
1424.It VM\_NKMEMPAGES	int	no
1425.It VM\_USPACE	int	no
1426.It VM\_UVMEXP	struct uvmexp	no
1427.It VM\_UVMEXP2	struct uvmexp_sysctl	no
1428.El
1429.Pp
1430.Bl -tag -width "123456"
1431.It Li VM_ANONMAX
1432The percentage of physical memory which will be reclaimed
1433from other types of memory usage to store anonymous application data.
1434.It Li VM_ANONMIN
1435The percentage of physical memory which will be always be available for
1436anonymous application data.
1437.It Li VM_EXECMAX
1438The percentage of physical memory which will be reclaimed
1439from other types of memory usage to store cached executable data.
1440.It Li VM_EXECMIN
1441The percentage of physical memory which will be always be available for
1442cached executable data.
1443.It Li VM_FILEMAX
1444The percentage of physical memory which will be reclaimed
1445from other types of memory usage to store cached file data.
1446.It Li VM_FILEMIN
1447The percentage of physical memory which will be always be available for
1448cached file data.
1449.It Li VM_LOADAVG
1450Return the load average history.
1451The returned data consists of a
1452.Va struct loadavg .
1453.It Li VM_MAXSLP
1454The value of the maxslp kernel global variable.
1455.It Li VM_METER
1456Return system wide virtual memory statistics.
1457The returned data consists of a
1458.Va struct vmtotal .
1459.It Li VM_USPACE
1460The number of bytes allocated for each kernel stack.
1461.It Li VM_UVMEXP
1462Return system wide virtual memory statistics.
1463The returned data consists of a
1464.Va struct uvmexp .
1465.It Li VM_UVMEXP2
1466Return system wide virtual memory statistics.
1467The returned data consists of a
1468.Va struct uvmexp_sysctl .
1469.El
1470.Sh CTL_DDB
1471The integer information available for the CTL_DDB level is detailed below.
1472The changeable column shows whether a process with appropriate
1473privilege may change the value.
1474.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
1475.It Sy Pa Second level name	Type	Changeable
1476.It DBCTL\_RADIX	integer	yes
1477.It DBCTL\_MAXOFF	integer	yes
1478.It DBCTL\_LINES	integer	yes
1479.It DBCTL\_TABSTOPS	integer	yes
1480.It DBCTL\_ONPANIC	integer	yes
1481.It DBCTL\_FROMCONSOLE	integer	yes
1482.El
1483.Pp
1484.Bl -tag -width "123456"
1485.It Li DBCTL_RADIX
1486The input and output radix.
1487.It Li DBCTL_MAXOFF
1488The maximum symbol offset.
1489.It Li DBCTL_LINES
1490Number of display lines.
1491.It Li DBCTL_TABSTOPS
1492Tab width.
1493.It Li DBCTL_ONPANIC
1494If non-zero, DDB will be entered when the kernel panics.
1495.It Li DBCTL_FROMCONSOLE
1496If not zero, DDB may be entered by sending a break on a serial
1497console or by a special key sequence on a graphics console.
1498.El
1499.Pp
1500These MIB nodes are also available as variables from within the
1501DDB.  See
1502.Xr ddb 4
1503for more details.
1504.Sh CTL_VENDOR
1505The "vendor" toplevel name is reserved to be used by vendors who wish to
1506have their own private MIB tree. Intended use is to store values under
1507.Dq vendor.\*[Lt]yourname\*[Gt].* .
1508.Sh RETURN VALUES
1509If the call to
1510.Nm
1511is successful, the number of bytes copied out is returned.
1512Otherwise \-1 is returned and
1513.Va errno
1514is set appropriately.
1515.Sh FILES
1516.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact
1517.It Pa Aq sys/sysctl.h
1518definitions for top level identifiers, second level kernel and hardware
1519identifiers, and user level identifiers
1520.It Pa Aq sys/socket.h
1521definitions for second level network identifiers
1522.It Pa Aq sys/gmon.h
1523definitions for third level profiling identifiers
1524.It Pa Aq uvm/uvm_param.h
1525definitions for second level virtual memory identifiers
1526.It Pa Aq netinet/in.h
1527definitions for third level IPv4/v6 identifiers and
1528fourth level IPv4/v6 identifiers
1529.It Pa Aq netinet/icmp_var.h
1530definitions for fourth level ICMP identifiers
1531.It Pa Aq netinet/icmp6.h
1532definitions for fourth level ICMPv6 identifiers
1533.It Pa Aq netinet/tcp_var.h
1534definitions for fourth level TCP identifiers
1535.It Pa Aq netinet/udp_var.h
1536definitions for fourth level UDP identifiers
1537.It Pa Aq netinet6/udp6_var.h
1538definitions for fourth level IPv6 UDP identifiers
1539.It Pa Aq netinet6/ipsec.h
1540definitions for fourth level IPsec identifiers
1541.It Pa Aq netkey/key_var.h
1542definitions for third level PF_KEY identifiers
1543.El
1544.Sh ERRORS
1545The following errors may be reported:
1546.Bl -tag -width Er
1547.It Bq Er EFAULT
1548The buffer
1549.Fa name ,
1550.Fa oldp ,
1551.Fa newp ,
1552or length pointer
1553.Fa oldlenp
1554contains an invalid address.
1555.It Bq Er EINVAL
1556The
1557.Fa name
1558array is less than two or greater than CTL_MAXNAME.
1559.It Bq Er EINVAL
1560A non-null
1561.Fa newp
1562is given and its specified length in
1563.Fa newlen
1564is too large or too small.
1565.It Bq Er ENOMEM
1566The length pointed to by
1567.Fa oldlenp
1568is too short to hold the requested value.
1569.It Bq Er ENOTDIR
1570The
1571.Fa name
1572array specifies an intermediate rather than terminal name.
1573.It Bq Er EOPNOTSUPP
1574The
1575.Fa name
1576array specifies a value that is unknown.
1577.It Bq Er EPERM
1578An attempt is made to set a read-only value.
1579.It Bq Er EPERM
1580A process without appropriate privilege attempts to set a value.
1581.It Bq Er EPERM
1582An attempt to change a value protected by the current kernel security
1583level is made.
1584.El
1585.Sh SEE ALSO
1586.Xr ipsec 4 ,
1587.Xr sysctl 8
1588.Sh HISTORY
1589The
1590.Nm
1591function first appeared in
1592.Bx 4.4 .
1593