From ae12603a54610248b25dd74cf2d544c0a9d741fa Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Mon, 14 Jan 2019 18:59:58 +0100 Subject: [PATCH] kernel: Hide the sysctl.debug sysctl in the SYSCTL_DEBUG kernel option. The output is quite excessive and was previously too easily triggered, like with "sysctl name=value" (instead of just "name=value") in /etc/sysctl.conf. Taken-from: FreeBSD --- sys/conf/options | 3 +++ sys/config/LINT64 | 8 ++++++++ sys/kern/kern_sysctl.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/sys/conf/options b/sys/conf/options index 2a8228d7fd..75c7b63a5d 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -673,6 +673,9 @@ PANIC_REBOOT_WAIT_TIME opt_panic.h EVDEV_SUPPORT opt_evdev.h EVDEV_DEBUG opt_evdev.h +# Sysctl debugging +SYSCTL_DEBUG opt_sysctl.h + # Obsolete options (will be removed in the future) # FAST_IPSEC opt_dontuse.h diff --git a/sys/config/LINT64 b/sys/config/LINT64 index 51a6184914..c1db0db7ea 100644 --- a/sys/config/LINT64 +++ b/sys/config/LINT64 @@ -199,6 +199,14 @@ options INVARIANTS # options DIAGNOSTIC +# +# SYSCTL_DEBUG enables a 'sysctl' debug tree that can be used to dump the +# contents of the registered sysctl nodes on the console. It is disabled by +# default because it generates excessively verbose console output that can +# interfere with serial console operation. +# +options SYSCTL_DEBUG + # # This option let some drivers co-exist that can't co-exist in a running # system. This is used to be able to compile all kernel code in one go for diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index da0692ffc3..6d261003e0 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -51,6 +51,8 @@ #include #include +#include "opt_sysctl.h" + static MALLOC_DEFINE(M_SYSCTL, "sysctl", "sysctl internal magic"); static MALLOC_DEFINE(M_SYSCTLOID, "sysctloid", "sysctl dynamic oids"); @@ -524,6 +526,7 @@ sysctl_register_all(void *arg) } SYSINIT(sysctl, SI_BOOT1_POST, SI_ORDER_ANY, sysctl_register_all, 0); +#ifdef SYSCTL_DEBUG /* * "Staff-functions" * @@ -605,6 +608,7 @@ sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_sysctl, 0, debug, CTLTYPE_STRING | CTLFLAG_RD, 0, 0, sysctl_sysctl_debug, "-", ""); +#endif /* SYSCTL_DEBUG */ static int sysctl_sysctl_name(SYSCTL_HANDLER_ARGS) -- 2.41.0