summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
Commit message (Collapse)AuthorAgeFilesLines
* kern: for pointers replace 0 with NULL.pfg2016-04-151-2/+2
| | | | | | These are mostly cosmetical, no functional change. Found with devel/coccinelle.
* Evaluate the sysctl_running fail point before taking the sysctl lock.markj2016-01-261-2/+2
| | | | | | | | The fail point handler may sleep, but this is not permitted while holding a rm read lock. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* Flesh out sysctl types further (follow-up of r290475)cem2015-11-071-2/+53
| | | | | | | | | | | | | | | | | | | | Use the right intmax_t type instead of intptr_t in a few remaining places. Add support for CTLFLAG_TUN for the new fixed with types. Bruce will be upset that the new handlers silently truncate tuned quad-sized inputs, but so do all of the existing handlers. Add the new types to debug_dump_node, for whatever use that is. Bump FreeBSD_version again, for good measure. We are changing SYSCTL_HANDLER_ARGS and a member of struct sysctl_oid to intmax_t. Correct the sysctl typed NULL values for the fixed-width types. (Hat tip: hps@.) Suggested by: hps (partial) Sponsored by: EMC / Isilon Storage Division
* Round out SYSCTL macros to the full set of fixed-width typescem2015-11-071-1/+33
| | | | | | | | | | | | | | | | | | | | | | Add S8, S16, S32, and U32 types; add SYSCTL*() macros for them, as well as for the existing 64-bit types. (While SYSCTL*QUAD and UQUAD macros already exist, they do not take the same sort of 'val' parameter that the other macros do.) Clean up the documented "types" in the sysctl.9 document. (These are macros and thus not real types, but the manual page documents intent.) The sysctl_add_oid(9) arg2 has been bumped from intptr_t to intmax_t to accommodate 64-bit types on 32-bit pointer architectures. This is just the kernel support piece; the userspace sysctl(1) support will follow in a later patch. Submitted by: Ravi Pokala <rpokala@panasas.com> Reviewed by: cem Relnotes: no Sponsored by: Panasas Differential Revision: https://reviews.freebsd.org/D4091
* Sysctl: Add common support for U8, U16 typescem2015-10-221-0/+64
| | | | Sponsored by: EMC / Isilon Storage Division
* sysctl: switch sysctllock to a sleepable rmlock, take 2mjg2015-09-151-103/+101
| | | | | This restores r285125. Previous attempt was reverted due to a bug in rmlocks, which is fixed since r287833.
* Revert r285125 until rmlocks get fixed.mjg2015-07-301-101/+103
| | | | | | Right now there is a chance that sysctl unregister will cause reader to block on the sx lock associated with sysctl rmlock, in which case kernels with debug enabled will panic.
* Don't acquire sysctlmemlock in userland_sysctl() when the old valuepkelsey2015-07-061-1/+1
| | | | | | | | | | | | | | | | | pointer is NULL, as in that case there are no userland pages that could potentially be wired. It is common for old to be NULL and oldlenp to be non-NULL in calls to userland_sysctl(), as this is used to probe for the length of a variable-length sysctl entry before retrieving a value. Note that it is typical for such calls to be made with an uninitialized value in *oldlenp, so sysctlmemlock was essentially being acquired at random (depending on the uninitialized value in *oldlenp being > PAGE_SIZE or not) for these calls prior to this patch. Differential Revision: https://reviews.freebsd.org/D2987 Reviewed by: mjg, kib Approved by: jmallett (mentor) MFC after: 1 month
* sysctl: get rid of sysctl_lock/unlockmjg2015-07-041-22/+10
| | | | Inline their contents into the only consumer.
* sysctl: remove a debugging printf which crept in with r285125mjg2015-07-041-1/+1
|
* sysctl: switch sysctllock to a sleepable rmlockmjg2015-07-041-92/+102
| | | | The lock is almost never taken for writing.
* Implement a simple OID number garbage collector. Given the increasinghselasky2015-03-251-16/+47
| | | | | | | | | | | | | | | number of dynamically created and destroyed SYSCTLs during runtime it is very likely that the current new OID number limit of 0x7fffffff can be reached. Especially if dynamic OID creation and destruction results from automatic tests. Additional changes: - Optimize the typical use case by decrementing the next automatic OID sequence number instead of incrementing it. This saves searching time when inserting new OIDs into a fresh parent OID node. - Add simple check for duplicate non-automatic OID numbers. MFC after: 1 week
* Make sure tunable sysctls are only fetched once. The existing code canhselasky2015-03-241-0/+3
| | | | | re-register sysctls when destroying sysctl contexts or when moving sysctls from one tree to another.
* Correct string pointer offset for error printout.hselasky2015-03-241-1/+1
|
* In sbuf_new_for_sysctl(), default the buffer size to 64 bytes if theian2015-03-171-0/+3
| | | | passed-in pointer is NULL and the length is zero.
* Set the SBUF_INCLUDENUL flag in sbuf_new_for_sysctl() so that sysctlian2015-03-141-1/+1
| | | | | | | | | | | | | | | strings returned to userland include the nulterm byte. Some uses of sbuf_new_for_sysctl() write binary data rather than strings; clear the SBUF_INCLUDENUL flag after calling sbuf_new_for_sysctl() in those cases. (Note that the sbuf code still automatically adds a nulterm byte in sbuf_finish(), but since it's not included in the length it won't get copied to userland along with the binary data.) Remove explicit adding of a nulterm byte in a couple places now that it gets done automatically by the sbuf drain code. PR: 195668
* sysctl: don't modify oid_running for static nodesmjg2014-12-281-4/+7
| | | | | It is necessary to prevent nodes from being destroyed while used, but static ones cannot be destroyed.
* Now that sysctl_root is only called with sysctl lock in shared mode, updatemjg2014-10-261-2/+3
| | | | | | | | its assertion to require that. Update comment missed in r273400: sysctl_xlock/unlock -> sysctl_xlock/xunlock Noted by: jhb
* In all cases except CTLTYPE_STRING, penv is NULL here, so passing itdes2014-10-231-5/+4
| | | | | | | | indiscriminately to printf() and freeenv() is incorrect. Add a NULL check before freeenv(); as for printf(), we could use req.newptr instead, but we'd have to select the correct format string based on the type, and that's too much work for an error message, so just remove it.
* Mark some more sysctl stuff shared-locked and MPSAFE.mjg2014-10-211-15/+15
|
* Make sysctl name2oid shared-locked as well.mjg2014-10-211-2/+2
| | | | This is a follow-up to r273401.
* Implement shared locking for sysctl.mjg2014-10-211-14/+42
|
* Rename sysctl_lock and _unlock to sysctl_xlock and _xunlock.mjg2014-10-211-2/+2
|
* Follow up to r225617. In order to maximize the re-usability of kernel codedavide2014-10-161-1/+1
| | | | | | | | in userland rename in-kernel getenv()/setenv() to kern_setenv()/kern_getenv(). This fixes a namespace collision with libc symbols. Submitted by: kmacy Tested by: make universe
* Don't make a temporary copy of fixed sysctl strings.mjg2014-07-101-6/+13
|
* When getting the initial value of numeric tunables use thehselasky2014-07-051-12/+20
| | | | | | getenv_xxx() functions instead of strtoq(), because the getenv_xxx() functions include wrappers for various postfixes like G/M/K, which strtoq() doesn't do.
* Fix regression issue after r267961. Handle special string case forhselasky2014-06-281-2/+5
| | | | | | | SYSCTLs like previously. MFC after: 2 weeks Reported by: several people
* Pull in r267961 and r267973 again. Fix for issues reported will follow.hselasky2014-06-281-44/+149
|
* Revert r267961, r267973:gjb2014-06-271-149/+44
| | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifhselasky2014-06-271-44/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies
* Update kernel inclusions of capability.h to use capsicum.h instead; somerwatson2014-03-161-1/+1
| | | | | | | | further refinement is required as some device drivers intended to be portable over FreeBSD versions rely on __FreeBSD_version to decide whether to include capability.h. MFC after: 3 weeks
* Remove identical vnet sysctl handlers, and handle CTLFLAG_VNETglebius2014-02-071-1/+4
| | | | | | | | | | in the sysctl_root(). Note: SYSCTL_VNET_* macros can be removed as well. All is needed to virtualize a sysctl oid is set CTLFLAG_VNET on it. But for now keep macros in place to avoid large code churn. Sponsored by: Nginx, Inc.
* Add a helpful message that can help point to why a sysctl tree removal failedscottl2013-08-091-1/+5
| | | | | Obtained from: Netflix MFC after: 3 days
* - Use strdup(9) instead of reimplementing it.marius2013-03-011-52/+18
| | | | | | | | | - Use __DECONST instead of strange casts. - Reduce code duplication and simplify name2oid(). PR: 176373 Submitted by: Christoph Mallon MFC after: 1 week
* Update comments to reflect r246689.marius2013-02-111-2/+8
|
* Make SYSCTL_{LONG,QUAD,ULONG,UQUAD}(9) work as advertised and also handlemarius2013-02-111-9/+17
| | | | | | | constant values. Reviewed by: kib MFC after: 3 days
* Handle spurious page faults that may occur in no-fault sections of thealc2012-03-221-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | kernel. When access restrictions are added to a page table entry, we flush the corresponding virtual address mapping from the TLB. In contrast, when access restrictions are removed from a page table entry, we do not flush the virtual address mapping from the TLB. This is exactly as recommended in AMD's documentation. In effect, when access restrictions are removed from a page table entry, AMD's MMUs will transparently refresh a stale TLB entry. In short, this saves us from having to perform potentially costly TLB flushes. In contrast, Intel's MMUs are allowed to generate a spurious page fault based upon the stale TLB entry. Usually, such spurious page faults are handled by vm_fault() without incident. However, when we are executing no-fault sections of the kernel, we are not allowed to execute vm_fault(). This change introduces special-case handling for spurious page faults that occur in no-fault sections of the kernel. In collaboration with: kib Tested by: gibbs (an earlier version) I would also like to acknowledge Hiroki Sato's assistance in diagnosing this problem. MFC after: 1 week
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-1/+1
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* Define two new sysctl node flags: CTLFLAG_CAPRD and CTLFLAG_CAPRW, whichrwatson2011-07-171-6/+36
| | | | | | | | | | | | | | | | | | | may be jointly referenced via the mask CTLFLAG_CAPRW. Sysctls with these flags are available in Capsicum's capability mode; other sysctl nodes are not. Flag several useful sysctls as available in capability mode, such as memory layout sysctls required by the run-time linker and malloc(3). Also expose access to randomness and available kernel features. A few sysctls are enabled to support name->MIB conversion; these may leak information to capability mode by virtue of providing resolution on names not flagged for access in capability mode. This is, generally, not a huge problem, but might be something to resolve in the future. Flag these cases with XXX comments. Submitted by: jonathan Sponsored by: Google, Inc.
* Use a name instead of a magic number for kern_yield(9) when the prioritymdf2011-05-131-1/+1
| | | | | | | | should not change. Fetch the td_user_pri under the thread lock. This is probably not necessary but a magic number also seems preferable to knowing the implementation details here. Requested by: Jason Behmer < jason DOT behmer AT isilon DOT com >
* - Merge changes to the base system to support OFED. These includejeff2011-03-211-4/+26
| | | | | a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND, and other miscellaneous small features.
* Based on discussions on the svn-src mailing list, rework r218195:mdf2011-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | - entirely eliminate some calls to uio_yeild() as being unnecessary, such as in a sysctl handler. - move should_yield() and maybe_yield() to kern_synch.c and move the prototypes from sys/uio.h to sys/proc.h - add a slightly more generic kern_yield() that can replace the functionality of uio_yield(). - replace source uses of uio_yield() with the functional equivalent, or in some cases do not change the thread priority when switching. - fix a logic inversion bug in vlrureclaim(), pointed out by bde@. - instead of using the per-cpu last switched ticks, use a per thread variable for should_yield(). With PREEMPTION, the only reasonable use of this is to determine if a lock has been held a long time and relinquish it. Without PREEMPTION, this is essentially the same as the per-cpu variable.
* Explicitly wire the user buffer rather than doing it implicitly inmdf2011-01-271-4/+2
| | | | | | | | sbuf_new_for_sysctl(9). This allows using an sbuf with a SYSCTL_OUT drain for extremely large amounts of data where the caller knows that appropriate references are held, and sleeping is not an issue. Inspired by: rwatson
* Remove the CTLFLAG_NOLOCK as it seems to be both unused andmdf2011-01-261-5/+3
| | | | | | | | | | | | unfunctional. Wiring the user buffer has only been done explicitly since r101422. Mark the kern.disks sysctl as MPSAFE since it is and it seems to have been mis-using the NOLOCK flag. Partially break the KPI (but not the KBI) for the sysctl_req 'lock' field since this member should be private and the "REQ_LOCKED" state seems meaningless now.
* Introduce signed and unsigned version of CTLTYPE_QUAD, renamingmdf2011-01-191-3/+6
| | | | existing uses. Rename sysctl_handle_quad() to sysctl_handle_64().
* Specify a CTLTYPE_FOO so that a future sysctl(8) change does not needmdf2011-01-181-1/+2
| | | | to rely on the format string.
* Fix uninitialized variable warning that shows on Tinderbox but not mymdf2010-11-291-1/+1
| | | | | | setup. (??) Submitted by: Michael Butler <imb at protected-networks dot net>
* Do not hold the sysctl lock across a call to the handler. This fixes amdf2010-11-291-27/+67
| | | | | | | | | | general LOR issue where the sysctl lock had no good place in the hierarchy. One specific instance is #284 on http://sources.zabbadoz.net/freebsd/lor.html . Reviewed by: jhb MFC after: 1 month X-MFC-note: split oid_refcnt field for oid_running to preserve KBI
* Slightly modify the logic in sysctl_find_oid to reduce the indentation.mdf2010-11-291-19/+22
| | | | | | There should be no functional change. MFC after: 3 days
* Use the SYSCTL_CHILDREN macro in kern_sysctl.c to help de-obfuscate themdf2010-11-291-7/+6
| | | | | | code. MFC after: 3 days
OpenPOWER on IntegriCloud