Print this page
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-49 Codenomicon error with SMB echo
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb_echo.c
+++ new/usr/src/uts/common/fs/smbsrv/smb_echo.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 *
25 - * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
26 26 */
27 27
28 28 #include <smbsrv/smb_kproto.h>
29 29
30 30 /*
31 31 * The echo request is used to test the connection to the server,
32 32 * and to see if the server is still responding. The tid is ignored,
33 33 * so this request may be sent to the server even if there are no
34 34 * tree connections to the server.
35 35 *
36 36 * Each response echoes the data sent, though ByteCount may indicate
37 37 * no data. If echo-count is zero, no response is sent.
38 38 */
39 39 smb_sdrc_t
40 40 smb_pre_echo(smb_request_t *sr)
41 41 {
42 - DTRACE_SMB_1(op__Echo__start, smb_request_t *, sr);
42 + DTRACE_SMB_START(op__Echo, smb_request_t *, sr);
43 43 return (SDRC_SUCCESS);
44 44 }
45 45
46 46 void
47 47 smb_post_echo(smb_request_t *sr)
48 48 {
49 - DTRACE_SMB_1(op__Echo__done, smb_request_t *, sr);
49 + DTRACE_SMB_DONE(op__Echo, smb_request_t *, sr);
50 50 }
51 51
52 52 static unsigned short smb_max_echo = 10;
53 53
54 54 smb_sdrc_t
55 55 smb_com_echo(struct smb_request *sr)
56 56 {
57 57 unsigned short necho;
58 58 unsigned short nbytes;
59 59 unsigned short i;
60 60 struct mbuf_chain reply;
61 61 char *data;
62 62 uint16_t pid_hi, pid_lo;
63 63
64 64 pid_hi = sr->smb_pid >> 16;
65 65 pid_lo = (uint16_t)sr->smb_pid;
66 66
67 67 if (smbsr_decode_vwv(sr, "w", &necho) != 0)
68 68 return (SDRC_ERROR);
69 69
70 70 /*
71 71 * Don't let the client fool us into doing
72 72 * more work than is "reasonable".
73 73 */
74 74 if (necho > smb_max_echo)
75 75 necho = smb_max_echo;
76 76
77 77 nbytes = sr->smb_bcc;
78 78 data = smb_srm_zalloc(sr, nbytes);
79 79
80 80 if (smb_mbc_decodef(&sr->smb_data, "#c", nbytes, data))
81 81 return (SDRC_ERROR);
82 82
83 83 for (i = 1; i <= necho; ++i) {
84 84
85 85 /*
86 86 * According to [MS-CIFS] 3.3.5.32 echo is
87 87 * subject to cancellation.
88 88 */
89 89 if (sr->sr_state != SMB_REQ_STATE_ACTIVE)
90 90 break;
91 91
92 92 MBC_INIT(&reply, SMB_HEADER_ED_LEN + 10 + nbytes);
93 93
94 94 (void) smb_mbc_encodef(&reply, SMB_HEADER_ED_FMT,
95 95 sr->first_smb_com,
96 96 sr->smb_rcls,
97 97 sr->smb_reh,
98 98 sr->smb_err,
99 99 sr->smb_flg | SMB_FLAGS_REPLY,
100 100 sr->smb_flg2,
101 101 pid_hi,
102 102 sr->smb_sig,
103 103 sr->smb_tid,
104 104 pid_lo,
105 105 sr->smb_uid,
106 106 sr->smb_mid);
107 107
108 108 (void) smb_mbc_encodef(&reply, "bww#c", 1, i,
109 109 nbytes, nbytes, data);
110 110
111 111 if (sr->session->signing.flags & SMB_SIGNING_ENABLED)
112 112 smb_sign_reply(sr, &reply);
113 113
114 114 (void) smb_session_send(sr->session, 0, &reply);
115 115
116 116 delay(MSEC_TO_TICK(100));
117 117 }
118 118
119 119 return (SDRC_NO_REPLY);
120 120 }
|
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX