FreeBSD kernel kern code
kern_sysctl.c File Reference
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_ddb.h"
#include "opt_ktrace.h"
#include "opt_sysctl.h"
#include <sys/param.h>
#include <sys/fail.h>
#include <sys/systm.h>
#include <sys/capsicum.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/jail.h>
#include <sys/kdb.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/rmlock.h>
#include <sys/sbuf.h>
#include <sys/sx.h>
#include <sys/sysproto.h>
#include <sys/uio.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
Include dependency graph for kern_sysctl.c:

Go to the source code of this file.

Data Structures

struct  __sysctl_args
 
struct  __sysctlbyname_args
 

Macros

#define SYSCTL_WLOCK()   rm_wlock(&sysctllock)
 
#define SYSCTL_WUNLOCK()   rm_wunlock(&sysctllock)
 
#define SYSCTL_RLOCK(tracker)   rm_rlock(&sysctllock, (tracker))
 
#define SYSCTL_RUNLOCK(tracker)   rm_runlock(&sysctllock, (tracker))
 
#define SYSCTL_WLOCKED()   rm_wowned(&sysctllock)
 
#define SYSCTL_ASSERT_LOCKED()   rm_assert(&sysctllock, RA_LOCKED)
 
#define SYSCTL_ASSERT_WLOCKED()   rm_assert(&sysctllock, RA_WLOCKED)
 
#define SYSCTL_ASSERT_RLOCKED()   rm_assert(&sysctllock, RA_RLOCKED)
 
#define SYSCTL_INIT()
 
#define SYSCTL_SLEEP(ch, wmesg, timo)    rm_sleep(ch, &sysctllock, 0, wmesg, timo)
 

Enumerations

enum  sysctl_iter_action { ITER_SIBLINGS , ITER_CHILDREN , ITER_FOUND }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_SYSCTL, "sysctl", "sysctl internal magic")
 
static MALLOC_DEFINE (M_SYSCTLOID, "sysctloid", "sysctl dynamic oids")
 
static MALLOC_DEFINE (M_SYSCTLTMP, "sysctltmp", "sysctl temp output buffer")
 
static int sysctl_root (SYSCTL_HANDLER_ARGS)
 
static char * sysctl_escape_name (const char *)
 
static int sysctl_remove_oid_locked (struct sysctl_oid *oidp, int del, int recurse)
 
static int sysctl_old_kernel (struct sysctl_req *, const void *, size_t)
 
static int sysctl_new_kernel (struct sysctl_req *, void *, size_t)
 
static struct sysctl_oid * sysctl_find_oidname (const char *name, struct sysctl_oid_list *list)
 
void sysctl_wlock (void)
 
void sysctl_wunlock (void)
 
static int sysctl_root_handler_locked (struct sysctl_oid *oid, void *arg1, intmax_t arg2, struct sysctl_req *req, struct rm_priotracker *tracker)
 
static void sysctl_load_tunable_by_oid_locked (struct sysctl_oid *oidp)
 
static int sysctl_search_oid (struct sysctl_oid **nodes, struct sysctl_oid *needle)
 
static void sysctl_warn_reuse (const char *func, struct sysctl_oid *leaf)
 
void sysctl_register_oid (struct sysctl_oid *oidp)
 
void sysctl_register_disabled_oid (struct sysctl_oid *oidp)
 
void sysctl_enable_oid (struct sysctl_oid *oidp)
 
void sysctl_unregister_oid (struct sysctl_oid *oidp)
 
int sysctl_ctx_init (struct sysctl_ctx_list *c)
 
int sysctl_ctx_free (struct sysctl_ctx_list *clist)
 
