aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2009-03-11 21:48:36 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2009-03-11 21:48:36 +0000
commita56be37e68ba06161b1b8258b19bd019aff9544b (patch)
tree48083c4fab749cb8da99377a83f7d470672d4c2c /sys/kern/kern_sysctl.c
parenta9d9537110686054ec6c7a469f976c5b2c7fd51a (diff)
downloadsrc-a56be37e68ba06161b1b8258b19bd019aff9544b.tar.gz
src-a56be37e68ba06161b1b8258b19bd019aff9544b.zip
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
Notes
Notes: svn path=/head/; revision=189707
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 1d283dfa5307..d39db26ea124 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));