History log of /openbsd-current/sbin/sysctl/sysctl.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.261 09-May-2024 florian

ctime(3) and ctime_r(3) can fail when timestamps are way off.
Add missing error checks to all calls under sbin/

Input kettenis, millert
OK millert


Revision tags: OPENBSD_7_5_BASE
# 1.260 11-Feb-2024 bluhm

Remove needless includes of netinet6/ip6_var.h header in userland.

OK millert@


Revision tags: OPENBSD_7_4_BASE
# 1.259 17-May-2023 kettenis

Implement battery management sysctl. This will provide a set of sysctls
to control the charging of laptop batteries:

* hw.battery.chargemode (int)

-1: force discharge
0: inhibit charge
1: auto

In auto mode charging may be controlled by:

* hw.battery.chargestop (int)

Percentage (0-100) of last full capacity at which the battery should
stop charging.

* hw.battery.chargestart (int)

Percentage (0-100) of last full capacity at which the battery should
start charging.

The idea is that with

hw.battery.chargemode=1
hw.battery.chargestop=80
hw.battery.chargestart=75

the battery would be kept charged within the range between 75% and 80%.

Allowable settings and some details of the behavior may differ between
hardware implementations.

Committing this early to easy testing of further diffs that implement this
functionality in acpithinkpad(4) and aplsmc(4).

ok kn@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.258 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.257 18-May-2021 claudio

Add support for the new net.unix sysctl nodes.
OK mvs@


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.260 11-Feb-2024 bluhm

Remove needless includes of netinet6/ip6_var.h header in userland.

OK millert@


Revision tags: OPENBSD_7_4_BASE
# 1.259 17-May-2023 kettenis

Implement battery management sysctl. This will provide a set of sysctls
to control the charging of laptop batteries:

* hw.battery.chargemode (int)

-1: force discharge
0: inhibit charge
1: auto

In auto mode charging may be controlled by:

* hw.battery.chargestop (int)

Percentage (0-100) of last full capacity at which the battery should
stop charging.

* hw.battery.chargestart (int)

Percentage (0-100) of last full capacity at which the battery should
start charging.

The idea is that with

hw.battery.chargemode=1
hw.battery.chargestop=80
hw.battery.chargestart=75

the battery would be kept charged within the range between 75% and 80%.

Allowable settings and some details of the behavior may differ between
hardware implementations.

Committing this early to easy testing of further diffs that implement this
functionality in acpithinkpad(4) and aplsmc(4).

ok kn@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.258 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.257 18-May-2021 claudio

Add support for the new net.unix sysctl nodes.
OK mvs@


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.259 17-May-2023 kettenis

Implement battery management sysctl. This will provide a set of sysctls
to control the charging of laptop batteries:

* hw.battery.chargemode (int)

-1: force discharge
0: inhibit charge
1: auto

In auto mode charging may be controlled by:

* hw.battery.chargestop (int)

Percentage (0-100) of last full capacity at which the battery should
stop charging.

* hw.battery.chargestart (int)

Percentage (0-100) of last full capacity at which the battery should
start charging.

The idea is that with

hw.battery.chargemode=1
hw.battery.chargestop=80
hw.battery.chargestart=75

the battery would be kept charged within the range between 75% and 80%.

Allowable settings and some details of the behavior may differ between
hardware implementations.

Committing this early to easy testing of further diffs that implement this
functionality in acpithinkpad(4) and aplsmc(4).

ok kn@


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.258 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.257 18-May-2021 claudio

Add support for the new net.unix sysctl nodes.
OK mvs@


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.258 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.257 18-May-2021 claudio

Add support for the new net.unix sysctl nodes.
OK mvs@


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.257 18-May-2021 claudio

Add support for the new net.unix sysctl nodes.
OK mvs@


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.256 11-May-2021 dv

Cast printf args to remove compiler warnings.

From Ashton Fagg. OK tb@.


Revision tags: OPENBSD_6_9_BASE
# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.255 13-Jan-2021 cheloha

kernel, sysctl(8): remove dead variable: tickadj

The global "tickadj" variable is a remnant of the old NTP adjustment
code we used in the kernel before the current timecounter subsystem
was imported from FreeBSD circa 2004 or 2005.

Fifteen years hence it is completely vestigial and we can remove it.
We probably should have removed it long ago but I guess it slipped
through the cracks. FreeBSD removed it in 2002:

https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d

NetBSD and DragonflyBSD can probably remove it, too.

We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2
and sysctl(8) accordingly. Hypothetically this change could break
someone's sysctl(8) parsing script. I don't think that's very likely.

ok mvs@


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.254 28-Dec-2020 mglocker

Add support for kern.video.record.

ok mpi@


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.253 17-Nov-2020 mglocker

Fix comment sysctl(3) -> sysctl(2).


Revision tags: OPENBSD_6_8_BASE
# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.252 15-Jul-2020 kettenis

POWE9 CPUs provide an energy sensor that accumulates the emount of energy
used by the processor chip. Although we have a SENSOR_WATTHOUR sensor
type its units are not really suitable for this sensor. So add a
SENSOR_ENERGY type that uses micro Joules as its unit.

ok deraadt@


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.251 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.250 25-Dec-2019 cheloha

timeout(9): new flag: TIMEOUT_SCHEDULED, new statistic: tos_scheduled

