xref: /freebsd/sys/cddl/dev/dtrace/dtrace_sysctl.c (revision 7029da5c36f2d3cf6bb6c81bf551229f416399e8)
191eaf3e1SJohn Birrell /*
291eaf3e1SJohn Birrell  * CDDL HEADER START
391eaf3e1SJohn Birrell  *
491eaf3e1SJohn Birrell  * The contents of this file are subject to the terms of the
591eaf3e1SJohn Birrell  * Common Development and Distribution License (the "License").
691eaf3e1SJohn Birrell  * You may not use this file except in compliance with the License.
791eaf3e1SJohn Birrell  *
891eaf3e1SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
991eaf3e1SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
1091eaf3e1SJohn Birrell  * See the License for the specific language governing permissions
1191eaf3e1SJohn Birrell  * and limitations under the License.
1291eaf3e1SJohn Birrell  *
1391eaf3e1SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
1491eaf3e1SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1591eaf3e1SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
1691eaf3e1SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
1791eaf3e1SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
1891eaf3e1SJohn Birrell  *
1991eaf3e1SJohn Birrell  * CDDL HEADER END
2091eaf3e1SJohn Birrell  *
2191eaf3e1SJohn Birrell  * $FreeBSD$
2291eaf3e1SJohn Birrell  *
2391eaf3e1SJohn Birrell  */
2491eaf3e1SJohn Birrell 
2591eaf3e1SJohn Birrell /* Report registered DTrace providers. */
2691eaf3e1SJohn Birrell static int
2791eaf3e1SJohn Birrell sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
2891eaf3e1SJohn Birrell {
2991eaf3e1SJohn Birrell 	char	*p_name	= NULL;
3091eaf3e1SJohn Birrell 	dtrace_provider_t
3191eaf3e1SJohn Birrell 		*prov	= dtrace_provider;
3291eaf3e1SJohn Birrell 	int	error	= 0;
3391eaf3e1SJohn Birrell 	size_t	len	= 0;
3491eaf3e1SJohn Birrell 
3591eaf3e1SJohn Birrell 	mutex_enter(&dtrace_provider_lock);
3691eaf3e1SJohn Birrell 	mutex_enter(&dtrace_lock);
3791eaf3e1SJohn Birrell 
3891eaf3e1SJohn Birrell 	/* Compute the length of the space-separated provider name string. */
3991eaf3e1SJohn Birrell 	while (prov != NULL) {
4091eaf3e1SJohn Birrell 		len += strlen(prov->dtpv_name) + 1;
4191eaf3e1SJohn Birrell 		prov = prov->dtpv_next;
4291eaf3e1SJohn Birrell 	}
4391eaf3e1SJohn Birrell 
4491eaf3e1SJohn Birrell 	if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
4591eaf3e1SJohn Birrell 		error = ENOMEM;
4691eaf3e1SJohn Birrell 	else {
4791eaf3e1SJohn Birrell 		/* Start with an empty string. */
4891eaf3e1SJohn Birrell 		*p_name = '\0';
4991eaf3e1SJohn Birrell 
5091eaf3e1SJohn Birrell 		/* Point to the first provider again. */
5191eaf3e1SJohn Birrell 		prov = dtrace_provider;
5291eaf3e1SJohn Birrell 
5391eaf3e1SJohn Birrell 		/* Loop through the providers, appending the names. */
5491eaf3e1SJohn Birrell 		while (prov != NULL) {
5591eaf3e1SJohn Birrell 			if (prov != dtrace_provider)
5691eaf3e1SJohn Birrell 				(void) strlcat(p_name, " ", len);
5791eaf3e1SJohn Birrell 
5891eaf3e1SJohn Birrell 			(void) strlcat(p_name, prov->dtpv_name, len);
5991eaf3e1SJohn Birrell 
6091eaf3e1SJohn Birrell 			prov = prov->dtpv_next;
6191eaf3e1SJohn Birrell 		}
6291eaf3e1SJohn Birrell 	}
6391eaf3e1SJohn Birrell 
6491eaf3e1SJohn Birrell 	mutex_exit(&dtrace_lock);
6591eaf3e1SJohn Birrell 	mutex_exit(&dtrace_provider_lock);
6691eaf3e1SJohn Birrell 
6791eaf3e1SJohn Birrell 	if (p_name != NULL) {
6891eaf3e1SJohn Birrell 		error = sysctl_handle_string(oidp, p_name, len, req);
6991eaf3e1SJohn Birrell 
7091eaf3e1SJohn Birrell 		kmem_free(p_name, 0);
7191eaf3e1SJohn Birrell 	}
7291eaf3e1SJohn Birrell 
7391eaf3e1SJohn Birrell 	return (error);
7491eaf3e1SJohn Birrell }
7591eaf3e1SJohn Birrell 
76*7029da5cSPawel Biernacki SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
77*7029da5cSPawel Biernacki     "DTrace debug parameters");
78cd8bbc38SMark Johnston 
79638af813SMateusz Guzik SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers,
80638af813SMateusz Guzik     CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers,
81638af813SMateusz Guzik     "A", "available DTrace providers");
8291eaf3e1SJohn Birrell 
83*7029da5cSPawel Biernacki SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
84*7029da5cSPawel Biernacki     "DTrace parameters");
85b53bfbbaSMark Johnston 
86cd8bbc38SMark Johnston SYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW,
87cd8bbc38SMark Johnston     &dtrace_err_verbose, 0,
88cd8bbc38SMark Johnston     "print DIF and DOF validation errors to the message buffer");
89cd8bbc38SMark Johnston 
90b53bfbbaSMark Johnston SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max,
91e572bc11SMark Johnston     0, "largest allowed argument to memstr(), 0 indicates no limit");
92b53bfbbaSMark Johnston 
93f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
94b53bfbbaSMark Johnston     &dtrace_dof_maxsize, 0, "largest allowed DOF table");
95b53bfbbaSMark Johnston 
96f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
97b53bfbbaSMark Johnston     &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
98cdaa8777SGeorge V. Neville-Neil 
99cdaa8777SGeorge V. Neville-Neil SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,
100cdaa8777SGeorge V. Neville-Neil     &dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");
101