Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/sysctl.h
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ | #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ | ||||
#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ | #define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ | ||||
#define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ | #define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ | ||||
#define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ | #define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ | ||||
#define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ | #define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ | ||||
#define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ | #define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ | ||||
#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ | #define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ | ||||
#define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) | #define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) | ||||
/* | |||||
* This is transient flag to be used until all sysctl handlers are converted | |||||
* to not lock Giant. | |||||
* One, and only one of CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT is required | |||||
* for SYSCTL_PROC and SYSCTL_NODE. | |||||
*/ | |||||
#define CTLFLAG_NEEDGIANT 0x00000800 /* Handler require Giant */ | |||||
/* | /* | ||||
* Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. | * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. | ||||
* | * | ||||
* Secure when the securelevel is raised to at least N. | * Secure when the securelevel is raised to at least N. | ||||
*/ | */ | ||||
#define CTLSHIFT_SECURE 20 | #define CTLSHIFT_SECURE 20 | ||||
#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) | #define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | #define SYSCTL_NODE_CHILDREN(parent, name) \ | ||||
sysctl__##parent##_##name.oid_children | sysctl__##parent##_##name.oid_children | ||||
#ifndef NO_SYSCTL_DESCR | #ifndef NO_SYSCTL_DESCR | ||||
#define __DESCR(d) d | #define __DESCR(d) d | ||||
#else | #else | ||||
#define __DESCR(d) "" | #define __DESCR(d) "" | ||||
#endif | #endif | ||||
#ifdef notyet | |||||
#define SYSCTL_ENFORCE_FLAGS(x) \ | |||||
_Static_assert(((CTLFLAG_MPSAFE ^ CTLFLAG_NEEDGIANT) & (x)), \ | |||||
"Has to be either CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT") | |||||
#else | |||||
#define SYSCTL_ENFORCE_FLAGS(x) | |||||
#endif | |||||
/* This macro is only for internal use */ | /* This macro is only for internal use */ | ||||
#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | #define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | ||||
struct sysctl_oid id = { \ | struct sysctl_oid id = { \ | ||||
.oid_parent = (parent_child_head), \ | .oid_parent = (parent_child_head), \ | ||||
.oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ | .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ | ||||
.oid_number = (nbr), \ | .oid_number = (nbr), \ | ||||
.oid_kind = (kind), \ | .oid_kind = (kind), \ | ||||
.oid_arg1 = (a1), \ | .oid_arg1 = (a1), \ | ||||
.oid_arg2 = (a2), \ | .oid_arg2 = (a2), \ | ||||
.oid_name = (name), \ | .oid_name = (name), \ | ||||
.oid_handler = (handler), \ | .oid_handler = (handler), \ | ||||
.oid_fmt = (fmt), \ | .oid_fmt = (fmt), \ | ||||
.oid_descr = __DESCR(descr), \ | .oid_descr = __DESCR(descr), \ | ||||
.oid_label = (label), \ | .oid_label = (label), \ | ||||
}; \ | }; \ | ||||
DATA_SET(sysctl_set, id) | DATA_SET(sysctl_set, id); \ | ||||
SYSCTL_ENFORCE_FLAGS(kind) | |||||
/* This constructs a static "raw" MIB oid. */ | /* This constructs a static "raw" MIB oid. */ | ||||
#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | ||||
SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, \ | SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, \ | ||||
handler, fmt, descr, NULL) | handler, fmt, descr, NULL) | ||||
#define SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | #define SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | ||||
static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ | static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ | ||||
SYSCTL_CHILDREN(&sysctl__##parent), \ | SYSCTL_CHILDREN(&sysctl__##parent), \ | ||||
nbr, #name, kind, a1, a2, handler, fmt, descr, label) | nbr, #name, kind, a1, a2, handler, fmt, descr, label) | ||||
/* This constructs a global "raw" MIB oid. */ | /* This constructs a global "raw" MIB oid. */ | ||||
#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | #define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ | ||||
SYSCTL_OID_RAW(sysctl__##parent##_##name, \ | SYSCTL_OID_RAW(sysctl__##parent##_##name, \ | ||||
SYSCTL_CHILDREN(&sysctl__##parent), \ | SYSCTL_CHILDREN(&sysctl__##parent), \ | ||||
nbr, #name, kind, a1, a2, handler, fmt, descr, label) | nbr, #name, kind, a1, a2, handler, fmt, descr, label) | ||||
#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr), NULL) | ({ \ | ||||
SYSCTL_ENFORCE_FLAGS(kind); \ | |||||
sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2,handler, \ | |||||
fmt, __DESCR(descr), NULL); \ | |||||
}) | |||||
/* This constructs a root node from which other nodes can hang. */ | /* This constructs a root node from which other nodes can hang. */ | ||||
#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ | #define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ | ||||
SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ | SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ | ||||
nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ | nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ | ||||
handler, "N", descr, NULL); \ | handler, "N", descr, NULL); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) | ||||
Show All 11 Lines | |||||
#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ | #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ | ||||
SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, \ | SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, \ | ||||
handler, descr, NULL) | handler, descr, NULL) | ||||
#define SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, handler, descr, label) \ | #define SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, handler, descr, label) \ | ||||
({ \ | ({ \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ | ||||
SYSCTL_ENFORCE_FLAGS(access); \ | |||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ | sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ | ||||
NULL, 0, handler, "N", __DESCR(descr), label); \ | NULL, 0, handler, "N", __DESCR(descr), label); \ | ||||
}) | }) | ||||
#define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ | #define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ | ||||
({ \ | ({ \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ | ||||
SYSCTL_ENFORCE_FLAGS(access); \ | |||||
sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ | sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ | ||||
CTLTYPE_NODE|(access), \ | CTLTYPE_NODE|(access), \ | ||||
NULL, 0, handler, "N", __DESCR(descr), NULL); \ | NULL, 0, handler, "N", __DESCR(descr), NULL); \ | ||||
}) | }) | ||||
/* Oid for a string. len can be 0 to indicate '\0' termination. */ | /* Oid for a string. len can be 0 to indicate '\0' termination. */ | ||||
#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ | SYSCTL_OID(parent, nbr, name, \ | ||||
CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), \ | |||||
arg, len, sysctl_handle_string, "A", descr); \ | arg, len, sysctl_handle_string, "A", descr); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) | ||||
#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ | #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ | ||||
({ \ | ({ \ | ||||
char *__arg = (arg); \ | char *__arg = (arg); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ | sysctl_add_oid(ctx, parent, nbr, name, \ | ||||
CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), \ | |||||
__arg, len, sysctl_handle_string, "A", __DESCR(descr), \ | __arg, len, sysctl_handle_string, "A", __DESCR(descr), \ | ||||
NULL); \ | NULL); \ | ||||
}) | }) | ||||
/* Oid for a constant '\0' terminated string. */ | /* Oid for a constant '\0' terminated string. */ | ||||
#define SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr) \ | #define SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\ | SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\ | ||||
__DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \ | __DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \ | ||||
▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | ({ \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, \ | sysctl_add_oid(ctx, parent, nbr, name, \ | ||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ | ||||
__ptr, len, sysctl_handle_counter_u64_array, "S", \ | __ptr, len, sysctl_handle_counter_u64_array, "S", \ | ||||
__DESCR(descr), NULL); \ | __DESCR(descr), NULL); \ | ||||
}) | }) | ||||
/* Oid for an opaque object. Specified by a pointer and a length. */ | /* Oid for an opaque object. Specified by a pointer and a length. */ | ||||
#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ | #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ | SYSCTL_OID(parent, nbr, name, \ | ||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ | |||||
ptr, len, sysctl_handle_opaque, fmt, descr); \ | ptr, len, sysctl_handle_opaque, fmt, descr); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) | ||||
#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ | #define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ | ||||
({ \ | ({ \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ | sysctl_add_oid(ctx, parent, nbr, name, \ | ||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ | |||||
ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr), NULL); \ | ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr), NULL); \ | ||||
}) | }) | ||||
/* Oid for a struct. Specified by a pointer and a type. */ | /* Oid for a struct. Specified by a pointer and a type. */ | ||||
#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ | #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ | SYSCTL_OID(parent, nbr, name, \ | ||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ | |||||
ptr, sizeof(struct type), sysctl_handle_opaque, \ | ptr, sizeof(struct type), sysctl_handle_opaque, \ | ||||
"S," #type, descr); \ | "S," #type, descr); \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) | ||||
#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ | #define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ | ||||
({ \ | ({ \ | ||||
CTASSERT(((access) & CTLTYPE) == 0 || \ | CTASSERT(((access) & CTLTYPE) == 0 || \ | ||||
((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ | ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ | ||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ | sysctl_add_oid(ctx, parent, nbr, name, \ | ||||
CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ | |||||
(ptr), sizeof(struct type), \ | (ptr), sizeof(struct type), \ | ||||
sysctl_handle_opaque, "S," #type, __DESCR(descr), NULL); \ | sysctl_handle_opaque, "S," #type, __DESCR(descr), NULL); \ | ||||
}) | }) | ||||
/* Oid for a procedure. Specified by a pointer and an arg. */ | /* Oid for a procedure. Specified by a pointer and an arg. */ | ||||
#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, (access), \ | SYSCTL_OID(parent, nbr, name, (access), \ | ||||
ptr, arg, handler, fmt, descr); \ | ptr, arg, handler, fmt, descr); \ | ||||
CTASSERT(((access) & CTLTYPE) != 0) | CTASSERT(((access) & CTLTYPE) != 0) | ||||
#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | #define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | ||||
({ \ | ({ \ | ||||
CTASSERT(((access) & CTLTYPE) != 0); \ | CTASSERT(((access) & CTLTYPE) != 0); \ | ||||
SYSCTL_ENFORCE_FLAGS(access); \ | |||||
sysctl_add_oid(ctx, parent, nbr, name, (access), \ | sysctl_add_oid(ctx, parent, nbr, name, (access), \ | ||||
(ptr), (arg), (handler), (fmt), __DESCR(descr), NULL); \ | (ptr), (arg), (handler), (fmt), __DESCR(descr), NULL); \ | ||||
}) | }) | ||||
/* Oid to handle limits on uma(9) zone specified by pointer. */ | /* Oid to handle limits on uma(9) zone specified by pointer. */ | ||||
#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ | #define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ | ||||
SYSCTL_OID(parent, nbr, name, \ | SYSCTL_OID(parent, nbr, name, \ | ||||
CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ | CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ | ||||
▲ Show 20 Lines • Show All 370 Lines • Show Last 20 Lines |