This flag is set whenever a timeout is put on the wheel and cleared upon
(a) running, (b) deletion, and (c) readdition. It serves two purposes:

1. Facilitate distinguishing scheduled and rescheduled timeouts. When a
timeout is put on the wheel it is "scheduled" for a later softclock().
If this happens two or more times it is also said to be "rescheduled".
The tos_rescheduled value thus indicates how many distant timeouts
have been cascaded into a lower wheel level.

2. Eliminate false late timeouts. A timeout is not late if it is due
before softclock() has had a chance to schedule it. To track this we
need additional state, hence a new flag.

rprocter@ raises some interesting questions. Some answers:

- This interface is not stable and name changes are possible at a
later date.

- Although rescheduling timeouts is a side effect of the underlying
implementation, I don't forsee us using anything but a timeout wheel
in the future. Other data structures are too slow in practice, so
I doubt that the concept of a rescheduled timeout will be irrelevant
any time soon.

- I think the development utility of gathering these sorts of statistics
is high. Watching the distribution of timeouts under a given workflow
is informative.

ok visa@


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.249 28-Nov-2019 guenther

ks_mapblocks is gone


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.248 29-Oct-2019 dlg

mobileip is going to the attic


Revision tags: OPENBSD_6_6_BASE
# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.247 22-Sep-2019 krw

Let sysctl(1) work in single-user mode. Same diff applied by florian@
to ps(1).

Noted by kettenis@. florian@'s fix pointed out by maestre@.

ok maestre@


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.246 12-Jul-2019 cheloha

sysctl(2): add KERN_TIMEOUT_STATS: timeout(9) status and statistics.

With these totals one can track the throughput of the timeout(9) layer
from userspace.

With input from mpi@.

ok mpi@


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.245 03-Jul-2019 dlg

wire up net.link.ifrxq.pressure_return and pressure_drop

ok visa@ deraadt@


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.244 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.243 16-Jun-2019 mestre

Restrict filesystem access to read only _PATH_DEVDB and /dev through unveil(2),
discussed by many.
Additionally call ctime(3) before unveil(2) in order to avoid potential $TZ
expansion and therefore avoiding opening more files that would need to be read,
idea from deraadt@.
While here sort the headers alphabetically.

OK florian@ deraadt@


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.242 13-May-2019 claudio

KERN_PFSTATUS is not handled by sysctl so warn about it if requested but
ignore if sysctl -a is used.
OK bluhm@


Revision tags: OPENBSD_6_5_BASE
# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.241 21-Feb-2019 bluhm

If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2)
fails, do not continue using uninitialized memory. Catch the error,
print a warning, and skip the sensors.
OK benno@ visa@ deraadt@


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.240 29-Jan-2019 visa

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.239 10-Dec-2018 landry

Add a velocity sensor type (displayed as m/s)

Change distance sensor type to be displayed as meters with 3 decimals
instead of millimeters.

ok mpi@ kettenis@


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.238 06-Nov-2018 otto

vm.malloc_conf, userland sysctl parts; ok millert@ deraadt@


Revision tags: OPENBSD_6_4_BASE
# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.237 29-Sep-2018 visa

Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.

OK deraadt@


# 1.236 22-Sep-2018 visa

Revert previous. It broke /etc/rc.

Prompted by kn@


# 1.235 21-Sep-2018 visa

Stop displaying vfsconf reference counts so that the vfc_refcount field
can be removed from struct mount.

As a result of this diff, arrays vfsname[] and vfsvars[] are indexed
by filesystem typenum. This makes the vfs_typenums[] array redundant.

OK bluhm@ mpi@


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.234 24-Aug-2018 jsg

display CPU_CPUID / machdep.cpuid in hex not decimal


# 1.233 16-Jul-2018 jasper

use ANSI C function declaration; no binary change


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.232 26-May-2018 ratchov

In addition to "on" and "off", allow the audio "record.enable" mixer
knob to take the new "sysctl" value, which is the default. In this
case, the device behavior is determined by the new "kern.audio.record"
sysctl(2), which defaults to zero.

ok florian


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_3_BASE
# 1.231 06-Mar-2018 tim

Fix a small mistake from r1.229 causing sysctl(8) to print "newval -> newval"
instead of "oldval -> newval" when changing a string variable.

OK florian@


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.230 16-Feb-2018 jmc

simplify synopsis and text;
ok millert


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.229 10-Feb-2018 florian

add support for binary sysctl payloads by handling them as hex
strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material (for RFC 7217), but it seems to be the most straightforward
path toward integrating soiikey handling and rc.

Originally written by dlg, who commited it some time ago on my request.
I then backed it out again, now it's time to put it back in.

ok florian@ sthen@ naddy@ tb@

Man page bits tweaked & OK jmc


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.228 19-Jul-2017 florian

revert previous; the code this was supposed to be used for is moving
in the wrong direction.


# 1.227 17-Jul-2017 dlg

add support for binary sysctl payloads by handling them as hex strings.

this was part of a demo showing how to implement the kernel side of
sysctl(3) for setting Semantically Opaque Interface Identifier key
material, but it seems to be the most straightforward path toward
integrating soiikey handling and rc.

ok florian@ sthen@ naddy@ tb@


# 1.226 25-Apr-2017 tb

