summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-03-11 21:48:36 +0000
committerjhb <jhb@FreeBSD.org>2009-03-11 21:48:36 +0000
commit2548f05c6c8be3fe53f4191e634699bb4fa4c56b (patch)
tree48083c4fab749cb8da99377a83f7d470672d4c2c /sys/kern/kern_sysctl.c
parentde74558fd8fae07358ec61b9001d0a7590bb9d22 (diff)
downloadFreeBSD-src-2548f05c6c8be3fe53f4191e634699bb4fa4c56b.zip
FreeBSD-src-2548f05c6c8be3fe53f4191e634699bb4fa4c56b.tar.gz
Add a new type of KTRACE record for sysctl(3) invocations. It uses the
internal sysctl_sysctl_name() handler to map the MIB array to a string name and logs this name in the trace log. This can be useful to see exactly which sysctls a thread is invoking. MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 1d283df..d39db26 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -39,6 +39,7 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
+#include "opt_ktrace.h"
#include "opt_mac.h"
#include <sys/param.h>
@@ -54,6 +55,9 @@ __FBSDID("$FreeBSD$");
#include <sys/sysproto.h>
#include <sys/uio.h>
#include <sys/vimage.h>
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
#include <security/mac/mac_framework.h>
@@ -758,7 +762,7 @@ sysctl_sysctl_next(SYSCTL_HANDLER_ARGS)
static SYSCTL_NODE(_sysctl, 2, next, CTLFLAG_RD, sysctl_sysctl_next, "");
static int
-name2oid (char *name, int *oid, int *len, struct sysctl_oid **oidpp)
+name2oid(char *name, int *oid, int *len, struct sysctl_oid **oidpp)
{
int i;
struct sysctl_oid *oidp;
@@ -1499,6 +1503,11 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
req.newfunc = sysctl_new_user;
req.lock = REQ_LOCKED;
+#ifdef KTRACE
+ if (KTRPOINT(curthread, KTR_SYSCTL))
+ ktrsysctl(name, namelen);
+#endif
+
SYSCTL_XLOCK();
CURVNET_SET(TD_TO_VNET(curthread));
OpenPOWER on IntegriCloud