struct sysctl_ctx_entry * sysctl_ctx_entry_add (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
 
struct sysctl_ctx_entry * sysctl_ctx_entry_find (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
 
int sysctl_ctx_entry_del (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
 
int sysctl_remove_oid (struct sysctl_oid *oidp, int del, int recurse)
 
int sysctl_remove_name (struct sysctl_oid *parent, const char *name, int del, int recurse)
 
struct sysctl_oid * sysctl_add_oid (struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, int number, const char *name, int kind, void *arg1, intmax_t arg2, int(*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr, const char *label)
 
void sysctl_rename_oid (struct sysctl_oid *oidp, const char *name)
 
int sysctl_move_oid (struct sysctl_oid *oid, struct sysctl_oid_list *parent)
 
 SET_DECLARE (sysctl_set, struct sysctl_oid)
 
static void sysctl_register_all (void *arg)
 
 SYSINIT (sysctl, SI_SUB_KMEM, SI_ORDER_FIRST, sysctl_register_all, NULL)
 
static int sysctl_sysctl_name (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_NAME, name, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_name, "")
 
static enum sysctl_iter_action sysctl_sysctl_next_node (struct sysctl_oid *oidp, int *name, unsigned int namelen, bool honor_skip)
 
static bool sysctl_sysctl_next_action (struct sysctl_oid_list *lsp, int *name, u_int namelen, int *next, int *len, int level, bool honor_skip)
 
static int sysctl_sysctl_next (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_NEXT, next, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_next, "")
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_NEXTNOSKIP, nextnoskip, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_next, "")
 
static int name2oid (char *name, int *oid, int *len, struct sysctl_oid **oidpp)
 
static int sysctl_sysctl_name2oid (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_sysctl, CTL_SYSCTL_NAME2OID, name2oid, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE|CTLFLAG_CAPRW, 0, 0, sysctl_sysctl_name2oid, "I", "")
 
static int sysctl_sysctl_oidfmt (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_OIDFMT, oidfmt, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_oidfmt, "")
 
static int sysctl_sysctl_oiddescr (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_OIDDESCR, oiddescr, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_oiddescr, "")
 
static int sysctl_sysctl_oidlabel (SYSCTL_HANDLER_ARGS)
 
static SYSCTL_NODE (_sysctl, CTL_SYSCTL_OIDLABEL, oidlabel, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_oidlabel, "")
 
int sysctl_handle_bool (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_8 (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_16 (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_32 (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_int (SYSCTL_HANDLER_ARGS)
 
int sysctl_msec_to_ticks (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_long (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_64 (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_string (SYSCTL_HANDLER_ARGS)
 
int sysctl_handle_opaque (SYSCTL_HANDLER_ARGS)
 
int sysctl_usec_to_sbintime (SYSCTL_HANDLER_ARGS)
 
int sysctl_msec_to_sbintime (SYSCTL_HANDLER_ARGS)
 
int sysctl_sec_to_timeval (SYSCTL_HANDLER_ARGS)
 
int kernel_sysctl (struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
 
int kernel_sysctlbyname (struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
 
static int sysctl_old_user (struct sysctl_req *req, const void *p, size_t l)
 
static int sysctl_new_user (struct sysctl_req *req, void *p, size_t l)
 
int sysctl_wire_old_buffer (struct sysctl_req *req, size_t len)
 
int sysctl_find_oid (int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req)
 
int sys___sysctl (struct thread *td, struct __sysctl_args *uap)
 
int kern___sysctlbyname (struct thread *td, const char *oname, size_t namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags, bool inkernel)
 
int sys___sysctlbyname (struct thread *td, struct __sysctlbyname_args *uap)
 
int userland_sysctl (struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, const void *new, size_t newlen, size_t *retval, int flags)
 
static int sbuf_sysctl_drain (void *arg, const char *data, int len)
 
struct sbuf * sbuf_new_for_sysctl (struct sbuf *s, char *buf, int length, struct sysctl_req *req)
 

Variables

static struct rmlock sysctllock
 
static struct sx __exclusive_cache_line sysctlmemlock
 
static struct sx sysctlstringlock
 
struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children)
 

Macro Definition Documentation

◆ SYSCTL_ASSERT_LOCKED

#define SYSCTL_ASSERT_LOCKED ( )    rm_assert(&sysctllock, RA_LOCKED)

Definition at line 112 of file kern_sysctl.c.

◆ SYSCTL_ASSERT_RLOCKED

#define SYSCTL_ASSERT_RLOCKED ( )    rm_assert(&sysctllock, RA_RLOCKED)

Definition at line 114 of file kern_sysctl.c.

◆ SYSCTL_ASSERT_WLOCKED

#define SYSCTL_ASSERT_WLOCKED ( )    rm_assert(&sysctllock, RA_WLOCKED)

Definition at line 113 of file kern_sysctl.c.

◆ SYSCTL_INIT

#define SYSCTL_INIT ( )
Value:
rm_init_flags(&sysctllock, "sysctl lock", \
RM_SLEEPABLE)
void rm_init_flags(struct rmlock *rm, const char *name, int opts)
Definition: kern_rmlock.c:280
static struct rmlock sysctllock
Definition: kern_sysctl.c:103

Definition at line 115 of file kern_sysctl.c.

◆ SYSCTL_RLOCK

#define SYSCTL_RLOCK (   tracker)    rm_rlock(&sysctllock, (tracker))

Definition at line 109 of file kern_sysctl.c.

◆ SYSCTL_RUNLOCK

#define SYSCTL_RUNLOCK (   tracker)    rm_runlock(&sysctllock, (tracker))

Definition at line 110 of file kern_sysctl.c.

◆ SYSCTL_SLEEP

#define SYSCTL_SLEEP (   ch,
  wmesg,
  timo 
)     rm_sleep(ch, &sysctllock, 0, wmesg, timo)

Definition at line 117 of file kern_sysctl.c.

◆ SYSCTL_WLOCK

#define SYSCTL_WLOCK ( )    rm_wlock(&sysctllock)

Definition at line 107 of file kern_sysctl.c.

◆ SYSCTL_WLOCKED

#define SYSCTL_WLOCKED ( )    rm_wowned(&sysctllock)

Definition at line 111 of file kern_sysctl.c.

◆ SYSCTL_WUNLOCK

#define SYSCTL_WUNLOCK ( )    rm_wunlock(&sysctllock)

Definition at line 108 of file kern_sysctl.c.

Enumeration Type Documentation

◆ sysctl_iter_action

Enumerator
ITER_SIBLINGS 
ITER_CHILDREN 
ITER_FOUND 

Definition at line 1147 of file kern_sysctl.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kern___sysctlbyname()

int kern___sysctlbyname ( struct thread *  td,
const char *  oname,
size_t  namelen,
void *  old,
size_t *  oldlenp,
void *  new,
size_t  newlen,
size_t *  retval,
int  flags,
bool  inkernel 
)

Definition at line 2349 of file kern_sysctl.c.

References flags, free(), kernel_sysctl(), malloc(), name, and userland_sysctl().

Referenced by sys___sysctlbyname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kernel_sysctl()

int kernel_sysctl ( struct thread *  td,
int *  name,
u_int  namelen,
void *  old,
size_t *  oldlenp,
void *  new,
size_t  newlen,
size_t *  retval,
int  flags 
)

Definition at line 2006 of file kern_sysctl.c.

References flags, name, sysctl_new_kernel(), sysctl_old_kernel(), and sysctl_root().

Referenced by kern___sysctlbyname(), and kernel_sysctlbyname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kernel_sysctlbyname()

int kernel_sysctlbyname ( struct thread *  td,
char *  name,
void *  old,
size_t *  oldlenp,
void *  new,
size_t  newlen,
size_t *  retval,
int  flags 
)

Definition at line 2053 of file kern_sysctl.c.

References flags, kernel_sysctl(), and name.

Here is the call graph for this function:

◆ MALLOC_DEFINE() [1/3]

static MALLOC_DEFINE ( M_SYSCTL  ,
"sysctl"  ,
"sysctl internal magic"   
)
static

◆ MALLOC_DEFINE() [2/3]

static MALLOC_DEFINE ( M_SYSCTLOID  ,
"sysctloid"  ,
"sysctl dynamic oids"   
)
static

◆ MALLOC_DEFINE() [3/3]

static MALLOC_DEFINE ( M_SYSCTLTMP  ,
"sysctltmp"  ,
"sysctl temp output buffer"   
)
static

◆ name2oid()

static int name2oid ( char *  name,
int *  oid,
int *  len,
struct sysctl_oid **  oidpp 
)
static

Definition at line 1324 of file kern_sysctl.c.

References name, sysctl__children, and SYSCTL_ASSERT_LOCKED.

Referenced by sysctl_sysctl_name2oid().

Here is the caller graph for this function:

◆ sbuf_new_for_sysctl()

◆ sbuf_sysctl_drain()

static int sbuf_sysctl_drain ( void *  arg,
const char *  data,
int  len 
)
static

Definition at line 2492 of file kern_sysctl.c.

References data.

Referenced by sbuf_new_for_sysctl().

Here is the caller graph for this function:

◆ SET_DECLARE()

SET_DECLARE ( sysctl_set  ,
struct sysctl_oid   
)

◆ sys___sysctl()

int sys___sysctl ( struct thread *  td,
struct __sysctl_args uap 
)

◆ sys___sysctlbyname()

int sys___sysctlbyname ( struct thread *  td,
struct __sysctlbyname_args uap 
)

◆ sysctl_add_oid()

struct sysctl_oid * sysctl_add_oid ( struct sysctl_ctx_list *  clist,
struct sysctl_oid_list *  parent,
int  number,
const char *  name,
int  kind,
void *  arg1,
intmax_t  arg2,
int(*)(SYSCTL_HANDLER_ARGS)  handler,
const char *  fmt,
const char *  descr,
const char *  label 
)

◆ sysctl_ctx_entry_add()

struct sysctl_ctx_entry * sysctl_ctx_entry_add ( struct sysctl_ctx_list *  clist,
struct sysctl_oid *  oidp 
)

Definition at line 660 of file kern_sysctl.c.

References malloc(), and SYSCTL_ASSERT_WLOCKED.

Referenced by sysctl_add_oid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_ctx_entry_del()

int sysctl_ctx_entry_del ( struct sysctl_ctx_list *  clist,
struct sysctl_oid *  oidp 
)

Definition at line 695 of file kern_sysctl.c.

References free(), sysctl_ctx_entry_find(), SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Here is the call graph for this function:

◆ sysctl_ctx_entry_find()

struct sysctl_ctx_entry * sysctl_ctx_entry_find ( struct sysctl_ctx_list *  clist,
struct sysctl_oid *  oidp 
)

Definition at line 675 of file kern_sysctl.c.

References SYSCTL_ASSERT_WLOCKED.

Referenced by sysctl_ctx_entry_del().

Here is the caller graph for this function:

◆ sysctl_ctx_free()

int sysctl_ctx_free ( struct sysctl_ctx_list *  clist)

Definition at line 608 of file kern_sysctl.c.

References free(), panic(), sysctl_register_oid(), sysctl_remove_oid_locked(), SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Referenced by alloc_bounce_zone(), cpufreq_detach(), and device_sysctl_fini().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_ctx_init()

int sysctl_ctx_init ( struct sysctl_ctx_list *  c)

Definition at line 590 of file kern_sysctl.c.

Referenced by alloc_bounce_zone(), cpufreq_attach(), devclass_sysctl_init(), and device_sysctl_init().

Here is the caller graph for this function:

◆ sysctl_enable_oid()

void sysctl_enable_oid ( struct sysctl_oid *  oidp)

Definition at line 542 of file kern_sysctl.c.

References SYSCTL_ASSERT_WLOCKED.

Referenced by linker_file_enable_sysctls().

Here is the caller graph for this function:

◆ sysctl_escape_name()

static char * sysctl_escape_name ( const char *  orig)
static

Definition at line 758 of file kern_sysctl.c.

References malloc().

Referenced by sysctl_add_oid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_find_oid()

int sysctl_find_oid ( int *  name,
u_int  namelen,
struct sysctl_oid **  noid,
int *  nindx,
struct sysctl_req *  req 
)

Definition at line 2160 of file kern_sysctl.c.

References name, sysctl__children, and SYSCTL_ASSERT_LOCKED.

Referenced by sysctl_root(), sysctl_sysctl_oiddescr(), sysctl_sysctl_oidfmt(), and sysctl_sysctl_oidlabel().

Here is the caller graph for this function:

◆ sysctl_find_oidname()

static struct sysctl_oid * sysctl_find_oidname ( const char *  name,
struct sysctl_oid_list *  list 
)
static

Definition at line 132 of file kern_sysctl.c.

References name, and SYSCTL_ASSERT_LOCKED.

Referenced by sysctl_add_oid(), sysctl_move_oid(), and sysctl_register_oid().

Here is the caller graph for this function:

◆ sysctl_handle_16()

int sysctl_handle_16 ( SYSCTL_HANDLER_ARGS  )

Definition at line 1580 of file kern_sysctl.c.

◆ sysctl_handle_32()

int sysctl_handle_32 ( SYSCTL_HANDLER_ARGS  )

Definition at line 1612 of file kern_sysctl.c.

◆ sysctl_handle_64()

int sysctl_handle_64 ( SYSCTL_HANDLER_ARGS  )

Definition at line 1746 of file kern_sysctl.c.

Referenced by sysctl_debug_ktr_mask(), sysctl_kern_timecounter_freq(), sysctl_msec_to_sbintime(), and sysctl_usec_to_sbintime().

Here is the caller graph for this function:

◆ sysctl_handle_8()

int sysctl_handle_8 ( SYSCTL_HANDLER_ARGS  )

Definition at line 1548 of file kern_sysctl.c.

◆ sysctl_handle_bool()

int sysctl_handle_bool ( SYSCTL_HANDLER_ARGS  )

Definition at line 1513 of file kern_sysctl.c.

◆ sysctl_handle_int()

◆ sysctl_handle_long()

◆ sysctl_handle_opaque()

int sysctl_handle_opaque ( SYSCTL_HANDLER_ARGS  )

Definition at line 1867 of file kern_sysctl.c.

Referenced by ntp_sysctl(), sysctl_intrcnt(), sysctl_intrnames(), sysctl_kern_clockrate(), and sysctl_kern_msgbuf().

Here is the caller graph for this function:

◆ sysctl_handle_string()

◆ sysctl_load_tunable_by_oid_locked()

static void sysctl_load_tunable_by_oid_locked ( struct sysctl_oid *  oidp)
static

Definition at line 207 of file kern_sysctl.c.

References __aligned, data, freeenv(), getenv_array(), kern_getenv(), path, printf(), sysctl_new_kernel(), sysctl_old_kernel(), and sysctl_root_handler_locked().

Referenced by sysctl_register_oid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_move_oid()

int sysctl_move_oid ( struct sysctl_oid *  oid,
struct sysctl_oid_list *  parent 
)

Definition at line 941 of file kern_sysctl.c.

References parent, sysctl_find_oidname(), sysctl_register_oid(), sysctl_unregister_oid(), SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Here is the call graph for this function:

◆ sysctl_msec_to_sbintime()

int sysctl_msec_to_sbintime ( SYSCTL_HANDLER_ARGS  )

Definition at line 1925 of file kern_sysctl.c.

References sysctl_handle_64().

Here is the call graph for this function:

◆ sysctl_msec_to_ticks()

int sysctl_msec_to_ticks ( SYSCTL_HANDLER_ARGS  )

Definition at line 1673 of file kern_sysctl.c.

References hz, and sysctl_handle_int().

Here is the call graph for this function:

◆ sysctl_new_kernel()

static int sysctl_new_kernel ( struct sysctl_req *  req,
void *  p,
size_t  l 
)
static

Definition at line 1994 of file kern_sysctl.c.

Referenced by kernel_sysctl(), sysctl_handle_string(), and sysctl_load_tunable_by_oid_locked().

Here is the caller graph for this function:

◆ sysctl_new_user()

static int sysctl_new_user ( struct sysctl_req *  req,
void *  p,
size_t  l 
)
static

Definition at line 2116 of file kern_sysctl.c.

Referenced by userland_sysctl().

Here is the caller graph for this function:

◆ SYSCTL_NODE() [1/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_NAME  ,
name  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_name  ,
""   
)
static

◆ SYSCTL_NODE() [2/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_NEXT  ,
next  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_next  ,
""   
)
static

◆ SYSCTL_NODE() [3/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_NEXTNOSKIP  ,
nextnoskip  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_next  ,
""   
)
static

◆ SYSCTL_NODE() [4/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_OIDDESCR  ,
oiddescr  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_oiddescr  ,
""   
)
static

◆ SYSCTL_NODE() [5/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_OIDFMT  ,
oidfmt  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_oidfmt  ,
""   
)
static

◆ SYSCTL_NODE() [6/6]

static SYSCTL_NODE ( _sysctl  ,
CTL_SYSCTL_OIDLABEL  ,
oidlabel  ,
CTLFLAG_RD|CTLFLAG_MPSAFE|  CTLFLAG_CAPRD,
sysctl_sysctl_oidlabel  ,
""   
)
static

◆ sysctl_old_kernel()

static int sysctl_old_kernel ( struct sysctl_req *  req,
const void *  p,
size_t  l 
)
static

Definition at line 1973 of file kern_sysctl.c.

Referenced by kernel_sysctl(), and sysctl_load_tunable_by_oid_locked().

Here is the caller graph for this function:

◆ sysctl_old_user()

static int sysctl_old_user ( struct sysctl_req *  req,
const void *  p,
size_t  l 
)
static

Definition at line 2078 of file kern_sysctl.c.

References copyout_nofault().

Referenced by sysctl_wire_old_buffer(), and userland_sysctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCTL_PROC()

SYSCTL_PROC ( _sysctl  ,
CTL_SYSCTL_NAME2OID  ,
name2oid  ,
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE|  CTLFLAG_CAPRW,
,
,
sysctl_sysctl_name2oid  ,
"I"  ,
""   
)

◆ sysctl_register_all()

static void sysctl_register_all ( void *  arg)
static

Definition at line 969 of file kern_sysctl.c.

References SYSCTL_INIT, sysctl_register_oid(), SYSCTL_WLOCK, SYSCTL_WUNLOCK, sysctlmemlock, and sysctlstringlock.

Here is the call graph for this function:

◆ sysctl_register_disabled_oid()

void sysctl_register_disabled_oid ( struct sysctl_oid *  oidp)

Definition at line 526 of file kern_sysctl.c.

References sysctl_register_oid().

Referenced by linker_file_register_sysctls().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_register_oid()

void sysctl_register_oid ( struct sysctl_oid *  oidp)

◆ sysctl_remove_name()

int sysctl_remove_name ( struct sysctl_oid *  parent,
const char *  name,
int  del,
int  recurse 
)

Definition at line 732 of file kern_sysctl.c.

References name, parent, sysctl_remove_oid_locked(), SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Here is the call graph for this function:

◆ sysctl_remove_oid()

int sysctl_remove_oid ( struct sysctl_oid *  oidp,
int  del,
int  recurse 
)

Definition at line 721 of file kern_sysctl.c.

References sysctl_remove_oid_locked(), SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Referenced by et_deregister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_remove_oid_locked()

static int sysctl_remove_oid_locked ( struct sysctl_oid *  oidp,
int  del,
int  recurse 
)
static

Definition at line 792 of file kern_sysctl.c.

References free(), printf(), SYSCTL_ASSERT_WLOCKED, sysctl_remove_oid_locked(), SYSCTL_SLEEP, and sysctl_unregister_oid().

Referenced by sysctl_ctx_free(), sysctl_remove_name(), sysctl_remove_oid(), and sysctl_remove_oid_locked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_rename_oid()

void sysctl_rename_oid ( struct sysctl_oid *  oidp,
const char *  name 
)

Definition at line 924 of file kern_sysctl.c.

References free(), name, SYSCTL_WLOCK, and SYSCTL_WUNLOCK.

Referenced by device_sysctl_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_root()

static int sysctl_root ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2211 of file kern_sysctl.c.

References priv_check(), securelevel_gt(), sysctl_find_oid(), SYSCTL_RLOCK, sysctl_root_handler_locked(), and SYSCTL_RUNLOCK.

Referenced by kernel_sysctl(), and userland_sysctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_root_handler_locked()

static int sysctl_root_handler_locked ( struct sysctl_oid *  oid,
void *  arg1,
intmax_t  arg2,
struct sysctl_req *  req,
struct rm_priotracker *  tracker 
)
static

Definition at line 165 of file kern_sysctl.c.

References Giant, SYSCTL_RLOCK, SYSCTL_RUNLOCK, SYSCTL_WLOCK, SYSCTL_WUNLOCK, and wakeup().

Referenced by sysctl_load_tunable_by_oid_locked(), and sysctl_root().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_search_oid()

static int sysctl_search_oid ( struct sysctl_oid **  nodes,
struct sysctl_oid *  needle 
)
static

Definition at line 351 of file kern_sysctl.c.

References sysctl__children, and SYSCTL_ASSERT_LOCKED.

Referenced by sysctl_warn_reuse().

Here is the caller graph for this function:

◆ sysctl_sec_to_timeval()

int sysctl_sec_to_timeval ( SYSCTL_HANDLER_ARGS  )

Definition at line 1949 of file kern_sysctl.c.

References sysctl_handle_int().

Here is the call graph for this function:

◆ sysctl_sysctl_name()

static int sysctl_sysctl_name ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1079 of file kern_sysctl.c.

References buf, name, snprintf(), sysctl__children, SYSCTL_RLOCK, SYSCTL_RUNLOCK, and sysctl_wire_old_buffer().

Here is the call graph for this function:

◆ sysctl_sysctl_name2oid()

static int sysctl_sysctl_name2oid ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1363 of file kern_sysctl.c.

References buf, free(), malloc(), name2oid(), SYSCTL_RLOCK, and SYSCTL_RUNLOCK.

Here is the call graph for this function:

◆ sysctl_sysctl_next()

static int sysctl_sysctl_next ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1292 of file kern_sysctl.c.

References name, sysctl__children, SYSCTL_RLOCK, SYSCTL_RUNLOCK, and sysctl_sysctl_next_action().

Here is the call graph for this function:

◆ sysctl_sysctl_next_action()

static bool sysctl_sysctl_next_action ( struct sysctl_oid_list *  lsp,
int *  name,
u_int  namelen,
int *  next,
int *  len,
int  level,
bool  honor_skip 
)
static

Definition at line 1239 of file kern_sysctl.c.

References ITER_CHILDREN, ITER_FOUND, ITER_SIBLINGS, level, name, SYSCTL_ASSERT_LOCKED, sysctl_sysctl_next_action(), and sysctl_sysctl_next_node().

Referenced by sysctl_sysctl_next(), and sysctl_sysctl_next_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_sysctl_next_node()

static enum sysctl_iter_action sysctl_sysctl_next_node ( struct sysctl_oid *  oidp,
int *  name,
unsigned int  namelen,
bool  honor_skip 
)
static

Definition at line 1159 of file kern_sysctl.c.

References ITER_CHILDREN, ITER_FOUND, ITER_SIBLINGS, and name.

Referenced by sysctl_sysctl_next_action().

Here is the caller graph for this function:

◆ sysctl_sysctl_oiddescr()

static int sysctl_sysctl_oiddescr ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1444 of file kern_sysctl.c.

References sysctl_find_oid(), SYSCTL_RLOCK, SYSCTL_RUNLOCK, and sysctl_wire_old_buffer().

Here is the call graph for this function:

◆ sysctl_sysctl_oidfmt()

static int sysctl_sysctl_oidfmt ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1412 of file kern_sysctl.c.

References sysctl_find_oid(), SYSCTL_RLOCK, SYSCTL_RUNLOCK, and sysctl_wire_old_buffer().

Here is the call graph for this function:

◆ sysctl_sysctl_oidlabel()

static int sysctl_sysctl_oidlabel ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1473 of file kern_sysctl.c.

References sysctl_find_oid(), SYSCTL_RLOCK, SYSCTL_RUNLOCK, and sysctl_wire_old_buffer().

Here is the call graph for this function:

◆ sysctl_unregister_oid()

void sysctl_unregister_oid ( struct sysctl_oid *  oidp)

Definition at line 557 of file kern_sysctl.c.

References printf(), and SYSCTL_ASSERT_WLOCKED.

Referenced by linker_file_unregister_sysctls(), sysctl_move_oid(), sysctl_remove_oid_locked(), and vfs_register().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_usec_to_sbintime()

int sysctl_usec_to_sbintime ( SYSCTL_HANDLER_ARGS  )

Definition at line 1902 of file kern_sysctl.c.

References sysctl_handle_64().

Here is the call graph for this function:

◆ sysctl_warn_reuse()

static void sysctl_warn_reuse ( const char *  func,
struct sysctl_oid *  leaf 
)
static

Definition at line 382 of file kern_sysctl.c.

References buf, sbuf_finish(), sbuf_new(), sbuf_printf(), sbuf_printf_drain(), sbuf_set_drain(), and sysctl_search_oid().

Referenced by sysctl_add_oid(), and sysctl_register_oid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sysctl_wire_old_buffer()

◆ sysctl_wlock()

void sysctl_wlock ( void  )

Definition at line 151 of file kern_sysctl.c.

References SYSCTL_WLOCK.

Referenced by linker_file_enable_sysctls(), linker_file_register_sysctls(), linker_file_unregister_sysctls(), and vfs_register().

Here is the caller graph for this function:

◆ sysctl_wunlock()

void sysctl_wunlock ( void  )

Definition at line 158 of file kern_sysctl.c.

References SYSCTL_WUNLOCK.

Referenced by linker_file_enable_sysctls(), linker_file_register_sysctls(), linker_file_unregister_sysctls(), and vfs_register().

Here is the caller graph for this function:

◆ SYSINIT()

SYSINIT ( sysctl  ,
SI_SUB_KMEM  ,
SI_ORDER_FIRST  ,
sysctl_register_all  ,
NULL   
)

◆ userland_sysctl()

int userland_sysctl ( struct thread *  td,
int *  name,
u_int  namelen,
void *  old,
size_t *  oldlenp,
int  inkernel,
const void *  new,
size_t  newlen,
size_t *  retval,
int  flags 
)

Definition at line 2415 of file kern_sysctl.c.

References flags, kern_yield(), name, sysctl_new_user(), sysctl_old_user(), sysctl_root(), and sysctlmemlock.

Referenced by kern___sysctlbyname(), and sys___sysctl().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sysctl__children

struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children)

◆ sysctllock

struct rmlock sysctllock
static

Definition at line 103 of file kern_sysctl.c.

◆ sysctlmemlock

struct sx __exclusive_cache_line sysctlmemlock
static

Definition at line 104 of file kern_sysctl.c.

Referenced by sysctl_register_all(), and userland_sysctl().

◆ sysctlstringlock

struct sx sysctlstringlock
static

Definition at line 105 of file kern_sysctl.c.

Referenced by sysctl_handle_string(), and sysctl_register_all().