Use strtonum instead of strto{,u}ll for simpler and better overflow
checking, make somaxconn and sominconn unsigned.

Issue reported by orge on freenode, thanks!
Input, patient explanations and ok deraadt, millert.


Revision tags: OPENBSD_6_1_BASE
# 1.225 16-Mar-2017 mpi

Fix a regression preventing ``kern.profiling'' to return the profiling
state even with a correct kernel.

Reported by jmc@, ok tb@


# 1.224 22-Dec-2016 rzalamena

Remove PIM support from the multicast stack.

ok mpi@


# 1.223 18-Oct-2016 otto

Rewrite the kern.malloc.kmemstat in the same style as previous. This one does
not overflow because the initial count includes empty slots; ok tb@


# 1.222 09-Oct-2016 otto

fix heap overflow by rewriting loop; detected by new malloc canaries
ok krw@ beck@


# 1.221 21-Sep-2016 deraadt

sysctl KERN_ARND is no longer used (in ports, it only occurs in fallback
paths of libevent). This interface was the first generation of what
eventually became getentropy(2) and arc4random(3) -- june 1997!
Ports scan by sthen, general agreement guenther


# 1.220 02-Sep-2016 deraadt

for reporting changes, hex and decimal were swapped
noticed by pirofti


# 1.219 01-Sep-2016 deraadt

Export machdep.cpufeature in hex, to avoid - values which made
yuo@ grumpy.
ok tom guenther yuo


# 1.218 27-Aug-2016 guenther

Pull in <sys/time.h> for struct timespec

ok deraadt@


# 1.217 14-Aug-2016 guenther

Use int64_t and %ll for CTLTYPE_QUAD nodes.
Use memcpy() instead of up-casting from char* to long long*

ok krw@


# 1.216 27-Jul-2016 tedu

increase the size of forkstat fields to accomodate large values


Revision tags: OPENBSD_6_0_BASE
# 1.215 18-Jun-2016 vgross

Add net.inet.{tcp,udp}.rootonly sysctl, to mark which ports
cannot be bound to by non-root users.

Ok millert@ bluhm@


# 1.214 23-May-2016 deraadt

remove the sysctl kern.random counters, since none of the remaining
ones are capable of giving valuable works vs does-not-work evidence.
ok tedu


# 1.213 04-May-2016 jca

Kill #ifdef INET6 occurrences in userland.

Prompted by and ok millert@

(tcpdump and libpcap left untouched, the #ifdef force is too strong with
those)


# 1.212 29-Feb-2016 naddy

delete the kern.emul/KERN_EMUL sysctl bits since there are no
emulations left; ok millert@ deraadt@, jmc@ (man pages)


Revision tags: OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.211 18-Apr-2015 deraadt

Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert


Revision tags: OPENBSD_5_7_BASE
# 1.210 13-Feb-2015 guenther

Direct people to netstat for the new multicast routing sysctls.

problem noted by dcoppa@
ok claudio@


# 1.209 09-Feb-2015 dlg

provide a net.inet6.ip6.ifq sysctl so people can see and fiddle
with the ip6intrq.

ok claudio@


# 1.208 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.207 19-Nov-2014 tedu

delete the KERN_VNODE sysctl. it fails to provide any isolation from the
kernel struct vnode defintion, and the only consumer (pstat) still needs
kvm to read much of the required information. no great loss to always use
kvm until there's a better replacement interface.
ok deraadt millert uebayasi


# 1.206 26-Oct-2014 brad

Add a format specifier for the printf.

ok guenther@


# 1.205 25-Oct-2014 lteo

Remove unnecessary netinet/in_systm.h include.

ok millert@


# 1.204 15-Sep-2014 miod

Remove non-standard <sys/dkstat.h> header. It has not contained anything
related to disk stastics for almost 17 years, and the remaining
userland-visible defines duplicate those found in <sys/sched.h>.

Move the remaining _KERNEL defines to <sys/tty.h> where they belong, and
update all users to cope with this.

ok kettenis@


# 1.203 16-Aug-2014 deraadt

repair operation of kern.arandom, which will only allow a buffer of
512 bytes. As a result, it stopped working...
ok miod


Revision tags: OPENBSD_5_6_BASE
# 1.202 07-May-2014 tedu

missing word in error message. ok millert


# 1.201 07-May-2014 tedu

delete some crusty casts


# 1.200 08-Apr-2014 mpi

Use VM_UVMEXP instead of VM_METER for memory usages and directly
include <sys/vmmeter.h> where it is needed instead of relying on
it being included by <uvm/uvm_extern.h>.

miod@ likes it, ok guenther@


Revision tags: OPENBSD_5_5_BASE
# 1.199 23-Jan-2014 guenther

kern.intrcnt is viewable with vmstat+systat


# 1.198 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.197 15-Nov-2013 millert

Include unistd.h as it is the standard location for getopt().


# 1.196 12-Nov-2013 deraadt

satisfy proto requirement


# 1.195 22-Oct-2013 guenther

