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.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 29.\" $FreeBSD: src/lib/libc/gen/sysctl.3,v 1.33.2.13 2002/04/07 04:57:14 dd Exp $ 30.\" 31.Dd January 18, 2015 32.Dt SYSCTL 3 33.Os 34.Sh NAME 35.Nm sysctl , 36.Nm sysctlbyname , 37.Nm sysctlnametomib 38.Nd get or set system information 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In sys/types.h 43.In sys/sysctl.h 44.Ft int 45.Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" 46.Ft int 47.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "const void *newp" "size_t newlen" 48.Ft int 49.Fn sysctlnametomib "const char *name" "int *mibp" "size_t *sizep" 50.Sh DESCRIPTION 51The 52.Fn sysctl 53function retrieves system information and allows processes with 54appropriate privileges to set system information. 55The information available from 56.Fn sysctl 57consists of integers, strings, and tables. 58Information may be retrieved and set from the command interface 59using the 60.Xr sysctl 8 61utility. 62.Pp 63Unless explicitly noted below, 64.Fn sysctl 65returns a consistent snapshot of the data requested. 66Consistency is obtained by locking the destination 67buffer into memory so that the data may be copied out without blocking. 68Calls to 69.Fn sysctl 70are serialized to avoid deadlock. 71.Pp 72The state is described using a 73.Dq Management Information Base (MIB) 74style name, listed in 75.Fa name , 76which is a 77.Fa namelen 78length array of integers. 79.Pp 80The 81.Fn sysctlbyname 82function accepts an ASCII representation of the name and internally 83looks up the integer name vector. Apart from that, it behaves the same 84as the standard 85.Fn sysctl 86function. 87.Pp 88The information is copied into the buffer specified by 89.Fa oldp . 90The size of the buffer is given by the location specified by 91.Fa oldlenp 92before the call, 93and that location gives the amount of data copied after a successful call 94and after a call that returns with the error code 95.Er ENOMEM . 96If the amount of data available is greater 97than the size of the buffer supplied, 98the call supplies as much data as fits in the buffer provided 99and returns with the error code 100.Er ENOMEM . 101If the old value is not desired, 102.Fa oldp 103and 104.Fa oldlenp 105should be set to NULL. 106.Pp 107The size of the available data can be determined by calling 108.Fn sysctl 109with a NULL parameter for 110.Fa oldp . 111The size of the available data will be returned in the location pointed to by 112.Fa oldlenp . 113For some operations, the amount of space may change often. 114For these operations, 115the system attempts to round up so that the returned size is 116large enough for a call to return the data shortly thereafter. 117.Pp 118To set a new value, 119.Fa newp 120is set to point to a buffer of length 121.Fa newlen 122from which the requested value is to be taken. 123If a new value is not to be set, 124.Fa newp 125should be set to NULL and 126.Fa newlen 127set to 0. 128.Pp 129The 130.Fn sysctlnametomib 131function accepts an ASCII representation of the name, 132looks up the integer name vector, 133and returns the numeric representation in the mib array pointed to by 134.Fa mibp . 135The number of elements in the mib array is given by the location specified by 136.Fa sizep 137before the call, 138and that location gives the number of entries copied after a successful call. 139The resulting 140.Fa mib 141and 142.Fa size 143may be used in subsequent 144.Fn sysctl 145calls to get the data associated with the requested ASCII name. 146This interface is intended for use by applications that want to 147repeatedly request the same variable (the 148.Fn sysctl 149function runs in about a third the time as the same request made via the 150.Fn sysctlbyname 151function). 152The 153.Fn sysctlnametomib 154function is also useful for fetching mib prefixes and then adding 155a final component. 156For example, to fetch process information 157for processes with pid's less than 100: 158.Pp 159.Bd -literal -offset indent -compact 160int i, mib[4]; 161size_t len; 162struct kinfo_proc kp; 163 164/* Fill out the first three components of the mib */ 165len = 4; 166sysctlnametomib("kern.proc.pid", mib, &len); 167 168/* Fetch and print entries for pid's < 100 */ 169for (i = 0; i < 100; i++) { 170 mib[3] = i; 171 len = sizeof(kp); 172 if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1) 173 perror("sysctl"); 174 else if (len > 0) 175 printkproc(&kp); 176} 177.Ed 178.Pp 179The top level names are defined with a CTL_ prefix in 180.In sys/sysctl.h , 181and are as follows. 182The next and subsequent levels down are found in the include files 183listed here, and described in separate sections below. 184.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent 185.It Sy "Name" Ta Sy "Next level names" Ta Sy "Description" 186.It Dv CTL_DEBUG Ta "sys/sysctl.h" Ta "Debugging" 187.It Dv CTL_VFS Ta "sys/mount.h" Ta "Filesystem" 188.It Dv CTL_HW Ta "sys/sysctl.h" Ta "Generic CPU, I/O" 189.It Dv CTL_KERN Ta "sys/sysctl.h" Ta "High kernel limits" 190.It Dv CTL_MACHDEP Ta "sys/sysctl.h" Ta "Machine dependent" 191.It Dv CTL_NET Ta "sys/socket.h" Ta "Networking" 192.It Dv CTL_USER Ta "sys/sysctl.h" Ta "User-level" 193.It Dv CTL_VM Ta "vm/vm_param.h" Ta "Virtual memory" 194.El 195.Pp 196For example, the following retrieves the maximum number of processes allowed 197in the system: 198.Pp 199.Bd -literal -offset indent -compact 200int mib[2], maxproc; 201size_t len; 202 203mib[0] = CTL_KERN; 204mib[1] = KERN_MAXPROC; 205len = sizeof(maxproc); 206sysctl(mib, 2, &maxproc, &len, NULL, 0); 207.Ed 208.Pp 209To retrieve the standard search path for the system utilities: 210.Pp 211.Bd -literal -offset indent -compact 212int mib[2]; 213size_t len; 214char *p; 215 216mib[0] = CTL_USER; 217mib[1] = USER_CS_PATH; 218sysctl(mib, 2, NULL, &len, NULL, 0); 219p = malloc(len); 220sysctl(mib, 2, p, &len, NULL, 0); 221.Ed 222.Ss CTL_DEBUG 223The debugging variables vary from system to system. 224A debugging variable may be added or deleted without need to recompile 225.Fn sysctl 226to know about it. 227Each time it runs, 228.Fn sysctl 229gets the list of debugging variables from the kernel and 230displays their current values. 231The system defines twenty 232.Vt ( struct ctldebug ) 233variables named 234.Nm debug0 235through 236.Nm debug19 . 237They are declared as separate variables so that they can be 238individually initialized at the location of their associated variable. 239The loader prevents multiple use of the same variable by issuing errors 240if a variable is initialized in more than one place. 241For example, to export the variable 242.Nm dospecialcheck 243as a debugging variable, the following declaration would be used: 244.Bd -literal -offset indent -compact 245int dospecialcheck = 1; 246struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck }; 247.Ed 248.Ss CTL_VFS 249A distinguished second level name, VFS_GENERIC, 250is used to get general information about all filesystems. 251One of its third level identifiers is VFS_MAXTYPENUM 252that gives the highest valid filesystem type number. 253Its other third level identifier is VFS_CONF that 254returns configuration information about the filesystem 255type given as a fourth level identifier (see 256.Xr getvfsbyname 3 257as an example of its use). 258The remaining second level identifiers are the 259filesystem type number returned by a 260.Xr statfs 2 261call or from VFS_CONF. 262The third level identifiers available for each filesystem 263are given in the header file that defines the mount 264argument structure for that filesystem. 265.Ss CTL_HW 266The string and integer information available for the 267.Dv CTL_HW 268level 269is detailed below. 270The changeable column shows whether a process with appropriate 271privilege may change the value. 272.Bl -column "Second level nameXXXXXX" integerXXX -offset indent 273.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 274.It Dv HW_MACHINE Ta "string" Ta "no" 275.It Dv HW_MODEL Ta "string" Ta "no" 276.It Dv HW_NCPU Ta "integer" Ta "no" 277.It Dv HW_BYTEORDER Ta "integer" Ta "no" 278.It Dv HW_PHYSMEM Ta "integer" Ta "no" 279.It Dv HW_USERMEM Ta "integer" Ta "no" 280.It Dv HW_PAGESIZE Ta "integer" Ta "no" 281.It Dv HW_FLOATINGPT Ta "integer" Ta "no" 282.It Dv HW_MACHINE_ARCH Ta "string" Ta "no" 283.It Dv HW_MACHINE_PLATFORM Ta "string" Ta "no" 284.\".It Dv HW_DISKNAMES Ta "integer" Ta "no" 285.\".It Dv HW_DISKSTATS Ta "integer" Ta "no" 286.It Dv HW_SENSORS Ta "node" Ta "not applicable" 287.El 288.Bl -tag -width 6n 289.It Dv HW_MACHINE 290The machine class. 291.It Dv HW_MODEL 292The machine model 293.It Dv HW_NCPU 294The number of cpus. 295.It Dv HW_BYTEORDER 296The byteorder (4321, or 1234). 297.It Dv HW_PHYSMEM 298The bytes of physical memory. 299.It Dv HW_USERMEM 300The bytes of non-kernel memory. 301.It Dv HW_PAGESIZE 302The software page size. 303.It Dv HW_FLOATINGPT 304Nonzero if the floating point support is in hardware. 305.It Dv HW_MACHINE_ARCH 306The machine dependent architecture type. 307.It Dv HW_MACHINE_PLATFORM 308The platform architecture type. 309.\".It Dv HW_DISKNAMES 310.\".It Dv HW_DISKSTATS 311.It Dv HW_SENSORS 312Third level comprises an array of 313.Vt "struct sensordev" 314structures containing information about devices 315that may attach hardware monitoring sensors. 316.Pp 317Third, fourth and fifth levels together comprise an array of 318.Vt "struct sensor" 319structures containing snapshot readings of hardware monitoring sensors. 320In such usage, third level indicates the numerical representation 321of the sensor device name to which the sensor is attached 322(device's 323.Va xname 324and number shall be matched with the help of 325.Vt "struct sensordev" 326structure above), 327fourth level indicates sensor type and 328fifth level is an ordinal sensor number (unique to 329the specified sensor type on the specified sensor device). 330.Pp 331The 332.Vt sensordev 333and 334.Vt sensor 335structures 336and 337.Vt sensor_type 338enumeration 339are defined in 340.In sys/sensors.h . 341.El 342.Ss CTL_KERN 343The string and integer information available for the 344.Dv CTL_KERN 345level 346is detailed below. 347The changeable column shows whether a process with appropriate 348privilege may change the value. 349The types of data currently available are process information, 350system vnodes, the open file entries, routing table entries, 351virtual memory statistics, load average history, and clock rate 352information. 353.Bl -column "KERNXMAXPOSIXLOCKSPERUIDXXX" "struct clockrateXXX" -offset indent 354.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 355.It Dv KERN_ARGMAX Ta "integer" Ta "no" 356.It Dv KERN_BOOTFILE Ta "string" Ta "yes" 357.It Dv KERN_BOOTTIME Ta "struct timeval" Ta "no" 358.It Dv KERN_CLOCKRATE Ta "struct clockinfo" Ta "no" 359.It Dv KERN_FILE Ta "struct file" Ta "no" 360.It Dv KERN_HOSTID Ta "integer" Ta "yes" 361.It Dv KERN_HOSTNAME Ta "string" Ta "yes" 362.It Dv KERN_JOB_CONTROL Ta "integer" Ta "no" 363.It Dv KERN_MAXFILES Ta "integer" Ta "yes" 364.It Dv KERN_MAXFILESPERPROC Ta "integer" Ta "yes" 365.It Dv KERN_MAXPOSIXLOCKSPERUID Ta "integer" Ta "yes" 366.It Dv KERN_MAXPROC Ta "integer" Ta "no" 367.It Dv KERN_MAXPROCPERUID Ta "integer" Ta "yes" 368.It Dv KERN_MAXVNODES Ta "integer" Ta "yes" 369.It Dv KERN_NGROUPS Ta "integer" Ta "no" 370.It Dv KERN_NISDOMAINNAME Ta "string" Ta "yes" 371.It Dv KERN_OSRELDATE Ta "integer" Ta "no" 372.It Dv KERN_OSRELEASE Ta "string" Ta "no" 373.It Dv KERN_OSREV Ta "integer" Ta "no" 374.It Dv KERN_OSTYPE Ta "string" Ta "no" 375.It Dv KERN_POSIX1 Ta "integer" Ta "no" 376.It Dv KERN_PROC Ta "struct proc" Ta "no" 377.It Dv KERN_PROF Ta "node" Ta "not applicable" 378.It Dv KERN_QUANTUM Ta "integer" Ta "yes" 379.It Dv KERN_SAVED_IDS Ta "integer" Ta "no" 380.It Dv KERN_SECURELVL Ta "integer" Ta "raise only" 381.It Dv KERN_UPDATEINTERVAL Ta "integer" Ta "no" 382.It Dv KERN_VERSION Ta "string" Ta "no" 383.It Dv KERN_VNODE Ta "struct vnode" Ta "no" 384.El 385.Bl -tag -width 6n 386.It Dv KERN_ARGMAX 387The maximum bytes of argument to 388.Xr execve 2 . 389.It Dv KERN_BOOTFILE 390The full pathname of the file from which the kernel was loaded. 391.It Dv KERN_BOOTTIME 392A 393.Va struct timeval 394structure is returned. 395This structure contains the time that the system was booted. 396.It Dv KERN_CLOCKRATE 397A 398.Va struct clockinfo 399structure is returned. 400This structure contains the clock, statistics clock and profiling clock 401frequencies, the number of micro-seconds per hz tick and the skew rate. 402.It Dv KERN_FILE 403Return the entire file table. 404The returned data consists of a single 405.Va struct filehead 406followed by an array of 407.Va struct file , 408whose size depends on the current number of such objects in the system. 409.It Dv KERN_HOSTID 410Get or set the host id. 411.It Dv KERN_HOSTNAME 412Get or set the hostname. 413.It Dv KERN_JOB_CONTROL 414Return 1 if job control is available on this system, otherwise 0. 415.It Dv KERN_MAXFILES 416The maximum number of files that may be open in the system. 417.It Dv KERN_MAXFILESPERPROC 418The maximum number of files that may be open for a single process. 419This limit only applies to processes with an effective uid of nonzero 420at the time of the open request. 421Files that have already been opened are not affected if the limit 422or the effective uid is changed. 423.It Dv KERN_MAXPROC 424The maximum number of concurrent processes the system will allow. 425.It Dv KERN_MAXPROCPERUID 426The maximum number of concurrent processes the system will allow 427for a single effective uid. 428This limit only applies to processes with an effective uid of nonzero 429at the time of a fork request. 430Processes that have already been started are not affected if the limit 431is changed. 432.It Dv KERN_MAXVNODES 433The maximum number of vnodes available on the system. 434.It Dv KERN_NGROUPS 435The maximum number of supplemental groups. 436.It Dv KERN_NISDOMAINNAME 437The name of the current YP/NIS domain. 438.It Dv KERN_OSRELDATE 439The system release date in YYYYMM format 440(January 1996 is encoded as 199601). 441.It Dv KERN_OSRELEASE 442The system release string. 443.It Dv KERN_OSREV 444The system revision string. 445.It Dv KERN_OSTYPE 446The system type string. 447.It Dv KERN_POSIX1 448The version of 449.St -p1003.1 450with which the system 451attempts to comply. 452.It Dv KERN_PROC 453Return selected information about specific running processes. 454.Pp 455For the following names, an array of 456.Va struct kinfo_proc 457structures is returned, 458whose size depends on the current number of such objects in the system. 459Adding the flag 460.Dv KERN_PROC_FLAG_LWP 461to the third level name signals that information about all 462light weight processes of the selected processes should be returned. 463.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent 464.It Sy "Third level name" Ta Sy "Fourth level is:" 465.It Dv KERN_PROC_ALL Ta "None" 466.It Dv KERN_PROC_PID Ta "A process ID" 467.It Dv KERN_PROC_PGRP Ta "A process group" 468.It Dv KERN_PROC_TTY Ta "A tty device" 469.It Dv KERN_PROC_UID Ta "A user ID" 470.It Dv KERN_PROC_RUID Ta "A real user ID" 471.El 472.Pp 473For the following names, a NUL-terminated string is returned. 474.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent 475.It Sy "Third level name" Ta Sy "Fourth level is:" 476.It Dv KERN_PROC_ARGS Ta "A process ID" 477.It Dv KERN_PROC_CWD Ta "A process ID" 478.It Dv KERN_PROC_PATHNAME Ta "A process ID" 479.El 480.Pp 481The variables are as follows: 482.Bl -tag -width 6n 483.It Dv KERN_PROC_ARGS 484Returns the command line argument array of a process, in a flattened form, 485i.e. NUL-terminated arguments follow each other. 486A process ID of 487.Li \-1 488implies the current process. 489A process can set its own process title by changing this value. 490.It Dv KERN_PROC_CWD 491Returns the current working directory of a process. 492.It Dv KERN_PROC_PATHNAME 493Returns the path of a process' text file. 494.El 495.It Dv KERN_PROF 496Return profiling information about the kernel. 497If the kernel is not compiled for profiling, 498attempts to retrieve any of the 499.Dv KERN_PROF 500values will 501fail with 502.Er ENOENT . 503The third level names for the string and integer profiling information 504is detailed below. 505The changeable column shows whether a process with appropriate 506privilege may change the value. 507.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent 508.It Sy "Third level name" Ta Sy "Type" Ta Sy "Changeable" 509.It Dv GPROF_STATE Ta "integer" Ta "yes" 510.It Dv GPROF_COUNT Ta "u_short[]" Ta "yes" 511.It Dv GPROF_FROMS Ta "u_short[]" Ta "yes" 512.It Dv GPROF_TOS Ta "struct tostruct" Ta "yes" 513.It Dv GPROF_GMONPARAM Ta "struct gmonparam" Ta "no" 514.El 515.Pp 516The variables are as follows: 517.Bl -tag -width 6n 518.It Dv GPROF_STATE 519Returns 520.Dv GMON_PROF_ON 521or 522.Dv GMON_PROF_OFF 523to show that profiling is running or stopped. 524.It Dv GPROF_COUNT 525Array of statistical program counter counts. 526.It Dv GPROF_FROMS 527Array indexed by program counter of call-from points. 528.It Dv GPROF_TOS 529Array of 530.Va struct tostruct 531describing destination of calls and their counts. 532.It Dv GPROF_GMONPARAM 533Structure giving the sizes of the above arrays. 534.El 535.It Dv KERN_QUANTUM 536The maximum period of time, in microseconds, for which a process is allowed 537to run without being preempted if other processes are in the run queue. 538.It Dv KERN_SAVED_IDS 539Returns 1 if saved set-group and saved set-user ID is available. 540.It Dv KERN_SECURELVL 541The system security level. 542This level may be raised by processes with appropriate privilege. 543It may not be lowered. 544.It Dv KERN_VERSION 545The system version string. 546.It Dv KERN_VNODE 547Return the entire vnode table. 548Note, the vnode table is not necessarily a consistent snapshot of 549the system. 550The returned data consists of an array whose size depends on the 551current number of such objects in the system. 552Each element of the array contains the kernel address of a vnode 553.Va struct vnode * 554followed by the vnode itself 555.Va struct vnode . 556.El 557.Ss CTL_MACHDEP 558The set of variables defined is architecture dependent. 559The following variables are defined for the i386 architecture. 560.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent 561.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 562.It Dv CPU_CONSDEV Ta "dev_t" Ta "no" 563.It Dv CPU_ADJKERNTZ Ta "int" Ta "yes" 564.It Dv CPU_DISRTCSET Ta "int" Ta "yes" 565.It Dv CPU_BOOTINFO Ta "struct bootinfo" Ta "no" 566.It Dv CPU_WALLCLOCK Ta "int" Ta "yes" 567.El 568.Ss CTL_NET 569The string and integer information available for the 570.Dv CTL_NET 571level is detailed below. 572The changeable column shows whether a process with appropriate 573privilege may change the value. 574.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent 575.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 576.It Dv PF_ROUTE Ta "routing messages" Ta "no" 577.It Dv PF_INET Ta "IPv4 values" Ta "yes" 578.It Dv PF_INET6 Ta "IPv6 values" Ta "yes" 579.El 580.Bl -tag -width 6n 581.It Dv PF_ROUTE 582Return the entire routing table or a subset of it. 583The data is returned as a sequence of routing messages (see 584.Xr route 4 585for the header file, format and meaning). 586The length of each message is contained in the message header. 587.Pp 588The third level name is a protocol number, which is currently always 0. 589The fourth level name is an address family, which may be set to 0 to 590select all address families. 591The fifth and sixth level names are as follows: 592.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent 593.It Sy "Fifth level name" Ta Sy "Sixth level is:" 594.It Dv NET_RT_FLAGS Ta "rtflags" 595.It Dv NET_RT_DUMP Ta "None" 596.It Dv NET_RT_IFLIST Ta "None" 597.El 598.It Dv PF_INET 599Get or set various global information about the IPv4 600.Pq Internet Protocol version 4 . 601The third level name is the protocol. 602The fourth level name is the variable name. 603The currently defined protocols and names are: 604.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX 605.It Sy "Protocol" Ta Sy "Variable" Ta Sy "Type" Ta Sy "Changeable" 606.It icmp Ta bmcastecho Ta integer Ta yes 607.It icmp Ta maskrepl Ta integer Ta yes 608.It ip Ta forwarding Ta integer Ta yes 609.It ip Ta redirect Ta integer Ta yes 610.It ip Ta ttl Ta integer Ta yes 611.It udp Ta checksum Ta integer Ta yes 612.El 613.Pp 614The variables are as follows: 615.Bl -tag -width 6n 616.It Li icmp.bmcastecho 617Returns 1 if an ICMP echo request to a broadcast or multicast address is 618to be answered. 619.It Li icmp.maskrepl 620Returns 1 if ICMP network mask requests are to be answered. 621.It Li ip.forwarding 622Returns 1 when IP forwarding is enabled for the host, 623meaning that the host is acting as a router. 624.It Li ip.redirect 625Returns 1 when ICMP redirects may be sent by the host. 626This option is ignored unless the host is routing IP packets, 627and should normally be enabled on all systems. 628.It Li ip.ttl 629The maximum time-to-live (hop count) value for an IP packet sourced by 630the system. 631This value applies to normal transport protocols, not to ICMP. 632.It Li udp.checksum 633Returns 1 when UDP checksums are being computed and checked. 634Disabling UDP checksums is strongly discouraged. 635.Pp 636For variables net.inet.*.ipsec, please refer to 637.Xr ipsec 4 . 638.El 639.It Dv PF_INET6 640Get or set various global information about IPv6 641.Pq Internet Protocol version 6 . 642The third level name is the protocol. 643The fourth level name is the variable name. 644.Pp 645For variables 646.Li net.inet6.* , 647please refer to 648.Xr inet6 4 . 649For variables 650.Li net.inet6.*.ipsec6 , 651please refer to 652.Xr ipsec 4 . 653.El 654.Ss CTL_USER 655The string and integer information available for the 656.Dv CTL_USER 657level is detailed below. 658The changeable column shows whether a process with appropriate 659privilege may change the value. 660.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent 661.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 662.It Dv USER_BC_BASE_MAX Ta integer Ta no 663.It Dv USER_BC_DIM_MAX Ta integer Ta no 664.It Dv USER_BC_SCALE_MAX Ta integer Ta no 665.It Dv USER_BC_STRING_MAX Ta integer Ta no 666.It Dv USER_COLL_WEIGHTS_MAX Ta integer Ta no 667.It Dv USER_CS_PATH Ta string Ta no 668.It Dv USER_EXPR_NEST_MAX Ta integer Ta no 669.It Dv USER_LINE_MAX Ta integer Ta no 670.It Dv USER_POSIX2_CHAR_TERM Ta integer Ta no 671.It Dv USER_POSIX2_C_BIND Ta integer Ta no 672.It Dv USER_POSIX2_C_DEV Ta integer Ta no 673.It Dv USER_POSIX2_FORT_DEV Ta integer Ta no 674.It Dv USER_POSIX2_FORT_RUN Ta integer Ta no 675.It Dv USER_POSIX2_LOCALEDEF Ta integer Ta no 676.It Dv USER_POSIX2_SW_DEV Ta integer Ta no 677.It Dv USER_POSIX2_UPE Ta integer Ta no 678.It Dv USER_POSIX2_VERSION Ta integer Ta no 679.It Dv USER_RE_DUP_MAX Ta integer Ta no 680.It Dv USER_STREAM_MAX Ta integer Ta no 681.It Dv USER_TZNAME_MAX Ta integer Ta no 682.El 683.Bl -tag -width 6n 684.It Dv USER_BC_BASE_MAX 685The maximum ibase/obase values in the 686.Xr bc 1 687utility. 688.It Dv USER_BC_DIM_MAX 689The maximum array size in the 690.Xr bc 1 691utility. 692.It Dv USER_BC_SCALE_MAX 693The maximum scale value in the 694.Xr bc 1 695utility. 696.It Dv USER_BC_STRING_MAX 697The maximum string length in the 698.Xr bc 1 699utility. 700.It Dv USER_COLL_WEIGHTS_MAX 701The maximum number of weights that can be assigned to any entry of the 702.Dv LC_COLLATE 703order keyword in the locale definition file. 704.It Dv USER_CS_PATH 705Return a value for the 706.Ev PATH 707environment variable that finds all the standard utilities. 708.It Dv USER_EXPR_NEST_MAX 709The maximum number of expressions that can be nested within 710parenthesis by the 711.Xr expr 1 712utility. 713.It Dv USER_LINE_MAX 714The maximum length in bytes of a text-processing utility's input line. 715.It Dv USER_POSIX2_CHAR_TERM 716Return 1 if the system supports at least one terminal type capable of 717all operations described in 718.St -p1003.2 , 719otherwise 0. 720.It Dv USER_POSIX2_C_BIND 721Return 1 if the system's C-language development facilities support the 722C-Language Bindings Option, otherwise 0. 723.It Dv USER_POSIX2_C_DEV 724Return 1 if the system supports the C-Language Development Utilities Option, 725otherwise 0. 726.It Dv USER_POSIX2_FORT_DEV 727Return 1 if the system supports the FORTRAN Development Utilities Option, 728otherwise 0. 729.It Dv USER_POSIX2_FORT_RUN 730Return 1 if the system supports the FORTRAN Runtime Utilities Option, 731otherwise 0. 732.It Dv USER_POSIX2_LOCALEDEF 733Return 1 if the system supports the creation of locales, otherwise 0. 734.It Dv USER_POSIX2_SW_DEV 735Return 1 if the system supports the Software Development Utilities Option, 736otherwise 0. 737.It Dv USER_POSIX2_UPE 738Return 1 if the system supports the User Portability Utilities Option, 739otherwise 0. 740.It Dv USER_POSIX2_VERSION 741The version of 742.St -p1003.2 743with which the system attempts to comply. 744.It Dv USER_RE_DUP_MAX 745The maximum number of repeated occurrences of a regular expression 746permitted when using interval notation. 747.It Dv USER_STREAM_MAX 748The minimum maximum number of streams that a process may have open 749at any one time. 750.It Dv USER_TZNAME_MAX 751The minimum maximum number of types supported for the name of a timezone. 752.El 753.Ss CTL_VM 754The string and integer information available for the 755.Dv CTL_VM 756level is detailed below. 757The changeable column shows whether a process with appropriate 758privilege may change the value. 759.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent 760.It Sy "Second level name" Ta Sy "Type" Ta Sy "Changeable" 761.It Dv VM_LOADAVG Ta struct loadavg Ta no 762.It Dv VM_METER Ta struct vmtotal Ta no 763.It Dv VM_PAGEOUT_ALGORITHM Ta integer Ta yes 764.It Dv VM_SWAPPING_ENABLED Ta integer Ta maybe 765.It Dv VM_V_CACHE_MAX Ta integer Ta yes 766.It Dv VM_V_CACHE_MIN Ta integer Ta yes 767.It Dv VM_V_FREE_MIN Ta integer Ta yes 768.It Dv VM_V_FREE_RESERVED Ta integer Ta yes 769.It Dv VM_V_FREE_TARGET Ta integer Ta yes 770.It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes 771.It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes 772.El 773.Bl -tag -width 6n 774.It Dv VM_LOADAVG 775Return the load average history. 776The returned data consists of a 777.Va struct loadavg . 778.It Dv VM_METER 779Return the system wide virtual memory statistics. 780The returned data consists of a 781.Va struct vmtotal . 782.It Dv VM_PAGEOUT_ALGORITHM 7830 if the statistics-based page management algorithm is in use 784or 1 if the near-LRU algorithm is in use. 785.It Dv VM_SWAPPING_ENABLED 7861 if process swapping is enabled or 0 if disabled. This variable is 787permanently set to 0 if the kernel was built with swapping disabled. 788.It Dv VM_V_CACHE_MAX 789Maximum desired size of the cache queue. 790.It Dv VM_V_CACHE_MIN 791Minimum desired size of the cache queue. If the cache queue size 792falls very far below this value, the pageout daemon is awakened. 793.It Dv VM_V_FREE_MIN 794Minimum amount of memory (cache memory plus free memory) 795required to be available before a process waiting on memory will be 796awakened. 797.It Dv VM_V_FREE_RESERVED 798Processes will awaken the pageout daemon and wait for memory if the 799number of free and cached pages drops below this value. 800.It Dv VM_V_FREE_TARGET 801The total amount of free memory (including cache memory) that the 802pageout daemon tries to maintain. 803.It Dv VM_V_INACTIVE_TARGET 804The desired number of inactive pages that the pageout daemon should 805achieve when it runs. Inactive pages can be quickly inserted into 806process address space when needed. 807.It Dv VM_V_PAGEOUT_FREE_MIN 808If the amount of free and cache memory falls below this value, the 809pageout daemon will enter "memory conserving mode" to avoid deadlock. 810.El 811.Sh RETURN VALUES 812.Rv -std 813.Sh FILES 814.Bl -tag -width ".In netinet/icmp_var.h" -compact 815.It In sys/sysctl.h 816definitions for top level identifiers, second level kernel and hardware 817identifiers, and user level identifiers 818.It In sys/socket.h 819definitions for second level network identifiers 820.It In sys/gmon.h 821definitions for third level profiling identifiers 822.It In vm/vm_param.h 823definitions for second level virtual memory identifiers 824.It In netinet/in.h 825definitions for third level IPv4/IPv6 identifiers and 826fourth level IPv4/v6 identifiers 827.It In netinet/icmp_var.h 828definitions for fourth level ICMP identifiers 829.It In netinet/icmp6.h 830definitions for fourth level ICMPv6 identifiers 831.It In netinet/udp_var.h 832definitions for fourth level UDP identifiers 833.El 834.Sh ERRORS 835The following errors may be reported: 836.Bl -tag -width Er 837.It Bq Er EFAULT 838The buffer 839.Fa name , 840.Fa oldp , 841.Fa newp , 842or length pointer 843.Fa oldlenp 844contains an invalid address. 845.It Bq Er EINVAL 846The 847.Fa name 848array is less than two or greater than 849.Dv CTL_MAXNAME . 850.It Bq Er EINVAL 851A non-null 852.Fa newp 853is given and its specified length in 854.Fa newlen 855is too large or too small. 856.It Bq Er ENOMEM 857The length pointed to by 858.Fa oldlenp 859is too short to hold the requested value. 860.It Bq Er ENOTDIR 861The 862.Fa name 863array specifies an intermediate rather than terminal name. 864.It Bq Er EISDIR 865The 866.Fa name 867array specifies a terminal name, but the actual name is not terminal. 868.It Bq Er ENOENT 869The 870.Fa name 871array specifies a value that is unknown. 872.It Bq Er EPERM 873An attempt is made to set a read-only value. 874.It Bq Er EPERM 875A process without appropriate privilege attempts to set a value. 876.El 877.Sh SEE ALSO 878.Xr sysconf 3 , 879.Xr sysctl 8 880.Sh HISTORY 881The 882.Fn sysctl 883function first appeared in 884.Bx 4.4 . 885