xref: /illumos-gate/usr/src/cmd/smbsrv/dtrace/smbd-authsvc.d (revision ed81dd52230eff1a7c7625caad21af232c36f6cb)
1*ed81dd52SAlek Pinchuk #!/usr/sbin/dtrace -s
2*ed81dd52SAlek Pinchuk /*
3*ed81dd52SAlek Pinchuk  * This file and its contents are supplied under the terms of the
4*ed81dd52SAlek Pinchuk  * Common Development and Distribution License ("CDDL"), version 1.0.
5*ed81dd52SAlek Pinchuk  * You may only use this file in accordance with the terms of version
6*ed81dd52SAlek Pinchuk  * 1.0 of the CDDL.
7*ed81dd52SAlek Pinchuk  *
8*ed81dd52SAlek Pinchuk  * A full copy of the text of the CDDL should have accompanied this
9*ed81dd52SAlek Pinchuk  * source.  A copy of the CDDL is also available via the Internet at
10*ed81dd52SAlek Pinchuk  * http://www.illumos.org/license/CDDL.
11*ed81dd52SAlek Pinchuk  */
12*ed81dd52SAlek Pinchuk 
13*ed81dd52SAlek Pinchuk /*
14*ed81dd52SAlek Pinchuk  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
15*ed81dd52SAlek Pinchuk  */
16*ed81dd52SAlek Pinchuk 
17*ed81dd52SAlek Pinchuk /*
18*ed81dd52SAlek Pinchuk  * User-level dtrace for the smbd authentication service
19*ed81dd52SAlek Pinchuk  * Usage: dtrace -s smbd-authsvc.d -p `pgrep smbd`
20*ed81dd52SAlek Pinchuk  */
21*ed81dd52SAlek Pinchuk 
22*ed81dd52SAlek Pinchuk #pragma D option flowindent
23*ed81dd52SAlek Pinchuk 
24*ed81dd52SAlek Pinchuk self int trace;
25*ed81dd52SAlek Pinchuk self int mask;
26*ed81dd52SAlek Pinchuk 
27*ed81dd52SAlek Pinchuk /*
28*ed81dd52SAlek Pinchuk  * The smbd_authsvc_work() function is a good place to start tracing
29*ed81dd52SAlek Pinchuk  * to watch authentication.  This function executes all the actions
30*ed81dd52SAlek Pinchuk  * associated with a single session setup conversation (even though
31*ed81dd52SAlek Pinchuk  * that conversation will usually involve multiple SMB requests).
32*ed81dd52SAlek Pinchuk  */
33*ed81dd52SAlek Pinchuk pid$target:*smbd:smbd_authsvc_work:entry
34*ed81dd52SAlek Pinchuk {
35*ed81dd52SAlek Pinchuk 	self->trace++;
36*ed81dd52SAlek Pinchuk }
37*ed81dd52SAlek Pinchuk 
38*ed81dd52SAlek Pinchuk /*
39*ed81dd52SAlek Pinchuk  * If traced and not masked, print entry/return
40*ed81dd52SAlek Pinchuk  */
41*ed81dd52SAlek Pinchuk pid$target:*smbd::entry,
42*ed81dd52SAlek Pinchuk pid$target:libmlsvc.so.1::entry,
43*ed81dd52SAlek Pinchuk pid$target:libmlrpc.so.1::entry,
44*ed81dd52SAlek Pinchuk pid$target:libsmbns.so.1::entry,
45*ed81dd52SAlek Pinchuk pid$target:libsmb.so.1::entry,
46*ed81dd52SAlek Pinchuk pid$target:libsmbfs.so.1::entry
47*ed81dd52SAlek Pinchuk /self->trace > 0 && self->mask == 0/
48*ed81dd52SAlek Pinchuk {
49*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg0);
50*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg1);
51*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg2);
52*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg3);
53*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg4);
54*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg5);
55*ed81dd52SAlek Pinchuk }
56*ed81dd52SAlek Pinchuk 
57*ed81dd52SAlek Pinchuk /*
58*ed81dd52SAlek Pinchuk  * Mask (don't print) all function calls below these functions.
59*ed81dd52SAlek Pinchuk  * These make many boring, repetitive function calls like
60*ed81dd52SAlek Pinchuk  * smb_mbtowc, smb_msgbuf_has_space, ...
61*ed81dd52SAlek Pinchuk  *
62*ed81dd52SAlek Pinchuk  * Also, libmlrpc has rather deep call stacks, particularly under
63*ed81dd52SAlek Pinchuk  * ndr_encode_decode_common(), so this stops traces below there.
64*ed81dd52SAlek Pinchuk  * Remove that from the mask actions to see the details.
65*ed81dd52SAlek Pinchuk  */
66*ed81dd52SAlek Pinchuk pid$target::ndr_encode_decode_common:entry,
67*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_decode:entry,
68*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_encode:entry,
69*ed81dd52SAlek Pinchuk pid$target::smb_strlwr:entry,
70*ed81dd52SAlek Pinchuk pid$target::smb_strupr:entry,
71*ed81dd52SAlek Pinchuk pid$target::smb_wcequiv_strlen:entry
72*ed81dd52SAlek Pinchuk {
73*ed81dd52SAlek Pinchuk 	self->mask++;
74*ed81dd52SAlek Pinchuk }
75*ed81dd52SAlek Pinchuk 
76*ed81dd52SAlek Pinchuk /*
77*ed81dd52SAlek Pinchuk  * Now inverses of above, unwind order.
78*ed81dd52SAlek Pinchuk  */
79*ed81dd52SAlek Pinchuk 
80*ed81dd52SAlek Pinchuk pid$target::ndr_encode_decode_common:return,
81*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_decode:return,
82*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_encode:return,
83*ed81dd52SAlek Pinchuk pid$target::smb_strlwr:return,
84*ed81dd52SAlek Pinchuk pid$target::smb_strupr:return,
85*ed81dd52SAlek Pinchuk pid$target::smb_wcequiv_strlen:return
86*ed81dd52SAlek Pinchuk {
87*ed81dd52SAlek Pinchuk 	self->mask--;
88*ed81dd52SAlek Pinchuk }
89*ed81dd52SAlek Pinchuk 
90*ed81dd52SAlek Pinchuk pid$target:*smbd::return,
91*ed81dd52SAlek Pinchuk pid$target:libmlsvc.so.1::return,
92*ed81dd52SAlek Pinchuk pid$target:libmlrpc.so.1::return,
93*ed81dd52SAlek Pinchuk pid$target:libsmbns.so.1::return,
94*ed81dd52SAlek Pinchuk pid$target:libsmb.so.1::return,
95*ed81dd52SAlek Pinchuk pid$target:libsmbfs.so.1::return
96*ed81dd52SAlek Pinchuk /self->trace > 0 && self->mask == 0/
97*ed81dd52SAlek Pinchuk {
98*ed81dd52SAlek Pinchuk 	printf("\t0x%x", arg1);
99*ed81dd52SAlek Pinchuk }
100*ed81dd52SAlek Pinchuk 
101*ed81dd52SAlek Pinchuk pid$target:*smbd:smbd_authsvc_work:return
102*ed81dd52SAlek Pinchuk {
103*ed81dd52SAlek Pinchuk 	self->trace--;
104*ed81dd52SAlek Pinchuk }
105