- add UNIX-domain socket info to struct kinfo_file2
- convert netstat from kvm_getfiles() to kvm_getfile2() using that
- delete kvm_getfiles() and KERN_FILE as no longer used (bump libkvm's major)
- rename kvm_getfile2() to kvm_getfiles(), kinfo_file2 to kinfo_file
and KERN_FILE2 to KERN_FILE.

ok deraadt@, millert@
ports scan sthen@


Revision tags: OPENBSD_5_4_BASE
# 1.194 18-Jul-2013 guenther

Revert 1.191 and 1.193 and fix the original problem (access to the last
filesystem, currently ext2fs) by increasing maxtypenum sufficiently.

suggested by Rafael Neves (rafaelneves (at) gmail.com)


# 1.193 18-Jul-2013 guenther

Correct off-by-one in naming of nodes below vfs.mounts.

problem noted by Rafael Neves (rafaelneves (at) gmail.com)
ok jca@


# 1.192 09-Jun-2013 tedu

add fuse sysctls, from Sylvestre Gallon


# 1.191 09-Jun-2013 tedu

fix an off by one preventing access to the last filesystem.
from Sylvestre Gallon


# 1.190 08-Jun-2013 yasuoka

Add new sysctl for pipex packet input/output queue length and
counters.

ok guenther, feedback jmc


# 1.189 16-Apr-2013 deraadt

handle big time_t types; ok guenther


# 1.188 15-Apr-2013 guenther

Remove CTL_USER hierarchy from sysctl()
(Use sysconf() or confstr() instead)

ok miod@ millert@


# 1.187 29-Mar-2013 tedu

remove some of the unused fields from rndstats and stop printing zeroes.
print labels before stats so people can tell what's what.


# 1.186 29-Mar-2013 tedu

sadly, we are going to need machine/cpu.h here for a while to get machdep
noticed by naddy


# 1.185 28-Mar-2013 deraadt

remove excesss includes


Revision tags: OPENBSD_5_3_BASE
# 1.184 20-Sep-2012 yuo

add more sensor types to sensor framework.
- Pressure (10^-3 Pa)
- distance (10^-6 m)
- acceleration (10^-6 m/s^2)

ok deraadt@ reyk@


Revision tags: OPENBSD_5_2_BASE
# 1.183 12-Apr-2012 deraadt

remove rfork(); ok guenther miod


Revision tags: OPENBSD_5_1_BASE
# 1.182 19-Jan-2012 chl

remove unused variable.

ok yasuoka@


# 1.181 15-Jan-2012 dhill

add missing sysctl_pipex declaration

ok yasuoka


# 1.180 16-Sep-2011 yuo

reorder SENSOR_* in switch() and add missing cases.

ok deraadt@


# 1.179 16-Sep-2011 yuo

fix typo


# 1.178 16-Sep-2011 yuo

apply following changes to sensor framework:
- change accuracy of SENSOR_FREQ from Hz to muHz
- add SENSOR_VOLTS_AC entry to userland programs

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.177 08-Jul-2011 yasuoka

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.176 23-May-2011 djm

allow ranges for entering net.inet.(tcp|udp).baddynamic lists, e.g.

sysctl net.inet.tcp.baddynamic=1-32768
sysctl net.inet.udp.baddynamic=+40000-65535

ok mk@


# 1.175 12-Mar-2011 guenther

Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named
KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols
will continue to be supported for a few releases.

Committing now that they ports people have had a couple releases
to update pkgs that usd the old functions


Revision tags: OPENBSD_4_9_BASE
# 1.174 02-Nov-2010 dlg

expose the kernels network livelock counter


# 1.173 19-Aug-2010 kettenis

Introduce an MI kern.consdev sysctl that will replace the MD
machdep.console_device that's only implemented on a few architectures.

ok deraadt@, miod@


Revision tags: OPENBSD_4_8_BASE
# 1.172 21-Apr-2010 deraadt

scale angle by 1000000 to permit min.sec accuracy


# 1.171 21-Apr-2010 deraadt

Add the "angle" sensor, measured in degrees; from Luis Pinto


# 1.170 20-Apr-2010 deraadt

Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga


# 1.169 20-Apr-2010 oga

Add "frequency" type for sensors. (and teach userland how to print that
type). Measured in Hz.

ok deraadt@


# 1.168 15-Apr-2010 yuo

add SENSOR_HUMIDITY to sensor framework to handle humidity values

ok kettenis@ xsa@ sobrado@ krw@ deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.167 05-Nov-2009 michele

IPv6 support for divert sockets.

tested by phessler@ pyr@
ok claudio@
"go ahead" deraadt@


# 1.166 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


# 1.165 04-Oct-2009 michele

Add (again) support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 1

A lot of discussion have happened since my last commit that resulted
in many changes and improvements.
I would *really* like to thank everyone who took part in the discussion
especially canacar@ who spotted out which are the limitations of this approach.

OpenBSD divert(4) is meant to be compatible with software running on
top of FreeBSD's divert sockets even though they are pretty different and will
become even more with time.

discusses with many, but mainly reyk@ canacar@ deraadt@ dlg@ claudio@ beck@
tested by reyk@ and myself
ok reyk@ claudio@ beck@
manpage help and ok by jmc@


# 1.164 08-Sep-2009 michele

I had not enough oks to commit this diff.
Sorry.


# 1.163 08-Sep-2009 michele

Add support for divert sockets. They allow you to:

- queue packets from pf(4) to a userspace application
- reinject packets from the application into the kernel stack.

The divert socket can be bound to a special "divert port" and will
receive every packet diverted to that port by pf(4).

The pf syntax is pretty simple, e.g.:

pass on em0 inet proto tcp from any to any port 80 divert-packet port 8000

test, bugfix and ok by reyk@
manpage help and ok by jmc@
no objections from many others.


# 1.162 12-Aug-2009 kettenis

Add support for SENSOR_WATTS.

ok deraadt@, oga@


Revision tags: OPENBSD_4_6_BASE
# 1.161 07-Jun-2009 millert

Add KERN_FILE2 sysctl analogous to KERN_PROC2 but for file structures,
along with vnode type-specific info to make it more useful for fstat(1).
OK deraadt@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE
# 1.160 04-Aug-2008 miod

Properly output machdep.chipset values on alpha models without pci buses;
ok deraadt@


# 1.159 12-Jul-2008 thib

fix printing of nchstats

ok art@,dlg@


# 1.158 09-Jul-2008 djm

expand the net.inet.(tcp|udp).baddynamic dynamic source port
skipping bitmasks to cover the entire 65536 port space - previously
they covered 512-1024 only.

sysctl needs to be updated to cope with this change; please
"make includes" before rebuilding it.

feedback millert@ ok millert@ deraadt@ markus@


# 1.157 28-Apr-2008 norby

Teach sysctl about mpls.

Claudio did all the code, I'm just comitting it...

ok claudio@ laurent@ dlg@


# 1.156 14-Mar-2008 sobrado

"-Aa" are not required flags; sort synopses; improve description of "-a"

written with invaluable advice from jmc@

ok jmc@


Revision tags: OPENBSD_4_3_BASE
# 1.155 09-Feb-2008 kettenis

Introduce HW_PHYSMEM64 and HW_USERMEM64 sysctls, which don't overflow on
machines with more than 4GB of memory. Make sysctl(8) print values obtained
using these sysctls for hw.physmem and hw.usermem.

ok krw@, miod@


# 1.154 14-Dec-2007 deraadt

Bring in probing for protocols that was missing; ok claudio reyk


# 1.153 13-Dec-2007 reyk

the mib[] array will be modified by sysctl_inet, move the *CTL_STATS
checks after the call for this function. now it works (again) to skip
printing the ip/tcp/udp/icmp stats in sysctl output, use netstat instead.


# 1.152 13-Dec-2007 reyk

implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more
protocols will be added later.

discussed with deraadt@ claudio@ gilles@
ok deraadt@


# 1.151 26-Nov-2007 deraadt

if no arguments given, assume a nice default; ok miod jakemsr deanna


# 1.150 11-Nov-2007 jmc

do not document -w: it is for compat only. just like we did for audioctl,
mixerctl, and wsconsctl.

also move to "name=value", as for the other *ctl apps.

problem spotted by Tim van der Molen, though this might not be the fix
he wanted;


Revision tags: OPENBSD_4_2_BASE
# 1.149 04-Jun-2007 henning

no more ipx


# 1.148 29-May-2007 robert

remove the ztsscale sysctl; ok deraadt@


# 1.147 21-May-2007 cnst

small cleanups:
* use NULL instead of 0 for pointers, as per style(9)
* wrap a long for-loop line in sysctl_malloc()
* fix -Wall complaint in print_sensor()

ok otto@


Revision tags: OPENBSD_4_1_BASE
# 1.146 20-Feb-2007 deraadt

knf found while fixing another bug


# 1.145 06-Jan-2007 deraadt

pretty up the sensor outputs a wee bit more; partly spotted by jsg


# 1.144 26-Dec-2006 mbalmer

Show more digits in timedelta sensor output as the timedelta sensors become
increasingly more precise.

ok deraadt


# 1.143 23-Dec-2006 deraadt

adapt to new two-level sensor sysctl framework; by Constantine A. Murenin


# 1.142 19-Oct-2006 marco

Add WATTHOUR and AMPHOUR

ok jordan@


Revision tags: OPENBSD_4_0_BASE
# 1.141 05-Jun-2006 otto

Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@


# 1.140 04-Jun-2006 deraadt

print time offsets much nicer


# 1.139 25-Apr-2006 deraadt

for SENSOR_TIMEDELTA, store time in nanoseconds. discussion with kettenis
mbalmer will have to cope.


# 1.138 25-Apr-2006 deraadt

if the timeval has data, print it at the end of the line


# 1.137 20-Apr-2006 deraadt

print timedelta; ok dlg


# 1.136 18-Apr-2006 marco

Discussed with jason@ that pfail means "partial fail". Now it translates
to "degraded".

ok jason@


# 1.135 13-Apr-2006 deraadt

Change how hw.sensors prints. Much simpler format, easier to read. While
there, stick to printing temperature measurements in just one sane unit.
ok various people, no objections for the latter


# 1.134 02-Apr-2006 djm

malloc(x * y) -> calloc(x, y) from adobriyan AT gmail.com, with tweaks
suggested by kjell@; ok otto@ pat@ millert@ jaredy@


Revision tags: OPENBSD_3_9_BASE
# 1.133 30-Nov-2005 dlg

add a sensor type for drive status and hook esm up with it.

ok marco@ grange@ deraadt@


# 1.132 15-Nov-2005 kettenis

Add support for light sensors.
ok dlg@


# 1.131 12-Nov-2005 deraadt

more memleaks plugged; evol@online.ptt.ru


# 1.130 12-Nov-2005 deraadt

memory leak; ok cloder


# 1.129 23-Oct-2005 kettenis

Add support for SENSOR_AMPS.
ok dlg@


Revision tags: OPENBSD_3_8_BASE
# 1.128 05-Aug-2005 dlg

add a sensor type that can report percentage

ok deraadt@


# 1.127 04-Aug-2005 deraadt

HW_PHYSMEM and HW_USERMEM should be unsigned; ok tdeval marco


# 1.126 04-Aug-2005 jsg

Support for SENSOR_INTEGER.
ok grange@, dlg@, henning@


# 1.125 04-Aug-2005 dlg

a quick diff for marco, who wanted to see if his power supplies were on or
off. adds printing of the INDICATOR sensor type

ok deraadt@


# 1.124 03-Aug-2005 dlg

extend the sensors framework to allow it to report the state of the
sensor, not just its value.

ok henning@ marco@ deraadt@ beck@ fixes and tweaks grange@


# 1.123 20-Jul-2005 miod

Print the last two kern.nchstats entries.


# 1.122 24-May-2005 markus

add net.inet.ip.ifq for monitoring and changing ifqueue; similar to netbsd
ok henning


# 1.121 24-Apr-2005 deraadt

it is nice if this compiles on other systems


# 1.120 24-Apr-2005 uwe

Do down-sampling of the high-resolution touch pad events in kernel,
and provide sysctls for fine-tuning the touch pad area that covers the
screen. Reasonable defaults are provided, but each machine can be a
bit different due to the manufacturing process.


# 1.119 20-Apr-2005 beck

actually error out when we would overflow by using the return value from
strlcpy, instead of just warning about out, and clobbering stuff anyway.
ok millert@


# 1.118 13-Apr-2005 deraadt

avoid variable aliasing


Revision tags: OPENBSD_3_7_BASE
# 1.117 28-Jan-2005 millert

Allow setting of kern.tty.*; now we can set kern.tty.maxptys. The kernel
itself will return an error if the user tries to set a read-only variable.


# 1.116 14-Sep-2004 deraadt

do not alias over libc ttyname(3)


Revision tags: OPENBSD_3_6_BASE
# 1.115 08-Aug-2004 deraadt

spacing


# 1.114 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


# 1.113 15-Apr-2004 tedu

new world order for emulations. adjust, and become more robust.
testing ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.112 21-Mar-2004 tedu

CPU_LONGRUN is gone. repair kern.emul.nemuls, strcmp on right string


# 1.111 25-Feb-2004 jmc

note that -w is optional and adjust accordingly;
remove -w from EXAMPLES;

diffs from Paul de Weerd;
ok deraadt@


# 1.110 24-Feb-2004 tedu

deal with bpf node


# 1.109 10-Feb-2004 grange

Add flags field to the sensor structure and an only flag SENSOR_FINVALID
which allows to drop information from broken, unwired, disabled, etc
sensors.

ok hshoexer@


# 1.108 10-Feb-2004 millert

Tell user to run pstat -t to get kern.tty.ttyinfo if they explicitly
ask for it, else just ignore it. This is consistent with sysctl
behavior and other entries of type CTLTYPE_STRUCT.


# 1.107 10-Feb-2004 millert

Don't hard-code type for tty sysctls to CTLTYPE_QUAD; some values are
now int.


# 1.106 19-Jan-2004 tedu

little wflag fallout spotted by atle kristensen


# 1.105 11-Jan-2004 grange

Trivial changes to pass through -Wall

ok millert@


# 1.104 11-Jan-2004 deraadt

remove the temporary -O flag..


# 1.103 11-Jan-2004 deraadt

Print output as "var=value" instead of "var = value". Also, any assignment
implies -w. I have despised the existing behaviour for years. ok from
henning, millert, grange


# 1.102 09-Jan-2004 millert

Tell the user to run ps if they try to view things under KERN_PROC2
(same handling as KERN_PROC).


# 1.101 05-Jan-2004 markus

0K == -273.15C and sync computation with drivers; ok grange


# 1.100 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.99 26-Sep-2003 deraadt

check strdup failure; ok anil millert


Revision tags: OPENBSD_3_4_BASE
# 1.98 09-Sep-2003 jmc

slight cleanup of man page and sync usage();


# 1.97 24-Aug-2003 tedu

don't print info about duplicate emuls. gives the illusion there is only
one linux emul and one freebsd emul. ok deraadt@


# 1.96 21-Aug-2003 tedu

emulation is now controlled by sysctl. changes:
add e_flags to struct emul. this stores on/off and native flags.
check for emul enabled in check_exec(). gather all the emuls into a
emulsw so a sysctl can find them. create sysctl. move maxhdrsiz calcualation
into init_main so it cleans up sys_execve codepath. teach sysctl utility
to grok kern.emul hierarchy.
requested and ok deraadt@ some comments from mickey@


# 1.95 11-Jun-2003 deraadt

ansification


# 1.94 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.93 26-May-2003 tedu

ignore longrun struct. eliminates a warning


# 1.92 14-May-2003 jfb

Add the -q flag to suppress all output when setting a variable
with -w

ok jsyn@, millert@


# 1.91 06-May-2003 henning

KNF while I'm here


# 1.90 06-May-2003 henning

for hw.sensors, print stuff in a human friendly way - temperatures in
degC and degF, fan speed in RPM, and voltages in (surprise) V.
theo, millert, grange agree


# 1.89 25-Apr-2003 grange

Support for accessing the information from the hardware monitoring sensors
via hw.sensors node. To get the information from the all sensors
just do
$ sysctl hw.sensors.
To get the information from the particular sensor (number 5 e.g.) do
$ sysctl hw.sensors.5

Tested and ok'ed by henning@ and millert@.


# 1.88 25-Apr-2003 grange

Very little tweak for consistency in space vs \t


# 1.87 07-Apr-2003 deraadt

strlcat; ok millert


Revision tags: OPENBSD_3_3_BASE
# 1.86 21-Jan-2003 markus

add kern.watchdog sysctl and generic watchdog interface;
based on feedback and discussions with mickey, henric, fgsch and jakob.
ok art@, mickey@, jakob@, henric@


# 1.85 17-Dec-2002 millert

Make SysV-style shared memory and semaphore limits sysctl'able.
Instead of allocating a static amount of memory for the data
structures via valloc() in allocsys(), allocate things dynamically
using pool(9) when possible and malloc(9) when not. The various
members of struct seminfo and struct shminfo are in kern.seminfo
and kern.shminfo respectively (not all members of kern.seminfo are
changable).

The data structures used still leave something to be desired but
things are not made worse in that respect by this commit.


Revision tags: OPENBSD_3_2_BASE
# 1.84 06-Jul-2002 nordin

Remove kernel support for NTP. ok deraadt@ and tholo@


# 1.83 03-Jul-2002 deraadt

ansi


# 1.82 09-Jun-2002 todd

rm trailing whitespace


# 1.81 09-Jun-2002 angelos

Print message for kern.mbstat (to use netstat)


# 1.80 26-May-2002 matthieu

- CPU_MAXID and CPU_CHIPSET were swapped in cpu.h
- add support to print machdep.chipset mib on alpha
ok deraadt@


Revision tags: OPENBSD_3_1_BASE
# 1.79 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.78 04-Dec-2001 art

Support for the new uvm sysctls.


# 1.77 05-Nov-2001 art

No need to vm_param.h here.


Revision tags: OPENBSD_3_0_BASE
# 1.76 02-Aug-2001 art

nkmempages.


# 1.75 13-Jul-2001 mickey

escape a wrning on msgbuf, under certain circumstances


# 1.74 05-Jul-2001 jjbg

IPComp support. angelos@ ok.


# 1.73 27-Jun-2001 art

UVM is no longer an option


# 1.72 22-Jun-2001 art

Fix more printf formats.
Add some missing prototypes.


# 1.71 22-Jun-2001 art

Fix a bunch of u_int64_t formats.


# 1.70 22-Jun-2001 art

more arguments than format


# 1.69 22-Jun-2001 mickey

block on msgbuf


# 1.68 22-Jun-2001 art

unused variable


# 1.67 22-Jun-2001 art

Nicer printing of kmem buckets.


# 1.66 01-Jun-2001 mickey

make listall immune to supuh long names; after deraadtification


# 1.65 01-Jun-2001 mickey

duh, main returns


# 1.64 01-Jun-2001 mickey

do not use strlen after strlcpy


# 1.63 14-May-2001 angelos

Ignore empty strings in kern.malloc.kmemstat.<foo>, add tty stats.


# 1.62 12-May-2001 angelos

Better argument checking for kmemstats.


# 1.61 11-May-2001 angelos

Print the new sysctls (nchstats, kmemstats, nselcoll, forkstat)


Revision tags: OPENBSD_2_9_BASE
# 1.60 23-Feb-2001 mickey

give cp_time a proper treatment


# 1.59 22-Jan-2001 deraadt

attempting to sysctl clear a string was failing; checked by millert and aaron


# 1.58 04-Jan-2001 angelos

Sync.


# 1.57 04-Jan-2001 angelos

Read a struct kmembuckets, rather than individual values.


# 1.56 04-Jan-2001 angelos

Print the kern.malloc.* branch


# 1.55 22-Dec-2000 deraadt

strlcpy is great


# 1.54 21-Nov-2000 millert

Fix an int * that should be a size_t * when calling sysctl(3).


Revision tags: OPENBSD_2_8_BASE
# 1.53 30-Jun-2000 millert

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).


