1.\" Copyright (c) 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd April 15, 2026 29.Dt SYSCTL 3 30.Os 31.Sh NAME 32.Nm sysctl , 33.Nm sysctlbyname , 34.Nm sysctlnametomib 35.Nd get or set system information 36.Sh LIBRARY 37.Lb libc 38.Sh SYNOPSIS 39.In sys/sysctl.h 40.Ft int 41.Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" 42.Ft int 43.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" 44.Ft int 45.Fn sysctlnametomib "const char *name" "int *mibp" "size_t *sizep" 46.Sh DESCRIPTION 47The 48.Fn sysctl 49function retrieves system information and allows processes with 50appropriate privileges to set system information. 51The information available from 52.Fn sysctl 53consists of integers, strings, and tables. 54Information may be retrieved and set from the command interface 55using the 56.Xr sysctl 8 57utility. 58.Pp 59Unless explicitly noted below, 60.Fn sysctl 61returns a consistent snapshot of the data requested. 62Consistency is obtained by locking the destination 63buffer into memory so that the data may be copied out without blocking. 64Calls to 65.Fn sysctl 66are serialized to avoid deadlock. 67.Pp 68The state is described using a ``Management Information Base'' (MIB) 69style name, listed in 70.Fa name , 71which is a 72.Fa namelen 73length array of integers. 74.Pp 75The 76.Fn sysctlbyname 77function accepts an ASCII representation of the name and internally 78looks up the integer name vector. 79Apart from that, it behaves the same 80as the standard 81.Fn sysctl 82function. 83.Pp 84The information is copied into the buffer specified by 85.Fa oldp . 86The size of the buffer is given by the location specified by 87.Fa oldlenp 88before the call, 89and that location gives the amount of data copied after a successful call 90and after a call that returns with the error code 91.Er ENOMEM . 92If the amount of data available is greater 93than the size of the buffer supplied, 94the call supplies as much data as fits in the buffer provided 95and returns with the error code 96.Er ENOMEM . 97If the old value is not desired, 98.Fa oldp 99and 100.Fa oldlenp 101should be set to NULL. 102.Pp 103The size of the available data can be determined by calling 104.Fn sysctl 105with the 106.Dv NULL 107argument for 108.Fa oldp . 109The size of the available data will be returned in the location pointed to by 110.Fa oldlenp . 111For some operations, the amount of space may change often. 112For these operations, 113the system attempts to round up so that the returned size is 114large enough for a call to return the data shortly thereafter. 115.Pp 116To set a new value, 117.Fa newp 118is set to point to a buffer of length 119.Fa newlen 120from which the requested value is to be taken. 121If a new value is not to be set, 122.Fa newp 123should be set to NULL and 124.Fa newlen 125set to 0. 126.Pp 127The 128.Fn sysctlnametomib 129function accepts an ASCII representation of the name, 130looks up the integer name vector, 131and returns the numeric representation in the mib array pointed to by 132.Fa mibp . 133The number of elements in the mib array is given by the location specified by 134.Fa sizep 135before the call, 136and that location gives the number of entries copied after a successful call. 137The resulting 138.Fa mib 139and 140.Fa size 141may be used in subsequent 142.Fn sysctl 143calls to get the data associated with the requested ASCII name. 144This interface is intended for use by applications that want to 145repeatedly request the same variable (the 146.Fn sysctl 147function runs in about a third the time as the same request made via the 148.Fn sysctlbyname 149function). 150The 151.Fn sysctlnametomib 152function is also useful for fetching mib prefixes and then adding 153a final component. 154For example, to fetch process information 155for processes with pid's less than 100: 156.Pp 157.Bd -literal -offset indent -compact 158int i, mib[4]; 159size_t len; 160struct kinfo_proc kp; 161 162/* Fill out the first three components of the mib */ 163len = 4; 164sysctlnametomib("kern.proc.pid", mib, &len); 165 166/* Fetch and print entries for pid's < 100 */ 167for (i = 0; i < 100; i++) { 168 mib[3] = i; 169 len = sizeof(kp); 170 if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1) 171 perror("sysctl"); 172 else if (len > 0) 173 printkproc(&kp); 174} 175.Ed 176.Pp 177The top level names are defined with a CTL_ prefix in 178.In sys/sysctl.h , 179and are as follows. 180The next and subsequent levels down are found in the include files 181listed here, and described in separate sections below. 182.Bl -column CTLXMACHDEPXXX "Next Level NamesXXXXXX" -offset indent 183.It Sy Name Ta Sy Next Level Names Ta Sy Description 184.It Dv CTL_DEBUG Ta In sys/sysctl.h Ta Debugging 185.It Dv CTL_VFS Ta In sys/mount.h Ta File system 186.It Dv CTL_HW Ta In sys/sysctl.h Ta Generic CPU, I/O 187.It Dv CTL_KERN Ta In sys/sysctl.h Ta High kernel limits 188.It Dv CTL_MACHDEP Ta In sys/sysctl.h Ta Machine dependent 189.It Dv CTL_NET Ta In sys/socket.h Ta Networking 190.It Dv CTL_USER Ta In sys/sysctl.h Ta User-level 191.It Dv CTL_VM Ta In vm/vm_param.h Ta Virtual memory 192.El 193.Pp 194For example, the following retrieves the maximum number of processes allowed 195in the system: 196.Pp 197.Bd -literal -offset indent -compact 198int mib[2], maxproc; 199size_t len; 200 201mib[0] = CTL_KERN; 202mib[1] = KERN_MAXPROC; 203len = sizeof(maxproc); 204sysctl(mib, 2, &maxproc, &len, NULL, 0); 205.Ed 206.Pp 207To retrieve the standard search path for the system utilities: 208.Pp 209.Bd -literal -offset indent -compact 210int mib[2]; 211size_t len; 212char *p; 213 214mib[0] = CTL_USER; 215mib[1] = USER_CS_PATH; 216sysctl(mib, 2, NULL, &len, NULL, 0); 217p = malloc(len); 218sysctl(mib, 2, p, &len, NULL, 0); 219.Ed 220.Ss CTL_DEBUG 221The debugging variables vary from system to system. 222A debugging variable may be added or deleted without need to recompile 223.Fn sysctl 224to know about it. 225Each time it runs, 226.Fn sysctl 227gets the list of debugging variables from the kernel and 228displays their current values. 229The system defines twenty 230.Pq Vt "struct ctldebug" 231variables named 232.Va debug0 233through 234.Va debug19 . 235They are declared as separate variables so that they can be 236individually initialized at the location of their associated variable. 237The loader prevents multiple use of the same variable by issuing errors 238if a variable is initialized in more than one place. 239For example, to export the variable 240.Va dospecialcheck 241as a debugging variable, the following declaration would be used: 242.Pp 243.Bd -literal -offset indent -compact 244int dospecialcheck = 1; 245struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; 246.Ed 247.Ss CTL_VFS 248A distinguished second level name, VFS_GENERIC, 249is used to get general information about all file systems. 250One of its third level identifiers is VFS_MAXTYPENUM 251that gives the highest valid file system type number. 252Its other third level identifier is VFS_CONF that 253returns configuration information about the file system 254type given as a fourth level identifier (see 255.Xr getvfsbyname 3 256as an example of its use). 257The remaining second level identifiers are the 258file system type number returned by a 259.Xr statfs 2 260call or from VFS_CONF. 261The third level identifiers available for each file system 262are given in the header file that defines the mount 263argument structure for that file system. 264.Ss CTL_HW 265The string and integer information available for the CTL_HW level 266is detailed below. 267The changeable column shows whether a process with appropriate 268privilege may change the value. 269.Bl -column "Second Level Name" integerXXX Changeable -offset indent 270.It Sy Second Level Name Ta Sy Type Ta Sy Changeable 271.It Dv HW_MACHINE Ta string Ta no 272.It Dv HW_MODEL Ta string Ta no 273.It Dv HW_NCPU Ta integer Ta no 274.It Dv HW_BYTEORDER Ta integer Ta no 275.It Dv HW_PHYSMEM Ta integer Ta no 276.It Dv HW_USERMEM Ta integer Ta no 277.It Dv HW_PAGESIZE Ta integer Ta no 278.\".It Dv HW_DISKNAMES Ta integer Ta no 279.\".It Dv HW_DISKSTATS Ta integer Ta no 280.It Dv HW_FLOATINGPT Ta integer Ta no 281.It Dv HW_MACHINE_ARCH Ta string Ta no 282.It Dv HW_REALMEM Ta integer Ta no 283.It Dv HW_AVAILPAGES Ta integer Ta no 284.El 285.Bl -tag -width 6n 286.It Li HW_MACHINE 287The machine class. 288.It Li HW_MODEL 289The machine model 290.It Li HW_NCPU 291The number of cpus. 292.It Li HW_BYTEORDER 293The byteorder (4321 or 1234). 294.It Li HW_PHYSMEM 295Amount of physical memory (in bytes), minus the amount used by the kernel, 296pre-loaded modules, and (on x86) the dcons buffer. 297.It Li HW_USERMEM 298Amount of memory (in bytes) which is not wired. 299.It Li HW_PAGESIZE 300The software page size. 301.\".It Fa HW_DISKNAMES 302.\".It Fa HW_DISKSTATS 303.It Li HW_FLOATINGPT 304Nonzero if the floating point support is in hardware. 305.It Li HW_MACHINE_ARCH 306The machine dependent architecture type. 307.It Li HW_REALMEM 308Amount of memory (in bytes) reported by the firmware. 309That value is sometimes not sane; in that case, the kernel reports the max 310memory address instead. 311.It Li HW_AVAILPAGES 312The same value as 313.Li HW_PHYSMEM , 314measured in pages rather than bytes. 315.El 316.Ss CTL_KERN 317The string and integer information available for the CTL_KERN level 318is detailed below. 319The changeable column shows whether a process with appropriate 320privilege may change the value. 321The types of data currently available are process information, 322system vnodes, the open file entries, routing table entries, 323virtual memory statistics, load average history, and clock rate 324information. 325.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent 326.It Sy Second Level Name Ta Sy Type Ta Sy Changeable 327.It Dv KERN_ARGMAX Ta integer Ta no 328.It Dv KERN_ARND Ta byte buffer Ta no 329.It Dv KERN_BOOTFILE Ta string Ta yes 330.It Dv KERN_BOOTTIME Ta struct timeval Ta no 331.It Dv KERN_CLOCKRATE Ta struct clockinfo Ta no 332.It Dv KERN_FILE Ta struct xfile Ta no 333.It Dv KERN_HOSTID Ta integer Ta yes 334.It Dv KERN_HOSTUUID Ta string Ta yes 335.It Dv KERN_HOSTNAME Ta string Ta yes 336.It Dv KERN_IOV_MAX Ta integer Ta no 337.It Dv KERN_JOB_CONTROL Ta integer Ta no 338.It Dv KERN_LOCKF Ta struct kinfo_lockf Ta no 339.It Dv KERN_LOGSIGEXIT Ta integer Ta yes 340.It Dv KERN_MAXFILES Ta integer Ta yes 341.It Dv KERN_MAXFILESPERPROC Ta integer Ta yes 342.It Dv KERN_MAXPHYS Ta integer Ta no 343.It Dv KERN_MAXPROC Ta integer Ta no 344.It Dv KERN_MAXPROCPERUID Ta integer Ta yes 345.It Dv KERN_MAXVNODES Ta integer Ta yes 346.It Dv KERN_NGROUPS Ta integer Ta no 347.It Dv KERN_NISDOMAINNAME Ta string Ta yes 348.It Dv KERN_OSRELDATE Ta integer Ta no 349.It Dv KERN_OSRELEASE Ta string Ta no 350.It Dv KERN_OSREV Ta integer Ta no 351.It Dv KERN_OSTYPE Ta string Ta no 352.It Dv KERN_POSIX1 Ta integer Ta no 353.It Dv KERN_PROC Ta node Ta not applicable 354.It Dv KERN_PS_STRINGS Ta integer Ta no 355.It Dv KERN_SAVED_IDS Ta integer Ta no 356.It Dv KERN_SECURELVL Ta integer Ta raise only 357.It Dv KERN_UPDATEINTERVAL Ta integer Ta no 358.It Dv KERN_USRSTACK Ta integer Ta no 359.It Dv KERN_VERSION Ta string Ta no 360.El 361.Bl -tag -width 6n 362.It Li KERN_ARGMAX 363The maximum bytes of argument to 364.Xr execve 2 . 365.It Li KERN_ARND 366.Xr arc4rand 9 367Fills the buffer with random bytes from in-kernel random data generator. 368This is an alternative interface for 369.Xr read 2 370of 371.Xr random 4 372device, which does not depend on accessibility and correct mounting options 373of the 374.Xr devfs 4 375node. 376.It Li KERN_BOOTFILE 377The full pathname of the file from which the kernel was loaded. 378.It Li KERN_BOOTTIME 379A 380.Va struct timeval 381structure is returned. 382This structure contains the time that the system was booted. 383.It Li KERN_CLOCKRATE 384A 385.Va struct clockinfo 386structure is returned. 387This structure contains the clock, statistics clock and profiling clock 388frequencies, the number of micro-seconds per hz tick and the skew rate. 389.It Li KERN_FILE 390Return the entire file table. 391The returned data consists of an array of 392.Va struct xfile , 393whose size depends on the current number of such objects in the system. 394.It Li KERN_HOSTID 395Get or set the host ID. 396.It Li KERN_HOSTUUID 397Get or set the host's universally unique identifier (UUID). 398.It Li KERN_HOSTNAME 399Get or set the hostname. 400.It Li KERN_IOV_MAX 401The maximum accepted number of elements in an input-output vector (iovec), 402see 403.Xr readv 2 404and 405.Xr writev 2 . 406.It Li KERN_JOB_CONTROL 407Return 1 if job control is available on this system, otherwise 0. 408.It Li KERN_LOCKF 409Returns the list of the file advisory locks currently known to kernel. 410.It Li KERN_LOGSIGEXIT 411Controls logging of process exit due to untrapped signals. 412.It Li KERN_MAXFILES 413The maximum number of files that may be open in the system. 414.It Li KERN_MAXFILESPERPROC 415The maximum number of files that may be open for a single process. 416This limit only applies to processes with an effective uid of nonzero 417at the time of the open request. 418Files that have already been opened are not affected if the limit 419or the effective uid is changed. 420.It Li KERN_MAXPHYS 421Specifies the maximum block I/O size. 422Can be changed by the tunable 423.Ev kern.maxphys . 424.It Li KERN_MAXPROC 425The maximum number of concurrent processes the system will allow. 426.It Li KERN_MAXPROCPERUID 427The maximum number of concurrent processes the system will allow 428for a single effective uid. 429This limit only applies to processes with an effective uid of nonzero 430at the time of a fork request. 431Processes that have already been started are not affected if the limit 432is changed. 433.It Li KERN_MAXVNODES 434The maximum number of vnodes available on the system. 435.It Li KERN_NGROUPS 436The maximum number of supplemental groups. 437.It Li KERN_NISDOMAINNAME 438The name of the current YP/NIS domain. 439.It Li KERN_OSRELDATE 440The kernel release version in the format 441.Ar M Ns Ar mm Ns Ar R Ns Ar xx , 442where 443.Ar M 444is the major version, 445.Ar mm 446is the two digit minor version, 447.Ar R 448is 0 if release branch, otherwise 1, 449and 450.Ar xx 451is updated when the available APIs change. 452.Pp 453The userland release version is available from 454.In osreldate.h ; 455parse this file if you need to get the release version of 456the currently installed userland. 457.It Li KERN_OSRELEASE 458The system release string. 459.It Li KERN_OSREV 460The system revision number. 461.It Li KERN_OSTYPE 462The system type string. 463.It Li KERN_POSIX1 464The version of 465.St -p1003.1 466with which the system 467attempts to comply. 468.It Li KERN_PROC 469Return selected information about specific running processes. 470.Pp 471For the following names, an array of 472.Va struct kinfo_proc 473structures is returned, 474whose size depends on the current number of such objects in the system. 475.Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent 476.It Sy Third Level Name Ta Sy Fourth Level 477.It Dv KERN_PROC_ALL Ta None 478.It Dv KERN_PROC_PID Ta A process ID 479.It Dv KERN_PROC_PGRP Ta A process group 480.It Dv KERN_PROC_SESSION Ta A session 481.It Dv KERN_PROC_TTY Ta A tty device 482.It Dv KERN_PROC_UID Ta An effective user ID 483.It Dv KERN_PROC_RUID Ta A real user ID 484.It Dv KERN_PROC_GID Ta An effective group ID 485.It Dv KERN_PROC_RGID Ta A real group ID 486.El 487.Pp 488For the following names, the miscellaneous information about the target 489process, which is specified by the fourth level of the oid name, 490is returned. 491A process ID of 492.Li \-1 493specifies the current process. 494.Bl -column "Third Level NameXXXXXX" "TypeXXXXXX" -offset indent 495.It Sy Third Level Name Ta Sy Fourth Level 496.It Dv KERN_PROC_ARGS Ta "Set of strings" 497.It Dv KERN_PROC_PATHNAME Ta "String" 498.It Dv KERN_PROC_KSTACK Ta "struct kinfo_stack []" 499.It Dv KERN_PROC_VMMAP Ta "struct kinfo_vmentry []" 500.It Dv KERN_PROC_FILEDESC Ta "struct kinfo_file []" 501.It Dv KERN_PROC_GROUPS Ta "gid_t []" 502.It Dv KERN_PROC_ENV Ta "Set of strings" 503.It Dv KERN_PROC_AUXV Ta "Elf_Auxinfo []" 504.It Dv KERN_PROC_RLIMIT Ta "struct rlimit" 505.It Dv KERN_PROC_PS_STRINGS Ta "Pointer to struct ps_strings" 506.It Dv KERN_PROC_UMASK Ta "Integer/short" 507.It Dv KERN_PROC_OSREL Ta "Integer" 508.It Dv KERN_PROC_SIGTRAMP Ta "struct kinfo_sigtramp" 509.It Dv KERN_PROC_CWD Ta "struct kinfo_file" 510.It Dv KERN_PROC_NFDS Ta "Integer" 511.It Dv KERN_PROC_SIGFASTBLK Ta "Address" 512.It Dv KERN_PROC_VM_LAYOUT Ta "struct kinfo_vm_layout" 513.It Dv KERN_PROC_RLIMIT_USAGE Ta "rlim_t []" 514.It Dv KERN_PROC_KQUEUE Ta "struct kinfo_knote []" 515.El 516.Pp 517.Bl -tag -compact 518.It Dv KERN_PROC_ARGS 519The command line argument 520array is returned in a flattened form, i.e., zero-terminated arguments 521follow each other. 522The total size of array is returned. 523It is also possible for a process to set its own process title this way. 524.It Dv KERN_PROC_PATHNAME 525The path of the process' text file is returned. 526.It Dv KERN_PROC_KSTACK 527The in-kernel call stacks for the threads of the specified process. 528.It Dv KERN_PROC_VMMAP 529The description of the map entries for the process. 530Also refer to 531.Xr kinfo_getvmmap 3 . 532.It Dv KERN_PROC_FILEDESC 533The file descriptors for files opened in the specified process. 534Also refer to 535.Xr kinfo_getfile 3 . 536.It Dv KERN_PROC_GROUPS 537Groups associated with the process. 538.It Dv KERN_PROC_ENV 539The set of strings representing the environment of the specified process. 540.Pp 541Note that from the kernel point of view, environment exists only at the 542time of 543.Xr execve 2 544system call. 545This node method tries to reconstruct the environment from the known 546breadcrumbs left in the process address space, but it is not guaranteed 547to succeed or to represent the current value as maintained by the program. 548.It Dv KERN_PROC_AUXV 549The set of ELF auxv entries. 550See the note above about environment, which is also applicable to auxv. 551.It Dv KERN_PROC_RLIMIT 552Additinal OID name element must be supplied, specifiing the resource name 553as in 554.Xr getrlimit 2 . 555The call returns the given resource limit for the process. 556.It Dv KERN_PROC_PS_STRINGS 557Returns the location of the 558.Vt ps_strings 559structure at the time of the last call to 560.Xr execve 2 561in the specified process. 562.It Dv KERN_PROC_UMASK 563The current umask value, see 564.Xr umask 2 . 565.It Dv KERN_PROC_OSREL 566The value of osrel for the process, that is the osrel the currently executed 567image was compiled for. 568Read from the note of the elf executable at 569.Xr execve 2 570time. 571Might be modified by the process. 572.It Dv KERN_PROC_SIGTRAMP 573Structure describing the address range of the signal trampoline in the 574process address space, 575where, simplifying, the kernel passes control for signal delivery. 576.It Dv KERN_PROC_CWD 577Returns the current working directory for the process. 578.It Dv KERN_PROC_NFDS 579Returns the total number of opened file descriptors for the process. 580.It Dv KERN_PROC_SIGFASTBLK 581Returns the address of the 582.Xr sigfastblock 2 583location, if active. 584.It Dv KERN_PROC_VM_LAYOUT 585Fills a structure describing process virtual address space layout. 586.It Dv KERN_PROC_RLIMIT_USAGE 587Like 588.Dv KERN_PROC_RLIMIT , 589but instead of the limit, returns the accounted resource usage. 590If the MIB is of the form 591.Li kern.proc.rlimit_usage\&. Ns Va pid , 592usage values for all resources are returned. 593If the MIB is of the form 594.Li kern.proc.rlimit_usage\&. Ns Va pid Ns \&. Ns Va resource , 595the usage value for the specified resource is returned. 596For resources which do not have a meaningful current value, 597.Li \-1 598is returned. 599.It Dv KERN_PROC_KQUEUE 600Fills an array of structures describing events registered with 601the specified kqueue. 602The next two node's values are the 603.Va pid 604and 605.Va kqfd , 606the process ID of the process, and the file descriptor of the kqueue 607in that process, to query. 608.El 609.It Li KERN_PS_STRINGS 610Reports the location of the process 611.Vt ps_strings 612structure after exec, for the ABI of the querying process. 613.It Li KERN_SAVED_IDS 614Returns 1 if saved set-group and saved set-user ID is available. 615.It Li KERN_SECURELVL 616The system security level. 617This level may be raised by processes with appropriate privilege. 618It may not be lowered. 619.It Li KERN_USRSTACK 620Reports the top of the main thread user stack for the current process. 621.It Li KERN_VERSION 622The system version string. 623.El 624.Ss CTL_NET 625The string and integer information available for the CTL_NET level 626is detailed below. 627The changeable column shows whether a process with appropriate 628privilege may change the value. 629.Bl -column "Second Level NameXXXXXX" "routing messagesXXX" -offset indent 630.It Sy Second Level Name Ta Sy Type Ta Sy Changeable 631.It Dv PF_ROUTE Ta routing messages Ta no 632.It Dv PF_INET Ta IPv4 values Ta yes 633.It Dv PF_INET6 Ta IPv6 values Ta yes 634.El 635.Bl -tag -width 6n 636.It Li PF_ROUTE 637Return the entire routing table or a subset of it. 638The data is returned as a sequence of routing messages (see 639.Xr route 4 640for the header file, format and meaning). 641The length of each message is contained in the message header. 642.Pp 643The third level name is a protocol number, which is currently always 0. 644The fourth level name is an address family, which may be set to 0 to 645select all address families. 646The fifth, sixth, and seventh level names are as follows: 647.Bl -column -offset indent "Fifth Level" "Sixth Level" "Seventh Level" 648.It Sy Fifth level Ta Sy Sixth Level Ta Sy Seventh Level 649.It Dv NET_RT_FLAGS Ta rtflags Ta None 650.It Dv NET_RT_DUMP Ta None Ta None or fib number 651.It Dv NET_RT_IFLIST Ta 0 or if_index Ta None 652.It Dv NET_RT_IFMALIST Ta 0 or if_index Ta None 653.It Dv NET_RT_IFLISTL Ta 0 or if_index Ta None 654.It Dv NET_RT_NHOPS Ta None Ta fib number 655.El 656.Pp 657The 658.Dv NET_RT_IFMALIST 659name returns information about multicast group memberships on all interfaces 660if 0 is specified, or for the interface specified by 661.Va if_index . 662.Pp 663The 664.Dv NET_RT_IFLISTL 665is like 666.Dv NET_RT_IFLIST , 667just returning message header structs with additional fields allowing the 668interface to be extended without breaking binary compatibility. 669The 670.Dv NET_RT_IFLISTL 671uses 'l' versions of the message header structures: 672.Va struct if_msghdrl 673and 674.Va struct ifa_msghdrl . 675.Pp 676.Dv NET_RT_NHOPS 677returns all nexthops for specified address family in given fib. 678.It Li PF_INET 679Get or set various global information about the IPv4 680(Internet Protocol version 4). 681The third level name is the protocol. 682The fourth level name is the variable name. 683The currently defined protocols and names are: 684.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX 685.It Sy Protocol Ta Sy Variable Ta Sy Type Ta Sy Changeable 686.It icmp Ta bmcastecho Ta integer Ta yes 687.It icmp Ta maskrepl Ta integer Ta yes 688.It ip Ta forwarding Ta integer Ta yes 689.It ip Ta redirect Ta integer Ta yes 690.It ip Ta ttl Ta integer Ta yes 691.It udp Ta checksum Ta integer Ta yes 692.El 693.Pp 694The variables are as follows: 695.Bl -tag -width 6n 696.It Li icmp.bmcastecho 697Returns 1 if an ICMP echo request to a broadcast or multicast address is 698to be answered. 699.It Li icmp.maskrepl 700Returns 1 if ICMP network mask requests are to be answered. 701.It Li ip.forwarding 702Returns 1 when IP forwarding is enabled for the host, 703meaning that the host is acting as a router. 704.It Li ip.redirect 705Returns 1 when ICMP redirects may be sent by the host. 706This option is ignored unless the host is routing IP packets, 707and should normally be enabled on all systems. 708.It Li ip.ttl 709The maximum time-to-live (hop count) value for an IP packet sourced by 710the system. 711This value applies to normal transport protocols, not to ICMP. 712.It Li udp.checksum 713Returns 1 when UDP checksums are being computed and checked. 714Disabling UDP checksums is strongly discouraged. 715.Pp 716For variables net.inet.*.ipsec, please refer to 717.Xr ipsec 4 . 718.El 719.It Li PF_INET6 720Get or set various global information about the IPv6 721(Internet Protocol version 6). 722The third level name is the protocol. 723The fourth level name is the variable name. 724.Pp 725For variables net.inet6.* please refer to 726.Xr inet6 4 . 727For variables net.inet6.*.ipsec6, please refer to 728.Xr ipsec 4 . 729.El 730.Ss CTL_USER 731The string and integer information available for the CTL_USER level 732is detailed below. 733The changeable column shows whether a process with appropriate 734privilege may change the value. 735.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent 736.It Sy Second Level Name Ta Sy Type Ta Sy Changeable 737.It Dv USER_BC_BASE_MAX Ta integer Ta no 738.It Dv USER_BC_DIM_MAX Ta integer Ta no 739.It Dv USER_BC_SCALE_MAX Ta integer Ta no 740.It Dv USER_BC_STRING_MAX Ta integer Ta no 741.It Dv USER_COLL_WEIGHTS_MAX Ta integer Ta no 742.It Dv USER_CS_PATH Ta string Ta no 743.It Dv USER_EXPR_NEST_MAX Ta integer Ta no 744.It Dv USER_LINE_MAX Ta integer Ta no 745.It Dv USER_LOCALBASE Ta string Ta no 746.It Dv USER_POSIX2_CHAR_TERM Ta integer Ta no 747.It Dv USER_POSIX2_C_BIND Ta integer Ta no 748.It Dv USER_POSIX2_C_DEV Ta integer Ta no 749.It Dv USER_POSIX2_FORT_DEV Ta integer Ta no 750.It Dv USER_POSIX2_FORT_RUN Ta integer Ta no 751.It Dv USER_POSIX2_LOCALEDEF Ta integer Ta no 752.It Dv USER_POSIX2_SW_DEV Ta integer Ta no 753.It Dv USER_POSIX2_UPE Ta integer Ta no 754.It Dv USER_POSIX2_VERSION Ta integer Ta no 755.It Dv USER_RE_DUP_MAX Ta integer Ta no 756.It Dv USER_STREAM_MAX Ta integer Ta no 757.It Dv USER_TZNAME_MAX Ta integer Ta no 758.El 759.Bl -tag -width 6n 760.It Li USER_BC_BASE_MAX 761The maximum ibase/obase values in the 762.Xr bc 1 763utility. 764.It Li USER_BC_DIM_MAX 765The maximum array size in the 766.Xr bc 1 767utility. 768.It Li USER_BC_SCALE_MAX 769The maximum scale value in the 770.Xr bc 1 771utility. 772.It Li USER_BC_STRING_MAX 773The maximum string length in the 774.Xr bc 1 775utility. 776.It Li USER_COLL_WEIGHTS_MAX 777The maximum number of weights that can be assigned to any entry of 778the LC_COLLATE order keyword in the locale definition file. 779.It Li USER_CS_PATH 780Return a value for the 781.Ev PATH 782environment variable that finds all the standard utilities. 783.It Li USER_EXPR_NEST_MAX 784The maximum number of expressions that can be nested within 785parenthesis by the 786.Xr expr 1 787utility. 788.It Li USER_LINE_MAX 789The maximum length in bytes of a text-processing utility's input 790line. 791.It Li USER_LOCALBASE 792Return the value of localbase that has been compiled into system utilities 793that need to have access to resources provided by a port or package. 794.It Li USER_POSIX2_CHAR_TERM 795Return 1 if the system supports at least one terminal type capable of 796all operations described in 797.St -p1003.2 , 798otherwise 0. 799.It Li USER_POSIX2_C_BIND 800Return 1 if the system's C-language development facilities support the 801C-Language Bindings Option, otherwise 0. 802.It Li USER_POSIX2_C_DEV 803Return 1 if the system supports the C-Language Development Utilities Option, 804otherwise 0. 805.It Li USER_POSIX2_FORT_DEV 806Return 1 if the system supports the FORTRAN Development Utilities Option, 807otherwise 0. 808.It Li USER_POSIX2_FORT_RUN 809Return 1 if the system supports the FORTRAN Runtime Utilities Option, 810otherwise 0. 811.It Li USER_POSIX2_LOCALEDEF 812Return 1 if the system supports the creation of locales, otherwise 0. 813.It Li USER_POSIX2_SW_DEV 814Return 1 if the system supports the Software Development Utilities Option, 815otherwise 0. 816.It Li USER_POSIX2_UPE 817Return 1 if the system supports the User Portability Utilities Option, 818otherwise 0. 819.It Li USER_POSIX2_VERSION 820The version of 821.St -p1003.2 822with which the system attempts to comply. 823.It Li USER_RE_DUP_MAX 824The maximum number of repeated occurrences of a regular expression 825permitted when using interval notation. 826.It Li USER_STREAM_MAX 827The minimum maximum number of streams that a process may have open 828at any one time. 829.It Li USER_TZNAME_MAX 830The minimum maximum number of types supported for the name of a 831timezone. 832.El 833.Ss CTL_VM 834The string and integer information available for the CTL_VM level 835is detailed below. 836The changeable column shows whether a process with appropriate 837privilege may change the value. 838.Bl -column "Second Level NameXXXXXX" "struct loadavgXXX" -offset indent 839.It Sy Second Level Name Ta Sy Type Ta Sy Changeable 840.It Dv VM_LOADAVG Ta struct loadavg Ta no 841.It Dv VM_TOTAL Ta struct vmtotal Ta no 842.It Dv VM_SWAPPING_ENABLED Ta integer Ta maybe 843.It Dv VM_V_FREE_MIN Ta integer Ta yes 844.It Dv VM_V_FREE_RESERVED Ta integer Ta yes 845.It Dv VM_V_FREE_TARGET Ta integer Ta yes 846.It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes 847.It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes 848.It Dv VM_OVERCOMMIT Ta integer Ta yes 849.El 850.Bl -tag -width 6n 851.It Li VM_LOADAVG 852Return the load average history. 853The returned data consists of a 854.Va struct loadavg . 855.It Li VM_TOTAL 856Return the system wide virtual memory statistics. 857The returned data consists of a 858.Va struct vmtotal . 859.It Li VM_SWAPPING_ENABLED 8601 if process swapping is enabled or 0 if disabled. 861This variable is 862permanently set to 0 if the kernel was built with swapping disabled. 863.It Li VM_V_FREE_MIN 864Minimum amount of memory (cache memory plus free memory) 865required to be available before a process waiting on memory will be 866awakened. 867.It Li VM_V_FREE_RESERVED 868Processes will awaken the pageout daemon and wait for memory if the 869number of free and cached pages drops below this value. 870.It Li VM_V_FREE_TARGET 871The total amount of free memory (including cache memory) that the 872pageout daemon tries to maintain. 873.It Li VM_V_INACTIVE_TARGET 874The desired number of inactive pages that the pageout daemon should 875achieve when it runs. 876Inactive pages can be quickly inserted into 877process address space when needed. 878.It Li VM_V_PAGEOUT_FREE_MIN 879If the amount of free and cache memory falls below this value, the 880pageout daemon will enter "memory conserving mode" to avoid deadlock. 881.It Li VM_OVERCOMMIT 882Overcommit behaviour, as described in 883.Xr tuning 7 . 884.El 885.Sh RETURN VALUES 886.Rv -std 887.Sh FILES 888.Bl -tag -width <netinet/icmpXvar.h> -compact 889.It In sys/sysctl.h 890definitions for top level identifiers, second level kernel and hardware 891identifiers, and user level identifiers 892.It In sys/socket.h 893definitions for second level network identifiers 894.It In sys/gmon.h 895definitions for third level profiling identifiers 896.It In vm/vm_param.h 897definitions for second level virtual memory identifiers 898.It In netinet/in.h 899definitions for third level IPv4/IPv6 identifiers and 900fourth level IPv4/v6 identifiers 901.It In netinet/icmp_var.h 902definitions for fourth level ICMP identifiers 903.It In netinet/icmp6.h 904definitions for fourth level ICMPv6 identifiers 905.It In netinet/udp_var.h 906definitions for fourth level UDP identifiers 907.El 908.Sh ERRORS 909The following errors may be reported: 910.Bl -tag -width Er 911.It Bq Er EFAULT 912The buffer 913.Fa name , 914.Fa oldp , 915.Fa newp , 916or length pointer 917.Fa oldlenp 918contains an invalid address. 919.It Bq Er EINVAL 920The 921.Fa name 922array is less than two or greater than CTL_MAXNAME. 923.It Bq Er EINVAL 924A non-null 925.Fa newp 926is given and its specified length in 927.Fa newlen 928is too large or too small. 929.It Bq Er ENOMEM 930The length pointed to by 931.Fa oldlenp 932is too short to hold the requested value. 933.It Bq Er ENOMEM 934The smaller of either the length pointed to by 935.Fa oldlenp 936or the estimated size of the returned data exceeds the 937system limit on locked memory. 938.It Bq Er ENOMEM 939Locking the buffer 940.Fa oldp , 941or a portion of the buffer if the estimated size of the data 942to be returned is smaller, 943would cause the process to exceed its per-process locked memory limit. 944.It Bq Er ENOTDIR 945The 946.Fa name 947array specifies an intermediate rather than terminal name. 948.It Bq Er EISDIR 949The 950.Fa name 951array specifies a terminal name, but the actual name is not terminal. 952.It Bq Er ENOENT 953The 954.Fa name 955array specifies a value that is unknown. 956.It Bq Er EPERM 957An attempt is made to set a read-only value. 958.It Bq Er EPERM 959A process without appropriate privilege attempts to set a value. 960.El 961.Sh SEE ALSO 962.Xr confstr 3 , 963.Xr kinfo_getproc 3 , 964.Xr kvm 3 , 965.Xr sysconf 3 , 966.Xr sysctl 8 967.Sh HISTORY 968The 969.Fn sysctl 970function first appeared in 971.Bx 4.4 . 972