xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision 0dd5877adce57db949b16ae963e5a6831cccdfb6)
1.\"	$NetBSD: sysctl.3,v 1.89 2002/02/10 01:21:38 ross 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.El
680.Pp
681.Bl -tag -width "123456"
682.It Li PF_ROUTE
683Return the entire routing table or a subset of it.
684The data is returned as a sequence of routing messages (see
685.Xr route 4
686for the header file, format and meaning).
687The length of each message is contained in the message header.
688.Pp
689The third level name is a protocol number, which is currently always 0.
690The fourth level name is an address family, which may be set to 0 to
691select all address families.
692The fifth and sixth level names are as follows:
693.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
694.It Pa Fifth level name	Sixth level is:
695.It NET\_RT\_FLAGS	rtflags
696.It NET\_RT\_DUMP	None
697.It NET\_RT\_IFLIST	None
698.El
699.It Li PF_INET
700Get or set various global information about the IPv4
701.Pq Internet Protocol version 4 .
702The third level name is the protocol.
703The fourth level name is the variable name.
704The currently defined protocols and names are:
705.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
706.It Pa Protocol name	Variable name	Type	Changeable
707.It ip	forwarding	integer	yes
708.It ip	redirect	integer	yes
709.It ip	ttl	integer	yes
710.It ip	forwsrcrt	integer	yes
711.It ip	directed-broadcast	integer	yes
712.It ip	allowsrcrt	integer	yes
713.It ip	subnetsarelocal	integer	yes
714.It ip	mtudisc	integer	yes
715.It ip	anonportmin	integer	yes
716.It ip	anonportmax	integer	yes
717.It ip	mtudisctimeout	integer	yes
718.It ip	gifttl	integer	yes
719.It ip	lowportmin	integer	yes
720.It ip	lowportmax	integer	yes
721.It ip	maxfragpacket	integer	yes
722.It icmp	maskrepl	integer	yes
723.It icmp	errppslimit	integer	yes
724.It icmp	rediraccept	integer	yes
725.It icmp	redirtimeout	integer	yes
726.It tcp	rfc1323	integer	yes
727.It tcp	sendspace	integer	yes
728.It tcp	recvspace	integer	yes
729.It tcp	mssdflt	integer	yes
730.It tcp	syn_cache_limit	integer	yes
731.It tcp	syn_bucket_limit	integer	yes
732.It tcp	syn_cache_interval	integer	yes
733.It tcp	init_win	integer	yes
734.It tcp	mss_ifmtu	integer	yes
735.It tcp	sack	integer	yes
736.It tcp	win_scale	integer	yes
737.It tcp	timestamps	integer	yes
738.It tcp	compat_42	integer	yes
739.It tcp	cwm	integer	yes
740.It tcp	cwm_burstsize	integer	yes
741.It tcp	ack_on_push	integer	yes
742.It tcp	keepidle	integer	yes
743.It tcp	keepintvl	integer	yes
744.It tcp	keepcnt	integer	yes
745.It tcp	slowhz	integer	no
746.It tcp	newreno	integer	yes
747.It tcp	log_refused	integer	yes
748.It tcp	rstppslimit	integer	yes
749.It udp	checksum	integer	yes
750.It udp	sendspace	integer	yes
751.It udp	recvspace	integer	yes
752.El
753.Pp
754The variables are as follows:
755.Bl -tag -width "123456"
756.It Li ip.forwarding
757Returns 1 when IP forwarding is enabled for the host,
758meaning that the host is acting as a router.
759.It Li ip.redirect
760Returns 1 when ICMP redirects may be sent by the host.
761This option is ignored unless the host is routing IP packets,
762and should normally be enabled on all systems.
763.It Li ip.ttl
764The maximum time-to-live (hop count) value for an IP packet sourced by
765the system.
766This value applies to normal transport protocols, not to ICMP.
767.It Li ip.forwsrcrt
768Returns 1 when forwarding of source-routed packets is enabled for
769the host.  This value may only be changed if the kernel security
770level is less than 1.
771.It Li ip.directed-broadcast
772Returns 1 if directed broadcast behavior is enabled for the host.
773.It Li ip.allowsrcrt
774Returns 1 if the host accepts source routed packets.
775.It Li ip.subnetsarelocal
776Returns 1 if subnets are to be considered local addresses.
777.It Li ip.mtudisc
778Returns 1 if Path MTU Discovery is enabled.
779.It Li ip.anonportmin
780The lowest port number to use for TCP and UDP ephemeral port allocation.
781This cannot be set to less than 1024 or greater than 65535.
782.It Li ip.anonportmax
783The highest port number to use for TCP and UDP ephemeral port allocation.
784This cannot be set to less than 1024 or greater than 65535, and must
785be greater than
786.Li ip.anonportmin .
787.It Li ip.mtudisctimeout
788Returns the number of seconds in which a route added by the Path MTU
789Discovery engine will time out.  When the route times out, the Path
790MTU Discovery engine will attempt to probe a larger path MTU.
791.It Li ip.gifttl
792The maximum time-to-live (hop count) value for an IPv4 packet generated by
793.Xr gif 4
794tunnel interface.
795.It Li ip.lowportmin
796The lowest port number to use for TCP and UDP reserved port allocation.
797This cannot be set to less than 0 or greater than 1024, and must
798be smaller than
799.Li ip.lowportmax .
800.It Li ip.lowportmax
801The highest port number to use for TCP and UDP reserved port allocation.
802This cannot be set to less than 0 or greater than 1024, and must
803be greater than
804.Li ip.lowportmin .
805.It Li ip.maxfragpackets
806The maximum number of fragmented packets the node will accept.
8070 means that the node will not accept any fragmented packets.
808-1 means that the node will accept as many fragmented packets as it receives.
809The flag is provided basically for avoiding possible DoS attacks.
810.It Li icmp.maskrepl
811Returns 1 if ICMP network mask requests are to be answered.
812.It Li icmp.errppslimit
813The variable specifies the maximum number of outgoing ICMP error messages,
814per second.
815ICMP error messages that exceeded the value are subject to rate limitation
816and will not go out from the node.
817Negative value disables rate limitation.
818.It Li icmp.rediraccept
819If set to non-zero, the host will accept ICMP redirect packets.
820Note that routers will never accept ICMP redirect packets,
821and the variable is meaningful on IP hosts only.
822.It Li icmp.redirtimeout
823The variable specifies lifetime of routing entries generated by incoming
824ICMP redirect.  This defaults to zero;  if the system is not running
825a routing daemon like
826.Xr routed 8
827than this value can be set to remove the routes added by redirect.
828A reasonable value to use would be 600 seconds.
829.It Li tcp.rfc1323
830Returns 1 if RFC1323 extensions to TCP are enabled.
831.It Li tcp.sendspace
832Returns the default TCP send buffer size.
833.It Li tcp.recvspace
834Returns the default TCP receive buffer size.
835.It Li tcp.mssdflt
836Returns the default maximum segment size both advertsized to the peer
837and to use when the peer does not advertize a maximum segment size to
838us during connection setup.  Do not change this value unless you really
839know what you are doing.
840.It Li tcp.syn_cache_limit
841Returns the maximum number of entries allowed in the TCP compressed state
842engine.
843.It Li tcp.syn_bucket_limit
844Returns the maximum number of entries allowed per hash bucket in the TCP
845compressed state engine.
846.It Li tcp.syn_cache_interval
847Returns the TCP compressed state engine's timer interval.
848.It Li tcp.init_win
849Returns a value indicating the TCP initial congestion window.  If this
850value is 0, an auto-tuning algorithm designed to use an initial window
851of approximately 4K bytes is in use.  Otherwise, this value indicates
852a fixed number of packets.
853.It Li tcp.mss_ifmtu
854Returns 1 if TCP calculates the outgoing maximum segment size based on
855the MTU of the appropriate interface.  Otherwise, it is calculated based on
856the greater of the MTU of the interface, and the largest (non-loopback)
857interface MTU on the system.
858.It Li tcp.sack
859TCP Selective ACKnowledgement (RFC 2018) is not implemented in
860.Nx
861at this time.
862Changing this value will have no effect.
863.It Li tcp.win_scale
864If rfc1323 is enabled, a value of 1 indicates RFC1323 window scale options,
865for increasing the TCP window size, are enabled.
866.It Li tcp.timestamps
867If rfc1323 is enabled, a value of 1 indicates RFC1323 time stamp options,
868used for measuring TCP round trip times, are enabled.
869.It Li tcp.compat_42
870Returns 1 if work-arounds for bugs in the 4.2BSD TCP implementation are
871enabled.  Use of this option is not recommended, although it may be
872required in order to communicate with extremely old TCP implementations.
873.It Li tcp.cwm
874Returns 1 if use of the Hughes/Touch/Heidemann Congestion Window Monitoring
875algorithm is enabled.  This algorithm prevents line-rate bursts of packets
876that could otherwise occur when data begins flowing on an idle TCP
877connection.  These line-rate bursts can contribute to network and router
878congestion.  This can be particularly useful on World Wide Web servers
879which support HTTP/1.1, which has lingering connections.
880.It Li tcp.cwm_burstsize
881Returns the Congestion Window Monitoring allowed burst size, in terms
882of packet count.
883.It Li tcp.ack_on_push
884Returns 1 if TCP is to immediately transmit an ACK upon reception of
885a packet with PUSH set.  This can avoid losing a round trip time in some
886rare situations, but has the caveat of potentially defeating TCP's delayed
887ACK algorithm.  Use of this option is generally not recommended, but
888the variable exists in case your configuration really needs it.
889.It Li tcp.keepidle
890Time a connection must be idle before keepalives are sent (if keepalives
891are enabled for the connection).  See also tcp.slowhz.
892.It Li tcp.keepintvl
893Time after a keepalive probe is sent until, in the absence of any response,
894another probe is sent.  See also tcp.slowhz.
895.It Li tcp.keepcnt
896Number of keepalive probes sent before declaring a connection dead.  If
897set to zero, there is no limit; keepalives will be sent until some kind of
898response is received from the peer.
899.It Li tcp.slowhz
900The units for tcp.keepidle and tcp.keepintvl; those variables are in ticks
901of a clock that ticks tcp.slowhz times per second.  (That is, their values
902must be divided by the tcp.slowhz value to get times in seconds.)
903.It Li tcp.newreno
904Returns 1 if the use of J. Hoe's NewReno congestion control algorithm is
905enabled.  This algorithm improves the start-up behavior of TCP connections.
906.It Li tcp.log_refused
907Returns 1 if refused TCP connections to the host will be logged.
908.It Li tcp.rstppslimit
909The variable specifies the maximum number of outgoing TCP RST packets,
910per second.
911TCP RST packet that exceeded the value are subject to rate limitation
912and will not go out from the node.
913Negative value disables rate limitation.
914.It Li udp.checksum
915Returns 1 when UDP checksums are being computed and checked.
916Disabling UDP checksums is strongly discouraged.
917.It Li udp.sendspace
918Returns the default UDP send buffer size.
919.It Li udp.recvspace
920Returns the default UDP receive buffer size.
921.El
922.Pp
923For variables net.*.ipsec, please refer to
924.Xr ipsec 4 .
925.It Li PF_INET6
926Get or set various global information about the IPv6
927.Pq Internet Protocol version 6 .
928The third level name is the protocol.
929The fourth level name is the variable name.
930The currently defined protocols and names are:
931.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
932.It Pa Protocol name	Variable name	Type	Changeable
933.It ip6	forwarding	integer	yes
934.It ip6	redirect	integer	yes
935.It ip6	hlim	integer	yes
936.It ip6	maxfragpackets	integer	yes
937.It ip6	accept_rtadv	integer	yes
938.It ip6	keepfaith	integer	yes
939.It ip6	log_interval	integer	yes
940.It ip6	hdrnestlimit	integer	yes
941.It ip6	dad_count	integer	yes
942.It ip6	auto_flowlabel	integer	yes
943.It ip6	defmcasthlim	integer	yes
944.It ip6	gif_hlim	integer	yes
945.It ip6	kame_version	string	no
946.It ip6	use_deprecated	integer	yes
947.It ip6	rr_prune	integer	yes
948.It ip6	bindv6only	integer	yes
949.It ip6	anonportmin	integer	yes
950.It ip6	anonportmax	integer	yes
951.It ip6	lowportmin	integer	yes
952.It ip6	lowportmax	integer	yes
953.It icmp6	rediraccept	integer	yes
954.It icmp6	redirtimeout	integer	yes
955.It icmp6	nd6_prune	integer	yes
956.It icmp6	nd6_delay	integer	yes
957.It icmp6	nd6_umaxtries	integer	yes
958.It icmp6	nd6_mmaxtries	integer	yes
959.It icmp6	nd6_useloopback	integer	yes
960.It icmp6	nodeinfo	integer	yes
961.It icmp6	errppslimit	integer	yes
962.It icmp6	nd6_maxnudhint	integer	yes
963.It icmp6	mtudisc_hiwat	integer	yes
964.It icmp6	mtudisc_lowat	integer	yes
965.It icmp6	nd6_debug	integer	yes
966.It udp6	sendspace	integer	yes
967.It udp6	recvspace	integer	yes
968.El
969.Pp
970The variables are as follows:
971.Bl -tag -width "123456"
972.It Li ip6.forwarding
973Returns 1 when IPv6 forwarding is enabled for the node,
974meaning that the node is acting as a router.
975Returns 0 when IPv6 forwarding is disabled for the node,
976meaning that the node is acting as a host.
977IPv6 specification defines node behavior for
978.Dq router
979case and
980.Dq host
981case quite differently, and changing this variable during operation
982may cause serious trouble.
983It is recommended to configure the variable at bootstrap time,
984and bootstrap time only.
985.It Li ip6.redirect
986Returns 1 when ICMPv6 redirects may be sent by the node.
987This option is ignored unless the node is routing IP packets,
988and should normally be enabled on all systems.
989.It Li ip6.hlim
990The default hop limit value for an IPv6 unicast packet sourced by the node.
991This value applies to all the transport protocols on top of IPv6.
992There are APIs to override the value, as documented in
993.Xr ip6 4 .
994.It Li ip6.maxfragpackets
995The maximum number of fragmented packets the node will accept.
9960 means that the node will not accept any fragmented packets.
997-1 means that the node will accept as many fragmented packets as it receives.
998The flag is provided basically for avoiding possible DoS attacks.
999.It Li ip6.accept_rtadv
1000If set to non-zero, the node will accept ICMPv6 router advertisement packets
1001and autoconfigures address prefixes and default routers.
1002The node must be a host
1003.Pq not a router
1004for the option to be meaningful.
1005.It Li ip6.keepfaith
1006If set to non-zero, it enables
1007.Dq FAITH
1008TCP relay IPv6-to-IPv4 translator code in the kernel.
1009Refer
1010.Xr faith 4
1011and
1012.Xr faithd 8
1013for detail.
1014.It Li ip6.log_interval
1015The variable controls amount of logs generated by IPv6 packet
1016forwarding engine, by seting interval between log output
1017.Pq in seconds .
1018.It Li ip6.hdrnestlimit
1019The number of IPv6 extension headers permitted on incoming IPv6 packets.
1020If set to 0, the node will accept as many extension headers as possible.
1021.It Li ip6.dad_count
1022The variable cofigures number of IPv6 DAD
1023.Pq duplicated address detection
1024probe packets.
1025The packets will be generated when IPv6 interface addresses are configured.
1026.It Li ip6.auto_flowlabel
1027On connected transport protocol packets,
1028fill IPv6 flowlabel field to help intermediate routers to identify packet flows.
1029.It Li ip6.defmcasthlim
1030The default hop limit value for an IPv6 multicast packet sourced by the node.
1031This value applies to all the transport protocols on top of IPv6.
1032There are APIs to override the value, as documented in
1033.Xr ip6 4 .
1034.It Li ip6.gif_hlim
1035The maximum hop limit value for an IPv6 packet generated by
1036.Xr gif 4
1037tunnel interface.
1038.It Li ip6.kame_version
1039The string identifies the version of KAME IPv6 stack implemented in the kernel.
1040.It Li ip6.use_deprecated
1041The variable controls use of deprecated address, specified in RFC2462 5.5.4.
1042.It Li ip6.rr_prune
1043The variable specifies interval between IPv6 router renumbering prefix
1044babysitting, in seconds.
1045.It Li ip6.bindv6only
1046The variable specifies initial value for
1047.Dv IPV6_BINDV6ONLY
1048socket option for
1049.Dv AF_INET6
1050socket.
1051Please refer to
1052.Xr ip6 4
1053for detail.
1054.It Li ip6.anonportmin
1055The lowest port number to use for TCP and UDP ephemeral port allocation.
1056This cannot be set to less than 1024 or greater than 65535.
1057.It Li ip6.anonportmax
1058The highest port number to use for TCP and UDP ephemeral port allocation.
1059This cannot be set to less than 1024 or greater than 65535, and must
1060be greater than
1061.Li ip6.anonportmin .
1062.It Li ip6.lowportmin
1063The lowest port number to use for TCP and UDP reserved port allocation.
1064This cannot be set to less than 0 or greater than 1024, and must
1065be smaller than
1066.Li ip6.lowportmax .
1067.It Li ip6.lowportmax
1068The highest port number to use for TCP and UDP reserved port allocation.
1069This cannot be set to less than 0 or greater than 1024, and must
1070be greater than
1071.Li ip6.lowportmin .
1072.It Li icmp6.rediraccept
1073If set to non-zero, the host will accept ICMPv6 redirect packets.
1074Note that IPv6 routers will never accept ICMPv6 redirect packets,
1075and the variable is meaningful on IPv6 hosts
1076.Pq non-router
1077only.
1078.It Li icmp6.redirtimeout
1079The variable specifies lifetime of routing entries generated by incoming
1080ICMPv6 redirect.
1081.It Li icmp6.nd6_prune
1082The variable specifies interval between IPv6 neighbor cache babysitting,
1083in seconds.
1084.It Li icmp6.nd6_delay
1085The variable specifies
1086.Dv DELAY_FIRST_PROBE_TIME
1087timing constant in IPv6 neighbor discovery specification
1088.Pq RFC2461 ,
1089in seconds.
1090.It Li icmp6.nd6_umaxtries
1091The variable specifies
1092.Dv MAX_UNICAST_SOLICIT
1093constant in IPv6 neighbor discovery specification
1094.Pq RFC2461 .
1095.It Li icmp6.nd6_mmaxtries
1096The variable specifies
1097.Dv MAX_MULTICAST_SOLICIT
1098constant in IPv6 neighbor discovery specification
1099.Pq RFC2461 .
1100.It Li icmp6.nd6_useloopback
1101If set to non-zero, kernel IPv6 stack will use loopback interface for
1102local traffic.
1103.It Li icmp6.nodeinfo
1104The variable enables responses to ICMPv6 node information queries.
1105If you set the variable to 0, reponses will not be generated for
1106ICMPv6 node information queries.
1107Since node information queries can have a security impact, it is
1108possible to fine tune which responses should be answered.
1109Two separate bits can be set.
1110.Bl -tag -width "12345"
1111.It 1
1112Respond to ICMPv6 FQDN queries, e.g.
1113.Li ping6 -w .
1114.It 2
1115Respond to ICMPv6 node addresses queries, e.g.
1116.Li ping6 -a .
1117.El
1118.It Li icmp6.errppslimit
1119The variable specifies the maximum number of outgoing ICMPv6 error messages,
1120per second.
1121ICMPv6 error messages that exceeded the value are subject to rate limitation
1122and will not go out from the node.
1123Negative value disables rate limitation.
1124.It Li icmp6.nd6_maxnudhint
1125IPv6 neighbor discovery permits upper layer protocols to supply reachability
1126hints, to avoid unnecessary neighbor discovery exchanges.
1127The variable defines the number of consecutive hints the neighbor discovery
1128layer will take.
1129For example, by setting the variable to 3, neighbor discovery layer
1130will take 3 consecutive hints in maximum.
1131After receiving 3 hints, neighbor discovery layer will perform
1132normal neighbor discovery process.
1133.It Li icmp6.mtudisc_hiwat
1134.It Li icmp6.mtudisc_lowat
1135The variables define the maximum number of routing table entries,
1136created due to path MTU discovery
1137.Pq prevents denial-of-service attacks with ICMPv6 too big messages .
1138When IPv6 path MTU discovery happens, we keep path MTU information into
1139the routing table.
1140If the number of routing table entries exceed the value,
1141the kernel will not attempt to keep the path MTU information.
1142.Li icmp6.mtudisc_hiwat
1143is used when we have verified ICMPv6 too big messages.
1144.Li icmp6.mtudisc_lowat
1145is used when we have unverified ICMPv6 too big messages.
1146Verification is performed by using address/port pairs kept in connected pcbs.
1147Negative value disables the upper limit.
1148.It Li icmp6.nd6_debug
1149If set to non-zero, kernel IPv6 neighbor discovery code will generate
1150debugging messages.
1151The debug outputs are useful to diagnose IPv6 interoperability issues.
1152The flag must be set to 0 for normal operation.
1153.El
1154.Pp
1155We reuse net.*.tcp for
1156.Tn TCP
1157over
1158.Tn IPv6 ,
1159and therefore we do not have variables net.*.tcp6.
1160Variables net.inet6.udp6 have identical meaning to net.inet.udp.
1161Please refer to
1162.Li PF_INET
1163section above.
1164For variables net.*.ipsec6, please refer to
1165.Xr ipsec 4 .
1166.El
1167.Sh CTL_PROC
1168The string and integer information available for the CTL_PROC
1169is detailed below.
1170The changeable column shows whether a process with appropriate
1171privilege may change the value.
1172These values are per-process, and as such may change from one process
1173to another. When a process is created, the default values are inherited from
1174its parent. When a set-user-ID or set-group-ID binary is executed, the
1175value of PROC_PID_CORENAME is reset to the system default value.
1176The second level name is either the magic value PROC_CURPROC, which
1177points to the current process, or the PID of the target process.
1178.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" "yes" -offset indent
1179.It Sy Pa Third level name	Type	Changeable
1180.It PROC\_PID\_CORENAME	string	yes
1181.It PROC\_PID\_LIMIT	node	not applicable
1182.El
1183.Bl -tag -width "123456"
1184.Pp
1185.It Li PROC_PID_CORENAME
1186The template used for the core dump file name (see
1187.Xr core 5
1188for details). The base name must either be
1189.Nm core
1190or end with the suffix ``.core'' (the super-user may set arbitrary names). By
1191default it points to KERN_DEFCORENAME.
1192.It Li PROC_PID_LIMIT
1193Return resources limits, as defined for the
1194.Xr getrlimit 2
1195and
1196.Xr setrlimit 2
1197system calls.
1198The fourth level name is one of:
1199.Bl -tag -width PROC_PID_LIMIT_MEMLOCKAA
1200.It Li PROC_PID_LIMIT_CPU
1201The maximum amount of cpu time (in seconds) to be used by each process.
1202.It Li PROC_PID_LIMIT_FSIZE
1203The largest size (in bytes) file that may be created.
1204.It Li PROC_PID_LIMIT_DATA
1205The maximum size (in bytes) of the data segment for a process;
1206this defines how far a program may extend its break with the
1207.Xr sbrk 2
1208system call.
1209.It Li PROC_PID_LIMIT_STACK
1210The maximum size (in bytes) of the stack segment for a process;
1211this defines how far a program's stack segment may be extended.
1212Stack extension is performed automatically by the system.
1213.It Li PROC_PID_LIMIT_CORE
1214The largest size (in bytes)
1215.Pa core
1216file that may be created.
1217.It Li PROC_PID_LIMIT_RSS
1218The maximum size (in bytes) to which a process's resident set size may
1219grow.
1220This imposes a limit on the amount of physical memory to be given to
1221a process; if memory is tight, the system will prefer to take memory
1222from processes that are exceeding their declared resident set size.
1223.It Li PROC_PID_LIMIT_MEMLOCK
1224The maximum size (in bytes) which a process may lock into memory
1225using the
1226.Xr mlock 2
1227function.
1228.It Li PROC_PID_LIMIT_NPROC
1229The maximum number of simultaneous processes for this user id.
1230.It Li PROC_PID_LIMIT_NOFILE
1231The maximum number of open files for this process.
1232.El
1233.Pp
1234The fifth level name is one of PROC_PID_LIMIT_TYPE_SOFT or
1235PROC_PID_LIMIT_TYPE_HARD, to select respectively the soft or hard limit.
1236Both are of type integer.
1237.El
1238.Sh CTL_USER
1239The string and integer information available for the CTL_USER level
1240is detailed below.
1241The changeable column shows whether a process with appropriate
1242privilege may change the value.
1243.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
1244.It Sy Pa Second level name	Type	Changeable
1245.It USER\_BC\_BASE\_MAX	integer	no
1246.It USER\_BC\_DIM\_MAX	integer	no
1247.It USER\_BC\_SCALE\_MAX	integer	no
1248.It USER\_BC\_STRING\_MAX	integer	no
1249.It USER\_COLL\_WEIGHTS\_MAX	integer	no
1250.It USER\_CS\_PATH	string	no
1251.It USER\_EXPR\_NEST\_MAX	integer	no
1252.It USER\_LINE\_MAX	integer	no
1253.It USER\_POSIX2\_CHAR\_TERM	integer	no
1254.It USER\_POSIX2\_C\_BIND	integer	no
1255.It USER\_POSIX2\_C\_DEV	integer	no
1256.It USER\_POSIX2\_FORT\_DEV	integer	no
1257.It USER\_POSIX2\_FORT\_RUN	integer	no
1258.It USER\_POSIX2\_LOCALEDEF	integer	no
1259.It USER\_POSIX2\_SW\_DEV	integer	no
1260.It USER\_POSIX2\_UPE	integer	no
1261.It USER\_POSIX2\_VERSION	integer	no
1262.It USER\_RE\_DUP\_MAX	integer	no
1263.It USER\_STREAM\_MAX	integer	no
1264.It USER\_TZNAME\_MAX	integer	no
1265.El
1266.Bl -tag -width "123456"
1267.Pp
1268.It Li USER_BC_BASE_MAX
1269The maximum ibase/obase values in the
1270.Xr bc 1
1271utility.
1272.It Li USER_BC_DIM_MAX
1273The maximum array size in the
1274.Xr bc 1
1275utility.
1276.It Li USER_BC_SCALE_MAX
1277The maximum scale value in the
1278.Xr bc 1
1279utility.
1280.It Li USER_BC_STRING_MAX
1281The maximum string length in the
1282.Xr bc 1
1283utility.
1284.It Li USER_COLL_WEIGHTS_MAX
1285The maximum number of weights that can be assigned to any entry of
1286the LC_COLLATE order keyword in the locale definition file.
1287.It Li USER_CS_PATH
1288Return a value for the
1289.Ev PATH
1290environment variable that finds all the standard utilities.
1291.It Li USER_EXPR_NEST_MAX
1292The maximum number of expressions that can be nested within
1293parenthesis by the
1294.Xr expr 1
1295utility.
1296.It Li USER_LINE_MAX
1297The maximum length in bytes of a text-processing utility's input
1298line.
1299.It Li USER_POSIX2_CHAR_TERM
1300Return 1 if the system supports at least one terminal type capable of
1301all operations described in POSIX 1003.2, otherwise 0.
1302.It Li USER_POSIX2_C_BIND
1303Return 1 if the system's C-language development facilities support the
1304C-Language Bindings Option, otherwise 0.
1305.It Li USER_POSIX2_C_DEV
1306Return 1 if the system supports the C-Language Development Utilities Option,
1307otherwise 0.
1308.It Li USER_POSIX2_FORT_DEV
1309Return 1 if the system supports the FORTRAN Development Utilities Option,
1310otherwise 0.
1311.It Li USER_POSIX2_FORT_RUN
1312Return 1 if the system supports the FORTRAN Runtime Utilities Option,
1313otherwise 0.
1314.It Li USER_POSIX2_LOCALEDEF
1315Return 1 if the system supports the creation of locales, otherwise 0.
1316.It Li USER_POSIX2_SW_DEV
1317Return 1 if the system supports the Software Development Utilities Option,
1318otherwise 0.
1319.It Li USER_POSIX2_UPE
1320Return 1 if the system supports the User Portability Utilities Option,
1321otherwise 0.
1322.It Li USER_POSIX2_VERSION
1323The version of POSIX 1003.2 with which the system attempts to comply.
1324.It Li USER_RE_DUP_MAX
1325The maximum number of repeated occurrences of a regular expression
1326permitted when using interval notation.
1327.ne 1i
1328.It Li USER_STREAM_MAX
1329The minimum maximum number of streams that a process may have open
1330at any one time.
1331.It Li USER_TZNAME_MAX
1332The minimum maximum number of types supported for the name of a
1333timezone.
1334.El
1335.Sh CTL_VM
1336The string and integer information available for the CTL_VM level
1337is detailed below.
1338The changeable column shows whether a process with appropriate
1339privilege may change the value.
1340.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
1341.It Sy Pa Second level name	Type	Changeable
1342.It VM\_ANONMAX	int	yes
1343.It VM\_ANONMIN	int	yes
1344.It VM\_EXECMAX	int	yes
1345.It VM\_EXECMIN	int	yes
1346.It VM\_FILEMAX	int	yes
1347.It VM\_FILEMIN	int	yes
1348.It VM\_LOADAVG	struct loadavg	no
1349.It VM\_MAXSLP	int	no
1350.It VM\_METER	struct vmtotal	no
1351.It VM\_NKMEMPAGES	int	no
1352.It VM\_USPACE	int	no
1353.It VM\_UVMEXP	struct uvmexp	no
1354.It VM\_UVMEXP2	struct uvmexp_sysctl	no
1355.El
1356.Pp
1357.Bl -tag -width "123456"
1358.It Li VM_ANONMAX
1359The percentage of physical memory which will be reclaimed
1360from other types of memory usage to store anonymous application data.
1361.It Li VM_ANONMIN
1362The percentage of physical memory which will be always be available for
1363anonymous application data.
1364.It Li VM_EXECMAX
1365The percentage of physical memory which will be reclaimed
1366from other types of memory usage to store cached executable data.
1367.It Li VM_EXECMIN
1368The percentage of physical memory which will be always be available for
1369cached executable data.
1370.It Li VM_FILEMAX
1371The percentage of physical memory which will be reclaimed
1372from other types of memory usage to store cached file data.
1373.It Li VM_FILEMIN
1374The percentage of physical memory which will be always be available for
1375cached file data.
1376.It Li VM_LOADAVG
1377Return the load average history.
1378The returned data consists of a
1379.Va struct loadavg .
1380.It Li VM_MAXSLP
1381The value of the maxslp kernel global variable.
1382.It Li VM_METER
1383Return system wide virtual memory statistics.
1384The returned data consists of a
1385.Va struct vmtotal .
1386.It Li VM_USPACE
1387The number of bytes allocated for each kernel stack.
1388.It Li VM_UVMEXP
1389Return system wide virtual memory statistics.
1390The returned data consists of a
1391.Va struct uvmexp .
1392.It Li VM_UVMEXP2
1393Return system wide virtual memory statistics.
1394The returned data consists of a
1395.Va struct uvmexp_sysctl .
1396.El
1397.Sh CTL_DDB
1398The integer information available for the CTL_DDB level is detailed below.
1399The changeable column shows whether a process with appropriate
1400privilege may change the value.
1401.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
1402.It Sy Pa Second level name	Type	Changeable
1403.It DBCTL\_RADIX	integer	yes
1404.It DBCTL\_MAXOFF	integer	yes
1405.It DBCTL\_LINES	integer	yes
1406.It DBCTL\_TABSTOPS	integer	yes
1407.It DBCTL\_ONPANIC	integer	yes
1408.It DBCTL\_FROMCONSOLE	integer	yes
1409.El
1410.Pp
1411.Bl -tag -width "123456"
1412.It Li DBCTL_RADIX
1413The input and output radix.
1414.It Li DBCTL_MAXOFF
1415The maximum symbol offset.
1416.It Li DBCTL_LINES
1417Number of display lines.
1418.It Li DBCTL_TABSTOPS
1419Tab width.
1420.It Li DBCTL_ONPANIC
1421If non-zero, DDB will be entered when the kernel panics.
1422.It Li DBCTL_FROMCONSOLE
1423If not zero, DDB may be entered by sending a break on a serial
1424console or by a special key sequence on a graphics console.
1425.El
1426.Pp
1427These MIB nodes are also available as variables from within the
1428DDB.  See
1429.Xr ddb 4
1430for more details.
1431.Sh CTL_VENDOR
1432The "vendor" toplevel name is reserved to be used by vendors who wish to
1433have their own private MIB tree. Intended use is to store values under
1434.Dq vendor.\*[Lt]yourname\*[Gt].* .
1435.Sh RETURN VALUES
1436If the call to
1437.Nm
1438is successful, the number of bytes copied out is returned.
1439Otherwise \-1 is returned and
1440.Va errno
1441is set appropriately.
1442.Sh FILES
1443.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact
1444.It Pa Aq sys/sysctl.h
1445definitions for top level identifiers, second level kernel and hardware
1446identifiers, and user level identifiers
1447.It Pa Aq sys/socket.h
1448definitions for second level network identifiers
1449.It Pa Aq sys/gmon.h
1450definitions for third level profiling identifiers
1451.It Pa Aq uvm/uvm_param.h
1452definitions for second level virtual memory identifiers
1453.It Pa Aq netinet/in.h
1454definitions for third level IPv4/v6 identifiers and
1455fourth level IPv4/v6 identifiers
1456.It Pa Aq netinet/icmp_var.h
1457definitions for fourth level ICMP identifiers
1458.It Pa Aq netinet/icmp6.h
1459definitions for fourth level ICMPv6 identifiers
1460.It Pa Aq netinet/tcp_var.h
1461definitions for fourth level TCP identifiers
1462.It Pa Aq netinet/udp_var.h
1463definitions for fourth level UDP identifiers
1464.It Pa Aq netinet6/udp6_var.h
1465definitions for fourth level IPv6 UDP identifiers
1466.It Pa Aq netinet6/ipsec.h
1467definitions for fourth level IPsec identifiers
1468.El
1469.Sh ERRORS
1470The following errors may be reported:
1471.Bl -tag -width Er
1472.It Bq Er EFAULT
1473The buffer
1474.Fa name ,
1475.Fa oldp ,
1476.Fa newp ,
1477or length pointer
1478.Fa oldlenp
1479contains an invalid address.
1480.It Bq Er EINVAL
1481The
1482.Fa name
1483array is less than two or greater than CTL_MAXNAME.
1484.It Bq Er EINVAL
1485A non-null
1486.Fa newp
1487is given and its specified length in
1488.Fa newlen
1489is too large or too small.
1490.It Bq Er ENOMEM
1491The length pointed to by
1492.Fa oldlenp
1493is too short to hold the requested value.
1494.It Bq Er ENOTDIR
1495The
1496.Fa name
1497array specifies an intermediate rather than terminal name.
1498.It Bq Er EOPNOTSUPP
1499The
1500.Fa name
1501array specifies a value that is unknown.
1502.It Bq Er EPERM
1503An attempt is made to set a read-only value.
1504.It Bq Er EPERM
1505A process without appropriate privilege attempts to set a value.
1506.It Bq Er EPERM
1507An attempt to change a value protected by the current kernel security
1508level is made.
1509.El
1510.Sh SEE ALSO
1511.Xr ipsec 4 ,
1512.Xr sysctl 8
1513.Sh HISTORY
1514The
1515.Nm
1516function first appeared in
1517.Bx 4.4 .
1518