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