xref: /netbsd-src/lib/libc/gen/sysctl.3 (revision dc306354b0b29af51801a7632f1e95265a68cd81)
1.\"	$NetBSD: sysctl.3,v 1.33 1998/10/06 00:20:46 matt Exp $
2.\"
3.\" Copyright (c) 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
35.\"
36.Dd May 9, 1995
37.Dt SYSCTL 3
38.Os
39.Sh NAME
40.Nm sysctl
41.Nd get or set system information
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.Fd #include <sys/param.h>
46.Fd #include <sys/sysctl.h>
47.Ft int
48.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
49.Sh DESCRIPTION
50The
51.Nm
52function retrieves system information and allows processes with
53appropriate privileges to set system information.
54The information available from
55.Nm
56consists of integers, strings, and tables.
57Information may be retrieved and set from the command interface
58using the
59.Xr sysctl 8
60utility.
61.Pp
62Unless explicitly noted below,
63.Nm
64returns a consistent snapshot of the data requested.
65Consistency is obtained by locking the destination
66buffer into memory so that the data may be copied out without blocking.
67Calls to
68.Nm
69are serialized to avoid deadlock.
70.Pp
71The state is described using a ``Management Information Base'' (MIB)
72style name, listed in
73.Fa name ,
74which is a
75.Fa namelen
76length array of integers.
77.Pp
78The information is copied into the buffer specified by
79.Fa oldp .
80The size of the buffer is given by the location specified by
81.Fa oldlenp
82before the call,
83and that location gives the amount of data copied after a successful call.
84If the amount of data available is greater
85than the size of the buffer supplied,
86the call supplies as much data as fits in the buffer provided
87and returns with the error code ENOMEM.
88If the old value is not desired,
89.Fa oldp
90and
91.Fa oldlenp
92should be set to NULL.
93.Pp
94The size of the available data can be determined by calling
95.Nm
96with a NULL parameter for
97.Fa oldp .
98The size of the available data will be returned in the location pointed to by
99.Fa oldlenp .
100For some operations, the amount of space may change often.
101For these operations,
102the system attempts to round up so that the returned size is
103large enough for a call to return the data shortly thereafter.
104.Pp
105To set a new value,
106.Fa newp
107is set to point to a buffer of length
108.Fa newlen
109from which the requested value is to be taken.
110If a new value is not to be set,
111.Fa newp
112should be set to NULL and
113.Fa newlen
114set to 0.
115.Pp
116The top level names are defined with a CTL_ prefix in
117.Pa <sys/sysctl.h> ,
118and are as follows.
119The next and subsequent levels down are found in the include files
120listed here, and described in separate sections below.
121.Pp
122.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
123.It Sy Pa Name	Next level names	Description
124.It CTL\_DEBUG	sys/sysctl.h	Debugging
125.It CTL\_VFS	sys/mount.h	Filesystem
126.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
127.It CTL\_KERN	sys/sysctl.h	High kernel limits
128.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
129.It CTL\_NET	sys/socket.h	Networking
130.It CTL\_USER	sys/sysctl.h	User-level
131.It CTL\_VM	vm/vm_param.h	Virtual memory
132.El
133.Pp
134For example, the following retrieves the maximum number of processes allowed
135in the system:
136.Bd -literal -offset indent -compact
137int mib[2], maxproc;
138size_t len;
139.sp
140mib[0] = CTL_KERN;
141mib[1] = KERN_MAXPROC;
142len = sizeof(maxproc);
143sysctl(mib, 2, &maxproc, &len, NULL, 0);
144.Ed
145.sp
146To retrieve the standard search path for the system utilities:
147.Bd -literal -offset indent -compact
148int mib[2];
149size_t len;
150char *p;
151.sp
152mib[0] = CTL_USER;
153mib[1] = USER_CS_PATH;
154sysctl(mib, 2, NULL, &len, NULL, 0);
155p = malloc(len);
156sysctl(mib, 2, p, &len, NULL, 0);
157.Ed
158.Sh CTL_DEBUG
159The debugging variables vary from system to system.
160A debugging variable may be added or deleted without need to recompile
161.Nm
162to know about it.
163Each time it runs,
164.Nm
165gets the list of debugging variables from the kernel and
166displays their current values.
167The system defines twenty
168.Ns ( Va struct ctldebug )
169variables named
170.Dv debug0
171through
172.Dv debug19 .
173They are declared as separate variables so that they can be
174individually initialized at the location of their associated variable.
175The loader prevents multiple use of the same variable by issuing errors
176if a variable is initialized in more than one place.
177For example, to export the variable
178.Dv dospecialcheck
179as a debugging variable, the following declaration would be used:
180.Bd -literal -offset indent -compact
181int dospecialcheck = 1;
182struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
183.Ed
184.Sh CTL_VFS
185A distinguished second level name, VFS_GENERIC,
186is used to get general information about all filesystems.
187One of its third level identifiers is VFS_MAXTYPENUM
188that gives the highest valid filesystem type number.
189Its other third level identifier is VFS_CONF that
190returns configuration information about the filesystem
191type given as a fourth level identifier (see
192.Xr getvfsbyname 3
193as an example of its use).
194The remaining second level identifiers are the
195filesystem type number returned by a
196.Xr statfs 2
197call or from VFS_CONF.
198The third level identifiers available for each filesystem
199are given in the header file that defines the mount
200argument structure for that filesystem.
201.Sh CTL_HW
202The string and integer information available for the CTL_HW level
203is detailed below.
204The changeable column shows whether a process with appropriate
205privilege may change the value.
206.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
207.It Sy Pa Second level name	Type	Changeable
208.It HW\_MACHINE	string	no
209.It HW\_MODEL	string	no
210.It HW\_NCPU	integer	no
211.It HW\_BYTEORDER	integer	no
212.It HW\_PHYSMEM	integer	no
213.It HW\_USERMEM	integer	no
214.It HW\_PAGESIZE	integer	no
215.It HW\_MACHINE\_ARCH	string	no
216.\".It HW\_DISKNAMES	integer	no
217.\".It HW\_DISKSTATS	integer	no
218.El
219.Pp
220.Bl -tag -width "123456"
221.It Li HW_MACHINE
222The machine class.
223.It Li HW_MODEL
224The machine model
225.It Li HW_NCPU
226The number of cpus.
227.ne 1i
228.It Li HW_BYTEORDER
229The byteorder (4,321, or 1,234).
230.It Li HW_PHYSMEM
231The bytes of physical memory.
232.It Li HW_USERMEM
233The bytes of non-kernel memory.
234.It Li HW_PAGESIZE
235The software page size.
236.It Li HW_MACHINE_ARCH
237The machine cpu class.
238.\".It Fa HW_DISKNAMES
239.\".It Fa HW_DISKSTATS
240.El
241.Sh CTL_KERN
242The string and integer information available for the CTL_KERN level
243is detailed below.
244The changeable column shows whether a process with appropriate
245privilege may change the value.
246The types of data currently available are process information,
247system vnodes, the open file entries, routing table entries,
248virtual memory statistics, load average history, and clock rate
249information.
250.Bl -column "KERNXCHOWNXRESTRICTEDXXX" "struct clockrateXXX" -offset indent
251.It Sy Pa Second level name	Type	Changeable
252.It KERN\_ARGMAX	integer	no
253.It KERN\_AUTONICETIME	integer	yes
254.It KERN\_AUTONICEVAL	integer	yes
255.It KERN\_BOOTTIME	struct timeval	no
256.It KERN\_CHOWN\_RESTRICTED	integer	no
257.It KERN\_CLOCKRATE	struct clockinfo	no
258.It KERN\_DOMAINNAME	string	yes
259.It KERN\_FILE	struct file	no
260.It KERN\_FSYNC	integer	no
261.It KERN\_HOSTID	integer	yes
262.It KERN\_HOSTNAME	string	yes
263.It KERN\_IOV\_MAX	integer	no
264.It KERN\_JOB\_CONTROL	integer	no
265.It KERN\_LINK\_MAX	integer	no
266.It KERN\_MAXFILES	integer	yes
267.It KERN\_MAXPARTITIONS	integer	no
268.It KERN\_MAXPROC	integer	yes
269.It KERN\_MAXVNODES	integer	yes
270.It KERN\_MAX\_CANON	integer	no
271.It KERN\_MAX\_INPUT	integer	no
272.It KERN\_MSGBUFSIZE	integer	no
273.It KERN\_NAME\_MAX	integer	no
274.It KERN\_NGROUPS	integer	no
275.It KERN\_NO\_TRUNC	integer	no
276.It KERN\_OSRELEASE	string	no
277.It KERN\_OSREV	integer	no
278.It KERN\_OSTYPE	string	no
279.It KERN\_PATH\_MAX	integer	no
280.It KERN\_PIPE\_BUF	integer	no
281.It KERN\_POSIX1	integer	no
282.It KERN\_PROC	struct proc	no
283.It KERN\_PROF	node	not applicable
284.It KERN\_RAWPARTITION	integer	no
285.It KERN\_SAVED\_IDS	integer	no
286.It KERN\_SECURELVL	integer	raise only
287.It KERN\_SHORTCORENAME	integer	yes
288.It KERN\_SYNCHRONIZED\_IO	integer	no
289.It KERN\_SYSVMSG	integer	no
290.It KERN\_SYSVSEM	integer	no
291.It KERN\_SYSVSHM	integer	no
292.It KERN\_VDISABLE	integer	no
293.It KERN\_VERSION	string	no
294.It KERN\_VNODE	struct vnode	no
295.El
296.ne 1i
297.Pp
298.Bl -tag -width "123456"
299.It Li KERN_ARGMAX
300The maximum bytes of argument to
301.Xr execve 2 .
302.It Li KERN_AUTONICETIME
303The number of seconds of cpu-time a non-root process may accumulate before
304having its priority lowered from the default to the value of KERN_AUTONICEVAL.
305If set to 0, automatic lowering of priority is not performed, and if set to -1
306all non-root processes are immediately lowered.
307.It Li KERN_AUTONICEVAL
308The priority assigned for automatically niced processes.
309.It Li KERN_BOOTTIME
310A
311.Va struct timeval
312structure is returned.
313This structure contains the time that the system was booted.
314.It Li KERN_CHOWN_RESTRICTED
315Return 1 if appropriate privileges are required for the
316.Xr chown 2
317system call, otherwise 0.
318.It Li KERN_CLOCKRATE
319A
320.Va struct clockinfo
321structure is returned.
322This structure contains the clock, statistics clock and profiling clock
323frequencies, the number of micro-seconds per hz tick, and the clock
324skew rate.
325.It Li KERN_DOMAINNAME
326Get or set the YP domain name.
327.It Li KERN_FILE
328Return the entire file table.
329The returned data consists of a single
330.Va struct filehead
331followed by an array of
332.Va struct file ,
333whose size depends on the current number of such objects in the system.
334.It Li KERN_FSYNC
335Return 1 if the POSIX 1003.1b File Synchronization Option is available
336on this system,
337otherwise 0.
338.It Li KERN_HOSTID
339Get or set the host id.
340.It Li KERN_HOSTNAME
341Get or set the hostname.
342.It Li KERN_IOV_MAX
343Return the maximum number of
344.Va iovec
345structures that a process has available for use with
346.Xr preadv 2 ,
347.Xr pwritev 2 ,
348.Xr readv 2 ,
349.Xr recvmsg 2 ,
350.Xr sendmsg 2
351and
352.Xr writev 2 .
353.It Li KERN_JOB_CONTROL
354Return 1 if job control is available on this system, otherwise 0.
355.It Li KERN_LINK_MAX
356The maximum file link count.
357.It Li KERN_MAXFILES
358The maximum number of open files that may be open in the system.
359.It Li KERN_MAXPARTITIONS
360The maximum number of partitions allowed per disk.
361.It Li KERN_MAXPROC
362The maximum number of simultaneous processes the system will allow.
363.It Li KERN_MAXVNODES
364The maximum number of vnodes available on the system.
365.It Li KERN_MAX_CANON
366The maximum number of bytes in terminal canonical input line.
367.It Li KERN_MAX_INPUT
368The minimum maximum number of bytes for which space is available in
369a terminal input queue.
370.It Li KERN_MSGBUFSIZE
371The maximum number of characters that the kernel message buffer can hold.
372.It Li KERN_NAME_MAX
373The maximum number of bytes in a file name.
374.It Li KERN_NGROUPS
375The maximum number of supplemental groups.
376.It Li KERN_NO_TRUNC
377Return 1 if file names longer than KERN_NAME_MAX are truncated.
378.It Li KERN_OSRELEASE
379The system release string.
380.It Li KERN_OSREV
381The system revision string.
382.It Li KERN_OSTYPE
383The system type string.
384.It Li KERN_PATH_MAX
385The maximum number of bytes in a pathname.
386.It Li KERN_PIPE_BUF
387The maximum number of bytes which will be written atomically to a pipe.
388.It Li KERN_POSIX1
389The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
390attempts to comply.
391.It Li KERN_PROC
392Return the entire process table, or a subset of it.
393An array of
394.Va struct kinfo_proc
395structures is returned,
396whose size depends on the current number of such objects in the system.
397The third and fourth level names are as follows:
398.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
399.It Pa Third level name	Fourth level is:
400.It KERN\_PROC\_ALL	None
401.It KERN\_PROC\_PID	A process ID
402.It KERN\_PROC\_PGRP	A process group
403.It KERN\_PROC\_TTY	A tty device
404.It KERN\_PROC\_UID	A user ID
405.It KERN\_PROC\_RUID	A real user ID
406.El
407.It Li KERN_PROF
408Return profiling information about the kernel.
409If the kernel is not compiled for profiling,
410attempts to retrieve any of the KERN_PROF values will
411fail with EOPNOTSUPP.
412The third level names for the string and integer profiling information
413is detailed below.
414The changeable column shows whether a process with appropriate
415privilege may change the value.
416.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
417.It Sy Pa Third level name	Type	Changeable
418.It GPROF\_STATE	integer	yes
419.It GPROF\_COUNT	u_short[\|]	yes
420.It GPROF\_FROMS	u_short[\|]	yes
421.It GPROF\_TOS	struct tostruct	yes
422.It GPROF\_GMONPARAM	struct gmonparam	no
423.El
424.Pp
425The variables are as follows:
426.Bl -tag -width "123456"
427.It Li GPROF_STATE
428Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
429is running or stopped.
430.It Li GPROF_COUNT
431Array of statistical program counter counts.
432.It Li GPROF_FROMS
433Array indexed by program counter of call-from points.
434.It Li GPROF_TOS
435Array of
436.Va struct tostruct
437describing destination of calls and their counts.
438.It Li GPROF_GMONPARAM
439Structure giving the sizes of the above arrays.
440.El
441.It Li KERN_RAWPARTITION
442The raw partition of a disk (a == 0).
443.It Li KERN_SAVED_IDS
444Returns 1 if saved set-group and saved set-user ID is available.
445.It Li KERN_SECURELVL
446The system security level.
447This level may be raised by processes with appropriate privilege.
448It may only be lowered by process 1.
449.It Li KERN_SHORTCORENAME
450Whether core dumps are named
451.Nm programname.core
452(default, value 0) or
453.Nm core
454(value 1).
455The default value can be changed to 1 with the kernel configuration option
456.Cd options SHORTCORENAME
457(see
458.Xr options 4 ,
459.Xr core 5 ).
460.It Li KERN_SYNCHRONIZED_IO
461Returns 1 if the POSIX 1003.1b Synchronized I/O Option is available
462on this system,
463otherwise 0.
464.It Li KERN_SYSVMSG
465Returns 1 if System V style message queue functionality is available
466on this system,
467otherwise 0.
468.It Li KERN_SYSVSEM
469Returns 1 if System V style semaphore functionality is available
470on this system,
471otherwise 0.
472.It Li KERN_SYSVSHM
473Returns 1 if System V style share memory functionality is available
474on this system,
475otherwise 0.
476.It Li KERN_VDISABLE
477Returns the terminal character disabling value.
478.It Li KERN_VERSION
479The system version string.
480.It Li KERN_VNODE
481Return the entire vnode table.
482Note, the vnode table is not necessarily a consistent snapshot of
483the system.
484The returned data consists of an array whose size depends on the
485current number of such objects in the system.
486Each element of the array contains the kernel address of a vnode
487.Va struct vnode *
488followed by the vnode itself
489.Va struct vnode .
490.El
491.Sh CTL_MACHDEP
492The set of variables defined is architecture dependent.
493Most architectures define at least the following variables.
494.Bl -column "CONSOLE_DEVICEXXX" "integerXXX" -offset indent
495.It Sy Pa Second level name	Type	Changeable
496.It Li CPU_CONSDEV	dev_t	no
497.El
498.Sh CTL_NET
499The string and integer information available for the CTL_NET level
500is detailed below.
501The changeable column shows whether a process with appropriate
502privilege may change the value.
503.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
504.It Sy Pa Second level name	Type	Changeable
505.It PF\_ROUTE	routing messages	no
506.It PF\_INET	internet values	yes
507.El
508.Pp
509.Bl -tag -width "123456"
510.It Li PF_ROUTE
511Return the entire routing table or a subset of it.
512The data is returned as a sequence of routing messages (see
513.Xr route 4
514for the header file, format and meaning).
515The length of each message is contained in the message header.
516.Pp
517The third level name is a protocol number, which is currently always 0.
518The fourth level name is an address family, which may be set to 0 to
519select all address families.
520The fifth and sixth level names are as follows:
521.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
522.It Pa Fifth level name	Sixth level is:
523.It NET\_RT\_FLAGS	rtflags
524.It NET\_RT\_DUMP	None
525.It NET\_RT\_IFLIST	None
526.El
527.It Li PF_INET
528Get or set various global information about the internet protocols.
529The third level name is the protocol.
530The fourth level name is the variable name.
531The currently defined protocols and names are:
532.Bl -column "Protocol name" "Variable nameXX" "integer" "yes" -offset indent
533.It Pa Protocol name	Variable name	Type	Changeable
534.It ip	forwarding	integer	yes
535.It ip	redirect	integer	yes
536.It ip	ttl	integer	yes
537.It ip	forwsrcrt	integer	yes
538.It ip	directed-broadcast	integer	yes
539.It ip	allowsrcrt	integer	yes
540.It ip	subnetsarelocal	integer	yes
541.It ip	mtudisc	integer	yes
542.It ip	anonportmin	integer	yes
543.It ip	anonportmax	integer	yes
544.It ip	mtudisctimeout	integer	yes
545.It icmp	maskrepl	integer	yes
546.It tcp	rfc1323	integer	yes
547.It tcp	sendspace	integer	yes
548.It tcp	recvspace	integer	yes
549.It tcp	mssdflt	integer	yes
550.It tcp	syn_cache_limit	integer	yes
551.It tcp	syn_bucket_limit	integer	yes
552.It tcp	syn_cache_interval	integer	yes
553.It tcp	init_win	integer	yes
554.It tcp	mss_ifmtu	integer	yes
555.It tcp	sack	integer	yes
556.It tcp	win_scale	integer	yes
557.It tcp	timestamps	integer	yes
558.It tcp	compat_42	integer	yes
559.It tcp	cwm	integer	yes
560.It tcp	cwm_burstsize	integer	yes
561.It tcp	ack_on_push	integer	yes
562.It tcp	keepidle	integer	yes
563.It tcp	keepintvl	integer	yes
564.It tcp keepcnt	integer	yes
565.It tcp	slowhz	integer	no
566.It tcp	newreno	integer	yes
567.It udp	checksum	integer	yes
568.It udp	sendspace	integer	yes
569.It udp	recvspace	integer	yes
570.El
571.Pp
572The variables are as follows:
573.Bl -tag -width "123456"
574.It Li ip.forwarding
575Returns 1 when IP forwarding is enabled for the host,
576meaning that the host is acting as a router.
577.It Li ip.redirect
578Returns 1 when ICMP redirects may be sent by the host.
579This option is ignored unless the host is routing IP packets,
580and should normally be enabled on all systems.
581.It Li ip.ttl
582The maximum time-to-live (hop count) value for an IP packet sourced by
583the system.
584This value applies to normal transport protocols, not to ICMP.
585.It Li ip.forwsrcrt
586Returns 1 when forwarding of source-routed packets is enabled for
587the host.  This value may only be changed if the kernel security
588level is less than 1.
589.It Li ip.directed-broadcast
590Returns 1 if directed broadcast behavior is enabled for the host.
591.It Li ip.allowsrcrt
592Returns 1 if the host accepts source routed packets.
593.It Li ip.subnetsarelocal
594Returns 1 if subnets are to be considered local addresses.
595.It Li ip.mtudisc
596Returns 1 if Path MTU Discovery is enabled.
597.It Li ip.anonportmin
598The lowest port number to use for TCP and UDP ephemeral port allocation.
599This cannot be set to less that 1024 or greater than 65535.
600.It Li ip.anonportmax
601The highest port number to use for TCP and UDP ephemeral port allocation.
602This cannot be set to less that 1024 or greater than 65535, and must
603be greater than
604.Li ip.anonportmin .
605.It Li ip.mtudisctimeout
606Returns the number of seconds in which a route added by the Path MTU
607Discovery engine will time out.  When the route times out, the Path
608MTU Discovery engine will attempt to probe a larger path MTU.
609.It Li icmp.maskrepl
610Returns 1 if ICMP network mask requests are to be answered.
611.It Li tcp.rfc1323
612Returns 1 if RFC1323 extensions to TCP are enabled.
613.It Li tcp.sendspace
614Returns the default TCP send buffer size.
615.It Li tcp.recvspace
616Returns the default TCP receive buffer size.
617.It Li tcp.mssdflt
618Returns the default maximum segment size both advertsized to the peer
619and to use when the peer does not advertize a maximum segment size to
620us during connection setup.  Do not change this value unless you really
621know what you are doing.
622.It Li tcp.syn_cache_limit
623Returns the maximum number of entries allowed in the TCP compressed state
624engine.
625.It Li tcp.syn_bucket_limit
626Returns the maximum number of entries allowed per hash bucket in the TCP
627compressed state engine.
628.It Li tcp.syn_cache_interval
629Returns the TCP compressed state engine's timer interval.
630.It Li tcp.init_win
631Returns a value indicating the TCP initial congestion window.  If this
632value is 0, an auto-tuning algorithm designed to use an initial window
633of approximately 4K bytes is in use.  Otherwise, this value indicates
634a fixed number of packets.
635.It Li tcp.mss_ifmtu
636Returns 1 if TCP calculates the outgoing maximum segment size based on
637the MTU of the appropriate interface.  Otherwise, it is calculated based on
638the greater of the MTU of the interface, and the largest (non-loopback)
639interface MTU on the system.
640.It Li tcp.sack
641Returns a value which determines the level of Selective Acknowledgement
642supported by TCP.  If 2, we will transmit and receive SACK options.
643If 1, we will transmit SACK options, but ignore any SACK options received.
644If 0, SACK is disabled.
645.It Li tcp.win_scale
646If rfc1323 is enabled, a value of 1 indicates RFC1323 window scale options,
647for increasing the TCP window size, are enabled.
648.It Li tcp.timestamps
649If rfc1323 is enabled, a value of 1 indicates RFC1323 time stamp options,
650used for measuring TCP round trip times, are enabled.
651.It Li tcp.compat_42
652Returns 1 if work-arounds for bugs in the 4.2BSD TCP implementation are
653enabled.  Use of this option is not recommended, although it may be
654required in order to communicate with extremely old TCP implementations.
655.It Li tcp.cwm
656Returns 1 if use of the Hughes/Touch/Heidemann Congestion Window Monitoring
657algorithm is enabled.  This algorithm prevents line-rate bursts of packets
658that could otherwise occur when data begins flowing on an idle TCP
659connection.  These line-rate bursts can contribute to network and router
660congestion.  This can be particularly useful on World Wide Web servers
661which support HTTP/1.1, which has lingering connections.
662.It Li tcp.cwm_burstsize
663Returns the Congestion Window Monitoring allowed burst size, in terms
664of packet count.
665.It Li tcp.ack_on_push
666Returns 1 if TCP is to immediately transmit an ACK upon reception of
667a packet with PUSH set.  This can avoid losing a round trip time in some
668rare situations, but has the caveat of potentially defeating TCP's delayed
669ACK algorithm.  Use of this option is generally not recommended, but
670the variable exists in case your configuration really needs it.
671.It Li tcp.keepidle
672Time a connection must be idle before keepalives are sent (if keepalives
673are enabled for the connection).  See also tcp.slowhz.
674.It Li tcp.keepintvl
675Time after a keepalive probe is sent until, in the absence of any response,
676another probe is sent.  See also tcp.slowhz.
677.It Li tcp.keepcnt
678Number of keepalive probes sent before declaring a connection dead.  If
679set to zero, there is no limit; keepalives will be sent until some kind of
680response is received from the peer.
681.It Li tcp.slowhz
682The units for tcp.keepidle and tcp.keepintvl; those variables are in ticks
683of a clock that ticks tcp.slowhz times per second.  (That is, their values
684must be divided by the tcp.slowhz value to get times in seconds.)
685.It Li tcp.newreno
686Returns 1 if the use of J. Hoe's NewReno congestion control algorithm is
687enabled.  This algorithm improves the start-up behavior of TCP connections.
688.It Li udp.checksum
689Returns 1 when UDP checksums are being computed and checked.
690Disabling UDP checksums is strongly discouraged.
691.It Li udp.sendspace
692Returns the default UDP send buffer size.
693.It Li udp.recvspace
694Returns the default UDP receive buffer size.
695.El
696.Sh CTL_USER
697The string and integer information available for the CTL_USER level
698is detailed below.
699The changeable column shows whether a process with appropriate
700privilege may change the value.
701.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
702.It Sy Pa Second level name	Type	Changeable
703.It USER\_BC\_BASE\_MAX	integer	no
704.It USER\_BC\_DIM\_MAX	integer	no
705.It USER\_BC\_SCALE\_MAX	integer	no
706.It USER\_BC\_STRING\_MAX	integer	no
707.It USER\_COLL\_WEIGHTS\_MAX	integer	no
708.It USER\_CS\_PATH	string	no
709.It USER\_EXPR\_NEST\_MAX	integer	no
710.It USER\_LINE\_MAX	integer	no
711.It USER\_POSIX2\_CHAR\_TERM	integer	no
712.It USER\_POSIX2\_C\_BIND	integer	no
713.It USER\_POSIX2\_C\_DEV	integer	no
714.It USER\_POSIX2\_FORT\_DEV	integer	no
715.It USER\_POSIX2\_FORT\_RUN	integer	no
716.It USER\_POSIX2\_LOCALEDEF	integer	no
717.It USER\_POSIX2\_SW\_DEV	integer	no
718.It USER\_POSIX2\_UPE	integer	no
719.It USER\_POSIX2\_VERSION	integer	no
720.It USER\_RE\_DUP\_MAX	integer	no
721.It USER\_STREAM\_MAX	integer	no
722.It USER\_TZNAME\_MAX	integer	no
723.El
724.Bl -tag -width "123456"
725.Pp
726.It Li USER_BC_BASE_MAX
727The maximum ibase/obase values in the
728.Xr bc 1
729utility.
730.It Li USER_BC_DIM_MAX
731The maximum array size in the
732.Xr bc 1
733utility.
734.It Li USER_BC_SCALE_MAX
735The maximum scale value in the
736.Xr bc 1
737utility.
738.It Li USER_BC_STRING_MAX
739The maximum string length in the
740.Xr bc 1
741utility.
742.It Li USER_COLL_WEIGHTS_MAX
743The maximum number of weights that can be assigned to any entry of
744the LC_COLLATE order keyword in the locale definition file.
745.It Li USER_CS_PATH
746Return a value for the
747.Ev PATH
748environment variable that finds all the standard utilities.
749.It Li USER_EXPR_NEST_MAX
750The maximum number of expressions that can be nested within
751parenthesis by the
752.Xr expr 1
753utility.
754.It Li USER_LINE_MAX
755The maximum length in bytes of a text-processing utility's input
756line.
757.It Li USER_POSIX2_CHAR_TERM
758Return 1 if the system supports at least one terminal type capable of
759all operations described in POSIX 1003.2, otherwise 0.
760.It Li USER_POSIX2_C_BIND
761Return 1 if the system's C-language development facilities support the
762C-Language Bindings Option, otherwise 0.
763.It Li USER_POSIX2_C_DEV
764Return 1 if the system supports the C-Language Development Utilities Option,
765otherwise 0.
766.It Li USER_POSIX2_FORT_DEV
767Return 1 if the system supports the FORTRAN Development Utilities Option,
768otherwise 0.
769.It Li USER_POSIX2_FORT_RUN
770Return 1 if the system supports the FORTRAN Runtime Utilities Option,
771otherwise 0.
772.It Li USER_POSIX2_LOCALEDEF
773Return 1 if the system supports the creation of locales, otherwise 0.
774.It Li USER_POSIX2_SW_DEV
775Return 1 if the system supports the Software Development Utilities Option,
776otherwise 0.
777.It Li USER_POSIX2_UPE
778Return 1 if the system supports the User Portability Utilities Option,
779otherwise 0.
780.It Li USER_POSIX2_VERSION
781The version of POSIX 1003.2 with which the system attempts to comply.
782.It Li USER_RE_DUP_MAX
783The maximum number of repeated occurrences of a regular expression
784permitted when using interval notation.
785.ne 1i
786.It Li USER_STREAM_MAX
787The minimum maximum number of streams that a process may have open
788at any one time.
789.It Li USER_TZNAME_MAX
790The minimum maximum number of types supported for the name of a
791timezone.
792.El
793.Sh CTL_VM
794The string and integer information available for the CTL_VM level
795is detailed below.
796The changeable column shows whether a process with appropriate
797privilege may change the value.
798.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
799.It Sy Pa Second level name	Type	Changeable
800.It VM\_LOADAVG	struct loadavg	no
801.It VM\_METER	struct vmtotal	no
802.El
803.Pp
804.Bl -tag -width "123456"
805.It Li VM_LOADAVG
806Return the load average history.
807The returned data consists of a
808.Va struct loadavg .
809.It Li VM_METER
810Return the system wide virtual memory statistics.
811The returned data consists of a
812.Va struct vmtotal .
813.El
814.Sh CTL_DDB
815The integer information available for the CTL_DDB level is detailed below.
816The changeable column shows whether a process with appropriate
817privilege may change the value.
818.Bl -column "DBCTL_TABSTOPSXXX" "integerXXX" -offset indent
819.It Sy Pa Second level name	Type	Changeable
820.It DBCTL\_RADIX	integer	yes
821.It DBCTL\_MAXOFF	integer	yes
822.It DBCTL\_LINES	integer	yes
823.It DBCTL\_TABSTOPS	integer	yes
824.It DBCTL\_ONPANIC	integer	yes
825.El
826.Pp
827.Bl -tag -width "123456"
828.It Li DBCTL_RADIX
829The input and output radix.
830.It Li DBCTL_MAXOFF
831The maximum symbol offset.
832.It Li DBCTL_LINES
833Number of display lines.
834.It Li DBCTL_TABSTOPS
835Tab width.
836.It Li DBCTL_ONPANIC
837If non-zero, DDB will be entered when the kernel panics.
838.El
839.Pp
840These MIB nodes are also available as variables from within the
841DDB.  See
842.Xr ddb 4
843for more details.
844.Sh RETURN VALUES
845If the call to
846.Nm
847is successful, the number of bytes copied out is returned.
848Otherwise \-1 is returned and
849.Va errno
850is set appropriately.
851.Sh ERRORS
852The following errors may be reported:
853.Bl -tag -width Er
854.It Bq Er EFAULT
855The buffer
856.Fa name ,
857.Fa oldp ,
858.Fa newp ,
859or length pointer
860.Fa oldlenp
861contains an invalid address.
862.It Bq Er EINVAL
863The
864.Fa name
865array is less than two or greater than CTL_MAXNAME.
866.It Bq Er EINVAL
867A non-null
868.Fa newp
869is given and its specified length in
870.Fa newlen
871is too large or too small.
872.It Bq Er ENOMEM
873The length pointed to by
874.Fa oldlenp
875is too short to hold the requested value.
876.It Bq Er ENOTDIR
877The
878.Fa name
879array specifies an intermediate rather than terminal name.
880.It Bq Er EOPNOTSUPP
881The
882.Fa name
883array specifies a value that is unknown.
884.It Bq Er EPERM
885An attempt is made to set a read-only value.
886.It Bq Er EPERM
887A process without appropriate privilege attempts to set a value.
888.It Bq Er EPERM
889An attempt to change a value protected by the current kernel security
890level is made.
891.El
892.Sh FILES
893.Bl -tag -width <netinet/icmpXvar.h> -compact
894.It Pa <sys/sysctl.h>
895definitions for top level identifiers, second level kernel and hardware
896identifiers, and user level identifiers
897.It Pa <sys/socket.h>
898definitions for second level network identifiers
899.It Pa <sys/gmon.h>
900definitions for third level profiling identifiers
901.It Pa <vm/vm_param.h>
902definitions for second level virtual memory identifiers
903.It Pa <netinet/in.h>
904definitions for third level Internet identifiers and
905fourth level IP identifiers
906.It Pa <netinet/icmp_var.h>
907definitions for fourth level ICMP identifiers
908.It Pa <netinet/tcp_var.h>
909definitions for fourth level TCP identifiers
910.It Pa <netinet/udp_var.h>
911definitions for fourth level UDP identifiers
912.El
913.Sh SEE ALSO
914.Xr sysctl 8
915.Sh HISTORY
916The
917.Nm
918function first appeared in
919.Bx 4.4 .
920