Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sysctl.c
Show First 20 Lines • Show All 485 Lines • ▼ Show 20 Lines | retry: | ||||
/* check for non-auto OID number collision */ | /* check for non-auto OID number collision */ | ||||
if (oidp->oid_number >= 0 && oidp->oid_number < CTL_AUTO_START && | if (oidp->oid_number >= 0 && oidp->oid_number < CTL_AUTO_START && | ||||
oid_number >= CTL_AUTO_START) { | oid_number >= CTL_AUTO_START) { | ||||
printf("sysctl: OID number(%d) is already in use for '%s'\n", | printf("sysctl: OID number(%d) is already in use for '%s'\n", | ||||
oidp->oid_number, oidp->oid_name); | oidp->oid_number, oidp->oid_name); | ||||
} | } | ||||
/* update the OID number, if any */ | /* update the OID number, if any */ | ||||
oidp->oid_number = oid_number; | oidp->oid_number = oid_number; | ||||
if (q != NULL) | if (q != NULL) | ||||
hselasky: Just a question about code factoring. Why is not CTLFLAG_DORMANT set by the wrapper before… | |||||
Not Done Inline ActionsThat's a very good suggestion, I will implement it. avg: That's a very good suggestion, I will implement it. | |||||
SLIST_INSERT_AFTER(q, oidp, oid_link); | SLIST_INSERT_AFTER(q, oidp, oid_link); | ||||
else | else | ||||
SLIST_INSERT_HEAD(parent, oidp, oid_link); | SLIST_INSERT_HEAD(parent, oidp, oid_link); | ||||
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE && | if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE && | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
(oidp->oid_kind & CTLFLAG_VNET) == 0 && | (oidp->oid_kind & CTLFLAG_VNET) == 0 && | ||||
#endif | #endif | ||||
(oidp->oid_kind & CTLFLAG_TUN) != 0 && | (oidp->oid_kind & CTLFLAG_TUN) != 0 && | ||||
(oidp->oid_kind & CTLFLAG_NOFETCH) == 0) { | (oidp->oid_kind & CTLFLAG_NOFETCH) == 0) { | ||||
/* only fetch value once */ | /* only fetch value once */ | ||||
oidp->oid_kind |= CTLFLAG_NOFETCH; | oidp->oid_kind |= CTLFLAG_NOFETCH; | ||||
/* try to fetch value from kernel environment */ | /* try to fetch value from kernel environment */ | ||||
sysctl_load_tunable_by_oid_locked(oidp); | sysctl_load_tunable_by_oid_locked(oidp); | ||||
} | } | ||||
} | } | ||||
void | void | ||||
sysctl_register_disabled_oid(struct sysctl_oid *oidp) | |||||
{ | |||||
/* | |||||
* Mark the leaf as dormant if it's not to be immediately enabled. | |||||
* We do not disable nodes as they can be shared between modules | |||||
* and it is always safe to access a node. | |||||
*/ | |||||
KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, | |||||
("internal flag is set in oid_kind")); | |||||
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE) | |||||
oidp->oid_kind |= CTLFLAG_DORMANT; | |||||
sysctl_register_oid(oidp); | |||||
} | |||||
Not Done Inline ActionsIt might make sense to have: sysctl_disable_oid() and use that to disable oid before calling sysctl_register_oid_impl() --HPS hselasky: It might make sense to have:
sysctl_disable_oid() and use that to disable oid before calling… | |||||
Not Done Inline ActionsYes, that might make sense, thank you for the suggestion. avg: Yes, that might make sense, thank you for the suggestion.
But I am somewhat reluctant to… | |||||
Not Done Inline ActionsSure. hselasky: Sure. | |||||
void | |||||
sysctl_enable_oid(struct sysctl_oid *oidp) | |||||
{ | |||||
SYSCTL_ASSERT_WLOCKED(); | |||||
if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { | |||||
KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) == 0, | |||||
("sysctl node is marked as dormant")); | |||||
return; | |||||
} | |||||
KASSERT((oidp->oid_kind & CTLFLAG_DORMANT) != 0, | |||||
("enabling already enabled sysctl oid")); | |||||
oidp->oid_kind &= ~CTLFLAG_DORMANT; | |||||
} | |||||
void | |||||
sysctl_unregister_oid(struct sysctl_oid *oidp) | sysctl_unregister_oid(struct sysctl_oid *oidp) | ||||
{ | { | ||||
struct sysctl_oid *p; | struct sysctl_oid *p; | ||||
int error; | int error; | ||||
SYSCTL_ASSERT_WLOCKED(); | SYSCTL_ASSERT_WLOCKED(); | ||||
error = ENOENT; | error = ENOENT; | ||||
if (oidp->oid_number == OID_AUTO) { | if (oidp->oid_number == OID_AUTO) { | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | sysctl_sysctl_next_ls(struct sysctl_oid_list *lsp, int *name, u_int namelen, | ||||
struct sysctl_oid *oidp; | struct sysctl_oid *oidp; | ||||
SYSCTL_ASSERT_LOCKED(); | SYSCTL_ASSERT_LOCKED(); | ||||
*len = level; | *len = level; | ||||
SLIST_FOREACH(oidp, lsp, oid_link) { | SLIST_FOREACH(oidp, lsp, oid_link) { | ||||
*next = oidp->oid_number; | *next = oidp->oid_number; | ||||
*oidpp = oidp; | *oidpp = oidp; | ||||
if (oidp->oid_kind & CTLFLAG_SKIP) | if ((oidp->oid_kind & (CTLFLAG_SKIP | CTLFLAG_DORMANT)) != 0) | ||||
continue; | continue; | ||||
if (!namelen) { | if (!namelen) { | ||||
if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE) | if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE) | ||||
return (0); | return (0); | ||||
if (oidp->oid_handler) | if (oidp->oid_handler) | ||||
/* We really should call the handler here...*/ | /* We really should call the handler here...*/ | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 804 Lines • ▼ Show 20 Lines | if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) { | ||||
if (nindx != NULL) | if (nindx != NULL) | ||||
*nindx = indx; | *nindx = indx; | ||||
KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0, | KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0, | ||||
("%s found DYING node %p", __func__, oid)); | ("%s found DYING node %p", __func__, oid)); | ||||
return (0); | return (0); | ||||
} | } | ||||
lsp = SYSCTL_CHILDREN(oid); | lsp = SYSCTL_CHILDREN(oid); | ||||
} else if (indx == namelen) { | } else if (indx == namelen) { | ||||
if ((oid->oid_kind & CTLFLAG_DORMANT) != 0) | |||||
return (ENOENT); | |||||
*noid = oid; | *noid = oid; | ||||
if (nindx != NULL) | if (nindx != NULL) | ||||
*nindx = indx; | *nindx = indx; | ||||
KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0, | KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0, | ||||
("%s found DYING node %p", __func__, oid)); | ("%s found DYING node %p", __func__, oid)); | ||||
return (0); | return (0); | ||||
} else { | } else { | ||||
return (ENOTDIR); | return (ENOTDIR); | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |
Just a question about code factoring. Why is not CTLFLAG_DORMANT set by the wrapper before calling this function? Would save passing in "enable" argument to this function?