xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision 8a705cc17d9661734a1beae130cdbb7daf4a7d17)
1.\"	$NetBSD: sysctl.3,v 1.93 2002/05/19 08:12:55 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 icmp6	rediraccept	integer	yes
960.It icmp6	redirtimeout	integer	yes
961.It icmp6	nd6_prune	integer	yes
962.It icmp6	nd6_delay	integer	yes
963.It icmp6	nd6_umaxtries	integer	yes
964.It icmp6	nd6_mmaxtries	integer	yes
965.It icmp6	nd6_useloopback	integer	yes
966.It icmp6	nodeinfo	integer	yes
967.It icmp6	errppslimit	integer	yes
968.It icmp6	nd6_maxnudhint	integer	yes
969.It icmp6	mtudisc_hiwat	integer	yes
970.It icmp6	mtudisc_lowat	integer	yes
971.It icmp6	nd6_debug	integer	yes
972.It udp6	sendspace	integer	yes
973.It udp6	recvspace	integer	yes
974.El
975.Pp
976The variables are as follows:
977.Bl -tag -width "123456"
978.It Li ip6.forwarding
979Returns 1 when IPv6 forwarding is enabled for the node,
980meaning that the node is acting as a router.
981Returns 0 when IPv6 forwarding is disabled for the node,
982meaning that the node is acting as a host.
983IPv6 specification defines node behavior for
984.Dq router
985case and
986.Dq host
987case quite differently, and changing this variable during operation
988may cause serious trouble.
989It is recommended to configure the variable at bootstrap time,
990and bootstrap time only.
991.It Li ip6.redirect
992Returns 1 when ICMPv6 redirects may be sent by the node.
993This option is ignored unless the node is routing IP packets,
994and should normally be enabled on all systems.
995.It Li ip6.hlim
996The default hop limit value for an IPv6 unicast packet sourced by the node.
997This value applies to all the transport protocols on top of IPv6.
998There are APIs to override the value, as documented in
999.Xr ip6 4 .
1000.It Li ip6.maxfragpackets
1001The maximum number of fragmented packets the node will accept.
10020 means that the node will not accept any fragmented packets.
1003-1 means that the node will accept as many fragmented packets as it receives.
1004The flag is provided basically for avoiding possible DoS attacks.
1005.It Li ip6.accept_rtadv
1006If set to non-zero, the node will accept ICMPv6 router advertisement packets
1007and autoconfigures address prefixes and default routers.
1008The node must be a host
1009.Pq not a router
1010for the option to be meaningful.
1011.It Li ip6.keepfaith
1012If set to non-zero, it enables
1013.Dq FAITH
1014TCP relay IPv6-to-IPv4 translator code in the kernel.
1015Refer
1016.Xr faith 4
1017and
1018.Xr faithd 8
1019for detail.
1020.It Li ip6.log_interval
1021The variable controls amount of logs generated by IPv6 packet
1022forwarding engine, by seting interval between log output
1023.Pq in seconds .
1024.It Li ip6.hdrnestlimit
1025The number of IPv6 extension headers permitted on incoming IPv6 packets.
1026If set to 0, the node will accept as many extension headers as possible.
1027.It Li ip6.dad_count
1028The variable cofigures number of IPv6 DAD
1029.Pq duplicated address detection
1030probe packets.
1031The packets will be generated when IPv6 interface addresses are configured.
1032.It Li ip6.auto_flowlabel
1033On connected transport protocol packets,
1034fill IPv6 flowlabel field to help intermediate routers to identify packet flows.
1035.It Li ip6.defmcasthlim
1036The default hop limit value for an IPv6 multicast packet sourced by the node.
1037This value applies to all the transport protocols on top of IPv6.
1038There are APIs to override the value, as documented in
1039.Xr ip6 4 .
1040.It Li ip6.gif_hlim
1041The maximum hop limit value for an IPv6 packet generated by
1042.Xr gif 4
1043tunnel interface.
1044.It Li ip6.kame_version
1045The string identifies the version of KAME IPv6 stack implemented in the kernel.
1046.It Li ip6.use_deprecated
1047The variable controls use of deprecated address, specified in RFC2462 5.5.4.
1048.It Li ip6.rr_prune
1049The variable specifies interval between IPv6 router renumbering prefix
1050babysitting, in seconds.
1051.It Li ip6.v6only
1052The variable specifies initial value for
1053.Dv IPV6_V6ONLY
1054socket option for
1055.Dv AF_INET6
1056socket.
1057Please refer to
1058.Xr ip6 4
1059for detail.
1060.It Li ip6.anonportmin
1061The lowest port number to use for TCP and UDP ephemeral port allocation.
1062This cannot be set to less than 1024 or greater than 65535.
1063.It Li ip6.anonportmax
1064The highest port number to use for TCP and UDP ephemeral port allocation.
1065This cannot be set to less than 1024 or greater than 65535, and must
1066be greater than
1067.Li ip6.anonportmin .
1068.It Li ip6.lowportmin
1069The lowest port number to use for TCP and UDP reserved port allocation.
1070This cannot be set to less than 0 or greater than 1024, and must
1071be smaller than
1072.Li ip6.lowportmax .
1073.It Li ip6.lowportmax
1074The highest port number to use for TCP and UDP reserved port allocation.
1075This cannot be set to less than 0 or greater than 1024, and must
1076be greater than
1077.Li ip6.lowportmin .
1078.It Li icmp6.rediraccept
1079If set to non-zero, the host will accept ICMPv6 redirect packets.
1080Note that IPv6 routers will never accept ICMPv6 redirect packets,
1081and the variable is meaningful on IPv6 hosts
1082.Pq non-router
1083only.
1084.It Li icmp6.redirtimeout
1085The variable specifies lifetime of routing entries generated by incoming
1086ICMPv6 redirect.
1087.It Li icmp6.nd6_prune
1088The variable specifies interval between IPv6 neighbor cache babysitting,
1089in seconds.
1090.It Li icmp6.nd6_delay
1091The variable specifies
1092.Dv DELAY_FIRST_PROBE_TIME
1093timing constant in IPv6 neighbor discovery specification
1094.Pq RFC2461 ,
1095in seconds.
1096.It Li icmp6.nd6_umaxtries
1097The variable specifies
1098.Dv MAX_UNICAST_SOLICIT
1099constant in IPv6 neighbor discovery specification
1100.Pq RFC2461 .
1101.It Li icmp6.nd6_mmaxtries
1102The variable specifies
1103.Dv MAX_MULTICAST_SOLICIT
1104constant in IPv6 neighbor discovery specification
1105.Pq RFC2461 .
1106.It Li icmp6.nd6_useloopback
1107If set to non-zero, kernel IPv6 stack will use loopback interface for
1108local traffic.
1109.It Li icmp6.nodeinfo
1110The variable enables responses to ICMPv6 node information queries.
1111If you set the variable to 0, reponses will not be generated for
1112ICMPv6 node information queries.
1113Since node information queries can have a security impact, it is
1114possible to fine tune which responses should be answered.
1115Two separate bits can be set.
1116.Bl -tag -width "12345"
1117.It 1
1118Respond to ICMPv6 FQDN queries, e.g.
1119.Li ping6 -w .
1120.It 2
1121Respond to ICMPv6 node addresses queries, e.g.
1122.Li ping6 -a .
1123.El
1124.It Li icmp6.errppslimit
1125The variable specifies the maximum number of outgoing ICMPv6 error messages,
1126per second.
1127ICMPv6 error messages that exceeded the value are subject to rate limitation
1128and will not go out from the node.
1129Negative value disables rate limitation.
1130.It Li icmp6.nd6_maxnudhint
1131IPv6 neighbor discovery permits upper layer protocols to supply reachability
1132hints, to avoid unnecessary neighbor discovery exchanges.
1133The variable defines the number of consecutive hints the neighbor discovery
1134layer will take.
1135For example, by setting the variable to 3, neighbor discovery layer
1136will take 3 consecutive hints in maximum.
1137After receiving 3 hints, neighbor discovery layer will perform
1138normal neighbor discovery process.
1139.It Li icmp6.mtudisc_hiwat
1140.It Li icmp6.mtudisc_lowat
1141The variables define the maximum number of routing table entries,
1142created due to path MTU discovery
1143.Pq prevents denial-of-service attacks with ICMPv6 too big messages .
1144When IPv6 path MTU discovery happens, we keep path MTU information into
1145the routing table.
1146If the number of routing table entries exceed the value,
1147the kernel will not attempt to keep the path MTU information.
1148.Li icmp6.mtudisc_hiwat
1149is used when we have verified ICMPv6 too big messages.
1150.Li icmp6.mtudisc_lowat
1151is used when we have unverified ICMPv6 too big messages.
1152Verification is performed by using address/port pairs kept in connected pcbs.
1153Negative value disables the upper limit.
1154.It Li icmp6.nd6_debug
1155If set to non-zero, kernel IPv6 neighbor discovery code will generate
1156debugging messages.
1157The debug outputs are useful to diagnose IPv6 interoperability issues.
1158The flag must be set to 0 for normal operation.
1159.El
1160.Pp
1161We reuse net.*.tcp for
1162.Tn TCP
1163over
1164.Tn IPv6 ,
1165and therefore we do not have variables net.*.tcp6.
1166Variables net.inet6.udp6 have identical meaning to net.inet.udp.
1167Please refer to
1168.Li PF_INET
1169section above.
1170For variables net.*.ipsec6, please refer to
1171.Xr ipsec 4 .
1172.It Li PF_KEY
1173Get or set various global information about the IPsec key management.
1174The third level name is the variable name.
1175The currently defined variable and names are:
1176.Bl -column "blockacq_lifetime" "integer" "yes" -offset indent
1177.It Pa Variable name	Type	Changeable
1178.It debug	integer	yes
1179.It spi_try	integer	yes
1180.It spi_min_value	integer	yes
1181.It spi_max_value	integer	yes
1182.It random_int	integer	yes
1183.It larval_lifetime	integer	yes
1184.It blockacq_count	integer	yes
1185.It blockacq_lifetime	integer	yes
1186.It esp_keymin	integer	yes
1187.It esp_auth	integer	yes
1188.It ah_keymin	integer	yes
1189.El
1190The variables are as follows:
1191.Bl -tag -width "123456"
1192.It Li debug
1193Turn on debugging message from within the kernel.
1194The value is a bitmap, as defined in
1195.Pa /usr/include/netkey/key_debug.h .
1196.It Li spi_try
1197The number of times the kernel will try to obtain an unique SPI
1198when it generates it from random number generator.
1199.It Li spi_min_value
1200Minimum SPI value when generating it within the kernel.
1201.It Li spi_max_value
1202Maximum SPI value when generating it within the kernel.
1203.It Li random_int
1204Interval to stir pseudo-random number generator, in seconds.
1205Pseudo-random number generator is used only as a last resort when
1206random number source
1207.Pq Pa /dev/urandom
1208is not available.
1209It should not really be used, and if it were used,
1210kernel will warn about it.
1211.It Li larval_lifetime
1212Lifetime for LARVAL SAD entries, in seconds.
1213.It Li blockacq_count
1214Number of ACQUIRE PF_KEY messages to be blocked after an ACQUIRE message.
1215It avoids flood of ACQUIRE PF_KEY from being sent from the kernel to the
1216key management daemon.
1217.It Li blockacq_lifetime
1218Lifetime of ACQUIRE PF_KEY message.
1219.It Li esp_keymin
1220Minimum ESP key length, in bits.
1221The value is used when the kernel creates proposal payload
1222on ACQUIRE PF_KEY message.
1223.It Li esp_auth
1224Whether ESP authentication should be used or not.
1225Non-zero value indicates that ESP authentication should be used.
1226The value is used when the kernel creates proposal payload
1227on ACQUIRE PF_KEY message.
1228.It Li ah_keymin
1229Minimum AH key length, in bits,
1230The value is used when the kernel creates proposal payload
1231on ACQUIRE PF_KEY message.
1232.El
1233.El
1234.Sh CTL_PROC
1235The string and integer information available for the CTL_PROC
1236is detailed below.
1237The changeable column shows whether a process with appropriate
1238privilege may change the value.
1239These values are per-process, and as such may change from one process
1240to another. When a process is created, the default values are inherited from
1241its parent. When a set-user-ID or set-group-ID binary is executed, the
1242value of PROC_PID_CORENAME is reset to the system default value.
1243The second level name is either the magic value PROC_CURPROC, which
1244points to the current process, or the PID of the target process.
1245.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" "yes" -offset indent
1246.It Sy Pa Third level name	Type	Changeable
1247.It PROC\_PID\_CORENAME	string	yes
1248.It PROC\_PID\_LIMIT	node	not applicable
1249.El
1250.Bl -tag -width "123456"
1251.Pp
1252.It Li PROC_PID_CORENAME
1253The template used for the core dump file name (see
1254.Xr core 5
1255for details). The base name must either be
1256.Nm core
1257or end with the suffix ``.core'' (the super-user may set arbitrary names). By
1258default it points to KERN_DEFCORENAME.
1259.It Li PROC_PID_LIMIT
1260Return resources limits, as defined for the
1261.Xr getrlimit 2
1262and
1263.Xr setrlimit 2
1264system calls.
1265The fourth level name is one of:
1266.Bl -tag -width PROC_PID_LIMIT_MEMLOCKAA
1267.It Li PROC_PID_LIMIT_CPU
1268The maximum amount of cpu time (in seconds) to be used by each process.
1269.It Li PROC_PID_LIMIT_FSIZE
1270The largest size (in bytes) file that may be created.
1271.It Li PROC_PID_LIMIT_DATA
1272The maximum size (in bytes) of the data segment for a process;
1273this defines how far a program may extend its break with the
1274.Xr sbrk 2
1275system call.
1276.It Li PROC_PID_LIMIT_STACK
1277The maximum size (in bytes) of the stack segment for a process;
1278this defines how far a program's stack segment may be extended.
1279Stack extension is performed automatically by the system.
1280.It Li PROC_PID_LIMIT_CORE
1281The largest size (in bytes)
1282.Pa core
1283file that may be created.
1284.It Li PROC_PID_LIMIT_RSS
1285The maximum size (in bytes) to which a process's resident set size may
1286grow.
1287This imposes a limit on the amount of physical memory to be given to
1288a process; if memory is tight, the system will prefer to take memory
1289from processes that are exceeding their declared resident set size.
1290.It Li PROC_PID_LIMIT_MEMLOCK
1291The maximum size (in bytes) which a process may lock into memory
1292using the
1293.Xr mlock 2
1294function.
1295.It Li PROC_PID_LIMIT_NPROC
1296The maximum number of simultaneous processes for this user id.
1297.It Li PROC_PID_LIMIT_NOFILE
1298The maximum number of open files for this process.
1299.El
1300.Pp
1301The fifth level name is one of PROC_PID_LIMIT_TYPE_SOFT or
1302PROC_PID_LIMIT_TYPE_HARD, to select respectively the soft or hard limit.
1303Both are of type integer.
1304.El
1305.Sh CTL_USER
1306The string and integer information available for the CTL_USER level
1307is detailed below.
1308The changeable column shows whether a process with appropriate
1309privilege may change the value.
1310.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
1311.It Sy Pa Second level name	Type	Changeable
1312.It USER\_BC\_BASE\_MAX	integer	no
1313.It USER\_BC\_DIM\_MAX	integer	no
1314.It USER\_BC\_SCALE\_MAX	integer	no
1315.It USER\_BC\_STRING\_MAX	integer	no
1316.It USER\_COLL\_WEIGHTS\_MAX	integer	no
1317.It USER\_CS\_PATH	string	no
1318.It USER\_EXPR\_NEST\_MAX	integer	no
1319.It USER\_LINE\_MAX	integer	no
1320.It USER\_POSIX2\_CHAR\_TERM	integer	no
1321.It USER\_POSIX2\_C\_BIND	integer	no
1322.It USER\_POSIX2\_C\_DEV	integer	no
1323.It USER\_POSIX2\_FORT\_DEV	integer	no
1324.It USER\_POSIX2\_FORT\_RUN	integer	no
1325.It USER\_POSIX2\_LOCALEDEF	integer	no
1326.It USER\_POSIX2\_SW\_DEV	integer	no
1327.It USER\_POSIX2\_UPE	integer	no
1328.It USER\_POSIX2\_VERSION	integer	no
1329.It USER\_RE\_DUP\_MAX	integer	no
1330.It USER\_STREAM\_MAX	integer	no
1331.It USER\_TZNAME\_MAX	integer	no
1332.El
1333.Bl -tag -width "123456"
1334.Pp
1335.It Li USER_BC_BASE_MAX
1336The maximum ibase/obase values in the
1337.Xr bc 1
1338utility.
1339.It Li USER_BC_DIM_MAX
1340The maximum array size in the
1341.Xr bc 1
1342utility.
1343.It Li USER_BC_SCALE_MAX
1344The maximum scale value in the
1345.Xr bc 1
1346utility.
1347.It Li USER_BC_STRING_MAX
1348The maximum string length in the
1349.Xr bc 1
1350utility.
1351.It Li USER_COLL_WEIGHTS_MAX
1352The maximum number of weights that can be assigned to any entry of
1353the LC_COLLATE order keyword in the locale definition file.
1354.It Li USER_CS_PATH
1355Return a value for the
1356.Ev PATH
1357environment variable that finds all the standard utilities.
1358.It Li USER_EXPR_NEST_MAX
1359The maximum number of expressions that can be nested within
1360parenthesis by the
1361.Xr expr 1
1362utility.
1363.It Li USER_LINE_MAX
1364The maximum length in bytes of a text-processing utility's input
1365line.
1366.It Li USER_POSIX2_CHAR_TERM
1367Return 1 if the system supports at least one terminal type capable of
1368all operations described in POSIX 1003.2, otherwise 0.
1369.It Li USER_POSIX2_C_BIND
1370Return 1 if the system's C-language development facilities support the
1371C-Language Bindings Option, otherwise 0.
1372.It Li USER_POSIX2_C_DEV
1373Return 1 if the system supports the C-Language Development Utilities Option,
1374otherwise 0.
1375.It Li USER_POSIX2_FORT_DEV
1376Return 1 if the system supports the FORTRAN Development Utilities Option,
1377otherwise 0.
1378.It Li USER_POSIX2_FORT_RUN
1379Return 1 if the system supports the FORTRAN Runtime Utilities Option,
1380otherwise 0.
1381.It Li USER_POSIX2_LOCALEDEF
1382Return 1 if the system supports the creation of locales, otherwise 0.
1383.It Li USER_POSIX2_SW_DEV
1384Return 1 if the system supports the Software Development Utilities Option,
1385otherwise 0.
1386.It Li USER_POSIX2_UPE
1387Return 1 if the system supports the User Portability Utilities Option,
1388otherwise 0.
1389.It Li USER_POSIX2_VERSION
1390The version of POSIX 1003.2 with which the system attempts to comply.
1391.It Li USER_RE_DUP_MAX
1392The maximum number of repeated occurrences of a regular expression
1393permitted when using interval notation.
1394.ne 1i
1395.It Li USER_STREAM_MAX
1396The minimum maximum number of streams that a process may have open
1397at any one time.
1398.It Li USER_TZNAME_MAX
1399The minimum maximum number of types supported for the name of a
1400timezone.
1401.El
1402.Sh CTL_VM
1403The string and integer information available for the CTL_VM level
1404is detailed below.
1405The changeable column shows whether a process with appropriate
1406privilege may change the value.
1407.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
1408.It Sy Pa Second level name	Type	Changeable
1409.It VM\_ANONMAX	int	yes
1410.It VM\_ANONMIN	int	yes
1411.It VM\_EXECMAX	int	yes
1412.It VM\_EXECMIN	int	yes
1413.It VM\_FILEMAX	int	yes
1414.It VM\_FILEMIN	int	yes
1415.It VM\_LOADAVG	struct loadavg	no
1416.It VM\_MAXSLP	int	no
1417.It VM\_METER	struct vmtotal	no
1418.It VM\_NKMEMPAGES	int	no
1419.It VM\_USPACE	int	no
1420.It VM\_UVMEXP	struct uvmexp	no
1421.It VM\_UVMEXP2	struct uvmexp_sysctl	no
1422.El
1423.Pp
1424.Bl -tag -width "123456"
1425.It Li VM_ANONMAX
1426The percentage of physical memory which will be reclaimed
1427from other types of memory usage to store anonymous application data.
1428.It Li VM_ANONMIN
1429The percentage of physical memory which will be always be available for
1430anonymous application data.
1431.It Li VM_EXECMAX
1432The percentage of physical memory which will be reclaimed
1433from other types of memory usage to store cached executable data.
1434.It Li VM_EXECMIN
1435The percentage of physical memory which will be always be available for
1436cached executable data.
1437.It Li VM_FILEMAX
1438The percentage of physical memory which will be reclaimed
1439from other types of memory usage to store cached file data.
1440.It Li VM_FILEMIN
1441The percentage of physical memory which will be always be available for
1442cached file data.
1443.It Li VM_LOADAVG
1444Return the load average history.
1445The returned data consists of a
1446.Va struct loadavg .
1447.It Li VM_MAXSLP
1448The value of the maxslp kernel global variable.
1449.It Li VM_METER
1450Return system wide virtual memory statistics.
1451The returned data consists of a
1452.Va struct vmtotal .
1453.It Li VM_USPACE
1454The number of bytes allocated for each kernel stack.
1455.It Li VM_UVMEXP
1456Return system wide virtual memory statistics.
1457The returned data consists of a
1458.Va struct uvmexp .
1459.It Li VM_UVMEXP2
1460Return system wide virtual memory statistics.
1461The returned data consists of a
1462.Va struct uvmexp_sysctl .
1463.El
1464.Sh CTL_DDB
1465The integer information available for the CTL_DDB level is detailed below.
1466The changeable column shows whether a process with appropriate
1467privilege may change the value.
1468.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
1469.It Sy Pa Second level name	Type	Changeable
1470.It DBCTL\_RADIX	integer	yes
1471.It DBCTL\_MAXOFF	integer	yes
1472.It DBCTL\_LINES	integer	yes
1473.It DBCTL\_TABSTOPS	integer	yes
1474.It DBCTL\_ONPANIC	integer	yes
1475.It DBCTL\_FROMCONSOLE	integer	yes
1476.El
1477.Pp
1478.Bl -tag -width "123456"
1479.It Li DBCTL_RADIX
1480The input and output radix.
1481.It Li DBCTL_MAXOFF
1482The maximum symbol offset.
1483.It Li DBCTL_LINES
1484Number of display lines.
1485.It Li DBCTL_TABSTOPS
1486Tab width.
1487.It Li DBCTL_ONPANIC
1488If non-zero, DDB will be entered when the kernel panics.
1489.It Li DBCTL_FROMCONSOLE
1490If not zero, DDB may be entered by sending a break on a serial
1491console or by a special key sequence on a graphics console.
1492.El
1493.Pp
1494These MIB nodes are also available as variables from within the
1495DDB.  See
1496.Xr ddb 4
1497for more details.
1498.Sh CTL_VENDOR
1499The "vendor" toplevel name is reserved to be used by vendors who wish to
1500have their own private MIB tree. Intended use is to store values under
1501.Dq vendor.\*[Lt]yourname\*[Gt].* .
1502.Sh RETURN VALUES
1503If the call to
1504.Nm
1505is successful, the number of bytes copied out is returned.
1506Otherwise \-1 is returned and
1507.Va errno
1508is set appropriately.
1509.Sh FILES
1510.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact
1511.It Pa Aq sys/sysctl.h
1512definitions for top level identifiers, second level kernel and hardware
1513identifiers, and user level identifiers
1514.It Pa Aq sys/socket.h
1515definitions for second level network identifiers
1516.It Pa Aq sys/gmon.h
1517definitions for third level profiling identifiers
1518.It Pa Aq uvm/uvm_param.h
1519definitions for second level virtual memory identifiers
1520.It Pa Aq netinet/in.h
1521definitions for third level IPv4/v6 identifiers and
1522fourth level IPv4/v6 identifiers
1523.It Pa Aq netinet/icmp_var.h
1524definitions for fourth level ICMP identifiers
1525.It Pa Aq netinet/icmp6.h
1526definitions for fourth level ICMPv6 identifiers
1527.It Pa Aq netinet/tcp_var.h
1528definitions for fourth level TCP identifiers
1529.It Pa Aq netinet/udp_var.h
1530definitions for fourth level UDP identifiers
1531.It Pa Aq netinet6/udp6_var.h
1532definitions for fourth level IPv6 UDP identifiers
1533.It Pa Aq netinet6/ipsec.h
1534definitions for fourth level IPsec identifiers
1535.It Pa Aq netkey/key_var.h
1536definitions for third level PF_KEY identifiers
1537.El
1538.Sh ERRORS
1539The following errors may be reported:
1540.Bl -tag -width Er
1541.It Bq Er EFAULT
1542The buffer
1543.Fa name ,
1544.Fa oldp ,
1545.Fa newp ,
1546or length pointer
1547.Fa oldlenp
1548contains an invalid address.
1549.It Bq Er EINVAL
1550The
1551.Fa name
1552array is less than two or greater than CTL_MAXNAME.
1553.It Bq Er EINVAL
1554A non-null
1555.Fa newp
1556is given and its specified length in
1557.Fa newlen
1558is too large or too small.
1559.It Bq Er ENOMEM
1560The length pointed to by
1561.Fa oldlenp
1562is too short to hold the requested value.
1563.It Bq Er ENOTDIR
1564The
1565.Fa name
1566array specifies an intermediate rather than terminal name.
1567.It Bq Er EOPNOTSUPP
1568The
1569.Fa name
1570array specifies a value that is unknown.
1571.It Bq Er EPERM
1572An attempt is made to set a read-only value.
1573.It Bq Er EPERM
1574A process without appropriate privilege attempts to set a value.
1575.It Bq Er EPERM
1576An attempt to change a value protected by the current kernel security
1577level is made.
1578.El
1579.Sh SEE ALSO
1580.Xr ipsec 4 ,
1581.Xr sysctl 8
1582.Sh HISTORY
1583The
1584.Nm
1585function first appeared in
1586.Bx 4.4 .
1587