# 1.52 14-Jun-2000 provos

add swapencrypt ctl level.


# 1.51 07-Jun-2000 itojun

s/PIMCTL/PIM6CTL/ for less confusion.


# 1.50 22-May-2000 mickey

modify vfs subtree to accomodate for fs-specific variables.
in particular expose vfs.nfs.iothreads, which is a replacement
for nfsiod kludge.
this is not a netbsd port-over, since this particular
implementation builds up the needed variable indexes dynamically
(using the already existing `generic' vfs variables),
as opposed to netbsd which relies on static matching w/ kernel
definitions and configuration...
man changes to come soon.


Revision tags: OPENBSD_2_7_BASE
# 1.49 10-Apr-2000 mickey

branches: 1.49.2;
this is how rnd stats are printed out now


# 1.48 21-Mar-2000 mickey

more random stats


# 1.47 06-Feb-2000 itojun

do not directly include netinet6/{ip6,icmp6}.h


# 1.46 21-Jan-2000 angelos

ip4.allow -> ipip.allow


# 1.45 07-Jan-2000 angelos

gre.allow and mobileip.allow


# 1.44 30-Dec-1999 provos

vm.swapencrypt for UVM


# 1.43 10-Dec-1999 itojun

add IPv6 support. net.inet6.{ip6,icmp6} will be printed.


# 1.42 28-Oct-1999 angelos

net.inet.etherip.allow sysctl


# 1.41 02-Sep-1999 pjanzen

Treat kern.hostid as a u_int, and clean up parsing of integers on the command
line.


# 1.40 01-Jul-1999 deraadt

print kern.arandom unsigned


# 1.39 11-Apr-1999 niklas

Introduce net.inet.{ah,esp}.enable sysctl controls that are off by default.
If you are going to use either of AH or ESP or both, enable these in
/etc/sysctl.conf. Also correct the IPSec debugging sysctl code, it is now
named net.inet.ip.encdebug. Some corrected function signatures too.


# 1.38 09-Apr-1999 niklas

The userland parts of a sysctl that can switch on/off IP-in-IP (protocol 4)


# 1.37 25-Feb-1999 deraadt

mib for pf_key is PF_KEY not PF_KEY_V2


# 1.36 24-Feb-1999 angelos

New position for the encdebug variable.


# 1.35 19-Mar-1998 deraadt

fix type botches


# 1.34 15-Mar-1998 millert

Add support for vfs.* from lite2


# 1.33 17-Feb-1998 matthieu

use warn() instead of warnx() to print error message


# 1.32 25-Oct-1997 mickey

fix diskinfo listing, support blk2chr,chr2blk


# 1.31 25-Oct-1997 mickey

make diskinfo working; fix one bug and one exploit


# 1.30 22-Oct-1997 mickey

newer bios stuff


# 1.29 15-Oct-1997 kstailey

s/xntpd/xntpdc/


# 1.28 03-Oct-1997 deraadt

put real geo field in ()


# 1.27 03-Oct-1997 deraadt

avoid sign extension on bios geometry!


# 1.26 21-Sep-1997 mickey

new machdep.bios subtree


# 1.25 12-Sep-1997 millert

Add parens to shut up -Wall.


# 1.24 29-Aug-1997 mickey

fix case we have no CPU_BIOS* defined


# 1.23 28-Aug-1997 mickey

symbolic bios bootdev, s/hpc/tpc/ for bios geonetry


# 1.22 28-Aug-1997 mickey

grok bios geometry


# 1.21 19-Aug-1997 millert

Some KNF, check a few return values and use err/warn.


# 1.20 19-Aug-1997 millert

Move bad dynamic port parsing into parse_baddynamic().


# 1.19 19-Aug-1997 millert

Add support for adding/subtracting ports from the current baddynamic
mask.


# 1.18 19-Aug-1997 millert

typo


# 1.17 19-Aug-1997 millert

Make net.inet.tcp.baddynamic and net.inet.udp.baddynamic
comma-separated instead of space-separated when printing
so it is easy to cut and paste.


# 1.16 19-Aug-1997 millert

Only print bad dynamic ports list for udp and tcp since that's all
that exist. This fixes a bug where net.inet.ip.redirect,
net.inet.ip.directed-broadcast, and net.inet.tcp.keepinittimem
got interpreted as dynamic port lists. Oops.


# 1.15 09-Aug-1997 millert

The list of tcp/udp ports not to allocate dynamically is now
a bitmask configurable via sysctl([38]). The default values
have not changed. If one wants to change the list it should
be done early on in /etc/rc.


# 1.14 22-Jul-1997 kstailey

tabify, use NULL for ptr ops, not 0


# 1.13 22-Jul-1997 kstailey

re-tabify (angelos!)


# 1.12 15-Jul-1997 angelos

sysctl for PF_ENCAP.


# 1.11 28-Jun-1997 deraadt

fix the rnd types


# 1.10 24-Jun-1997 mickey

more accounting!


# 1.9 17-Jun-1997 mickey

count slow queue low entropy drops
bigger queue
use queue overflows for arc4_stir()


# 1.8 14-Jun-1997 mickey

split the treatment of the random events
event_q by flipk@
spl fix by deraadt@
gother statistics about whole processing
use 'sysctl kern.random' to view what had happened
also fix wrong vm.psstrings description


# 1.7 06-Apr-1997 millert

Use a size_t as arg 4 to sysctl(3).


# 1.6 16-Jan-1997 millert

Support VM_PSSTRINGS. Man, this has been sitting in my tree for a while...


# 1.5 15-Jan-1997 millert

getopt(3) returns -1 when out of args, not EOF, whee!


# 1.4 25-Nov-1996 mickey

ipx sysctl.
cleanup (protyping, printf formats and so)
1 (one) bug fix in printf's arg (struct instead of field)


# 1.3 08-Aug-1996 tholo

Make {,f}chown(2) behaviour POSIX.1 compliant with SUID / SGID files
Enable CTL_FS processing by sysctl(3)
Add CTL_FS request to disable clearing SUID / SGID bit when a files owner
or group is changed by root
Make sysctl(8) understand CTL_FS requests


# 1.2 30-Mar-1996 mickey

DDB support added.


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision