Print this page
NEX-4856 SMB2 kstats don't correctly count compound requests
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15578 SMB2 durable handle redesign
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15555 SMB2 async redesign
NEX-15061 smtorture smb2.lock.cancel.cancel is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Also follow-up change to:
NEX-1643 dtrace provider for smbsrv (remove "done2" probes,
which don't make sense with the new async design)
NEX-15578 SMB2 durable handle redesign
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15555 SMB2 async redesign
NEX-15061 smtorture smb2.lock.cancel.cancel is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Also follow-up change to:
NEX-1643 dtrace provider for smbsrv (remove "done2" probes,
which don't make sense with the new async design)
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-10229 SMB v1 response incorrect when signature verification fails
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-9864 Some SMB cancel races remain after NEX-5845
Revert (part of) "NEX-5845 rework SMB immediate cancel"
reverts (part of) commit 7a5da69f6d42b17ebcc95ca3d02925d07a01343e.
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5845 rework SMB immediate cancel
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-5152 immediate SMB cancel may fail
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-5175 want SMB statistics separately for reads, writes, other
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-4313 want iops, bandwidth, and latency kstats for smb
Portions contributed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-4391 improve smb cancel support
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-4147 Cancelled SMB2 requests sometimes have no response (missed things)
NEX-3611 CLONE NEX-3550 Replace smb2_enable with max_protocol
Reviewed by: Yuri Pankov <Yuri.Pankov@nexenta.com>
NEX-2370 unable to save/modify files (zip,notepad,excel) on CIFS share from Windows 7
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-69 read-raw, write-raw are dead code
SMB-39 Use AF_UNIX pipes for RPC
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
SMB-65 SMB server in non-global zones (use zone_kcred())
SMB-65 SMB server in non-global zones (data structure changes)
Many things move to the smb_server_t object, and
many functions gain an sv arg (which server).
SMB-63 taskq_create_proc ... TQ_DYNAMIC puts tasks in p0
re #11974 CIFS Share - Tree connect fails from Windows 7 Clients
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/smbsrv/smb_dispatch.c
+++ new/usr/src/uts/common/fs/smbsrv/smb_dispatch.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
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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 /*
23 23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 - * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 + * Copyright 2019 Nexenta Systems, Inc. All rights reserved.
25 25 */
26 26
27 27 /*
28 28 * SMB requests.
29 29 *
30 30 * Request
31 31 * Header
32 32 * Magic 0xFF 'S' 'M' 'B'
33 33 * smb_com a byte, the "first" command
34 34 * Error a 4-byte union, ignored in a request
35 35 * smb_flg a one byte set of eight flags
36 36 * smb_flg2 a two byte set of 16 flags
37 37 * . twelve reserved bytes, have a role
38 38 * in connectionless transports (IPX, UDP?)
39 39 * smb_tid a 16-bit tree ID, a mount point sorta,
40 40 * 0xFFFF is this command does not have
41 41 * or require a tree context
42 42 * smb_pid a 16-bit process ID
43 43 * smb_uid a 16-bit user ID, specific to this "session"
44 44 * and mapped to a system (bona-fide) UID
45 45 * smb_mid a 16-bit multiplex ID, used to differentiate
46 46 * multiple simultaneous requests from the same
47 47 * process (pid) (ref RPC "xid")
48 48 *
49 49 * Chained (AndX) commands (0 or more)
50 50 * smb_wct a byte, number of 16-bit words containing
51 51 * command parameters, min 2 for chained command
52 52 * andx_com a byte, the "next" command, 0xFF for none
53 53 * . an unused byte
54 54 * andx_off a 16-bit offset, byte displacement from &Magic
55 55 * to the smb_wct field of the "next" command,
56 56 * ignore if andx_com is 0xFF, s/b 0 if no next
57 57 * smb_vwv[] 0 or more 16-bit (sorta) parameters for
58 58 * "this" command (i.e. smb_com if this is the
59 59 * first parameters, or the andx_com of the just
60 60 * previous block.
61 61 * smb_bcc a 16-bit count of smb_data[] bytes
62 62 * smb_data[] 0 or more bytes, format specific to commands
63 63 * padding[] Optional padding
64 64 *
65 65 * Last command
66 66 * smb_wct a byte, number of 16-bit words containing
67 67 * command parameters, min 0 for chained command
68 68 * smb_vwv[] 0 or more 16-bit (sorta) parameters for
69 69 * "this" command (i.e. smb_com if this is the
70 70 * first parameters, or the andx_com of the just
71 71 * previous block.
72 72 * smb_bcc a 16-bit count of smb_data[] bytes
73 73 * smb_data[] 0 or more bytes, format specific to commands
74 74 *
75 75 * Reply
76 76 * Header
77 77 * Magic 0xFF 'S' 'M' 'B'
78 78 * smb_com a byte, the "first" command, corresponds
79 79 * to request
80 80 * Error a 4-byte union, coding depends on dialect in use
81 81 * for "DOS" errors
82 82 * a byte for error class
83 83 * an unused byte
84 84 * a 16-bit word for error code
85 85 * for "NT" errors
86 86 * a 32-bit error code which
87 87 * is a packed class and specifier
88 88 * for "OS/2" errors
89 89 * I don't know
90 90 * The error information is specific to the
91 91 * last command in the reply chain.
92 92 * smb_flg a one byte set of eight flags, 0x80 bit set
93 93 * indicating this message is a reply
94 94 * smb_flg2 a two byte set of 16 flags
95 95 * . twelve reserved bytes, have a role
96 96 * in connectionless transports (IPX, UDP?)
97 97 * smb_tid a 16-bit tree ID, a mount point sorta,
98 98 * should be the same as the request
99 99 * smb_pid a 16-bit process ID, MUST BE the same as request
100 100 * smb_uid a 16-bit user ID, specific to this "session"
101 101 * and mapped to a system (bona-fide) UID,
102 102 * should be the same as request
103 103 * smb_mid a 16-bit multiplex ID, used to differentiate
104 104 * multiple simultaneous requests from the same
105 105 * process (pid) (ref RPC "xid"), MUST BE the
106 106 * same as request
107 107 * padding[] Optional padding
108 108 *
109 109 * Chained (AndX) commands (0 or more)
110 110 * smb_wct a byte, number of 16-bit words containing
111 111 * command parameters, min 2 for chained command,
112 112 * andx_com a byte, the "next" command, 0xFF for none,
113 113 * corresponds to request, if this is the chained
114 114 * command that had an error set to 0xFF
115 115 * . an unused byte
116 116 * andx_off a 16-bit offset, byte displacement from &Magic
117 117 * to the smb_wct field of the "next" command,
118 118 * ignore if andx_com is 0xFF, s/b 0 if no next
119 119 * smb_vwv[] 0 or more 16-bit (sorta) parameters for
120 120 * "this" command (i.e. smb_com if this is the
121 121 * first parameters, or the andx_com of the just
122 122 * previous block. Empty if an error.
123 123 * smb_bcc a 16-bit count of smb_data[] bytes
124 124 * smb_data[] 0 or more bytes, format specific to commands
125 125 * empty if an error.
126 126 *
127 127 * Last command
128 128 * smb_wct a byte, number of 16-bit words containing
129 129 * command parameters, min 0 for chained command
130 130 * smb_vwv[] 0 or more 16-bit (sorta) parameters for
131 131 * "this" command (i.e. smb_com if this is the
132 132 * first parameters, or the andx_com of the just
133 133 * previous block, empty if an error.
134 134 * smb_bcc a 16-bit count of smb_data[] bytes
135 135 * smb_data[] 0 or more bytes, format specific to commands,
136 136 * empty if an error.
137 137 */
138 138
139 139 #include <smbsrv/smb_kproto.h>
140 140 #include <smbsrv/smb_kstat.h>
141 141 #include <sys/sdt.h>
142 142 #include <sys/spl.h>
143 143
144 144 static int is_andx_com(unsigned char);
145 145 static int smbsr_check_result(struct smb_request *, int, int);
146 146 static void smb1_tq_work(void *);
147 147
148 148 static const smb_disp_entry_t const
149 149 smb_disp_table[SMB_COM_NUM] = {
150 150 { "SmbCreateDirectory", SMB_SDT_OPS(create_directory), /* 0x00 000 */
151 151 0x00, PC_NETWORK_PROGRAM_1_0 },
152 152 { "SmbDeleteDirectory", SMB_SDT_OPS(delete_directory), /* 0x01 001 */
153 153 0x01, PC_NETWORK_PROGRAM_1_0 },
154 154 { "SmbOpen", SMB_SDT_OPS(open), /* 0x02 002 */
155 155 0x02, PC_NETWORK_PROGRAM_1_0 },
156 156 { "SmbCreate", SMB_SDT_OPS(create), /* 0x03 003 */
157 157 0x03, PC_NETWORK_PROGRAM_1_0 },
158 158 { "SmbClose", SMB_SDT_OPS(close), /* 0x04 004 */
159 159 0x04, PC_NETWORK_PROGRAM_1_0 },
160 160 { "SmbFlush", SMB_SDT_OPS(flush), /* 0x05 005 */
|
↓ open down ↓ |
126 lines elided |
↑ open up ↑ |
161 161 0x05, PC_NETWORK_PROGRAM_1_0 },
162 162 { "SmbDelete", SMB_SDT_OPS(delete), /* 0x06 006 */
163 163 0x06, PC_NETWORK_PROGRAM_1_0 },
164 164 { "SmbRename", SMB_SDT_OPS(rename), /* 0x07 007 */
165 165 0x07, PC_NETWORK_PROGRAM_1_0 },
166 166 { "SmbQueryInformation", SMB_SDT_OPS(query_information), /* 0x08 008 */
167 167 0x08, PC_NETWORK_PROGRAM_1_0 },
168 168 { "SmbSetInformation", SMB_SDT_OPS(set_information), /* 0x09 009 */
169 169 0x09, PC_NETWORK_PROGRAM_1_0 },
170 170 { "SmbRead", SMB_SDT_OPS(read), /* 0x0A 010 */
171 - 0x0A, PC_NETWORK_PROGRAM_1_0 },
171 + 0x0A, PC_NETWORK_PROGRAM_1_0, SDDF_READOP },
172 172 { "SmbWrite", SMB_SDT_OPS(write), /* 0x0B 011 */
173 - 0x0B, PC_NETWORK_PROGRAM_1_0 },
173 + 0x0B, PC_NETWORK_PROGRAM_1_0, SDDF_WRITEOP },
174 174 { "SmbLockByteRange", SMB_SDT_OPS(lock_byte_range), /* 0x0C 012 */
175 175 0x0C, PC_NETWORK_PROGRAM_1_0 },
176 176 { "SmbUnlockByteRange", SMB_SDT_OPS(unlock_byte_range), /* 0x0D 013 */
177 177 0x0D, PC_NETWORK_PROGRAM_1_0 },
178 178 { "SmbCreateTemporary", SMB_SDT_OPS(create_temporary), /* 0x0E 014 */
179 179 0x0E, PC_NETWORK_PROGRAM_1_0 },
180 180 { "SmbCreateNew", SMB_SDT_OPS(create_new), /* 0x0F 015 */
181 181 0x0F, PC_NETWORK_PROGRAM_1_0 },
182 182 { "SmbCheckDirectory", SMB_SDT_OPS(check_directory), /* 0x10 016 */
183 183 0x10, PC_NETWORK_PROGRAM_1_0 },
184 184 { "SmbProcessExit", SMB_SDT_OPS(process_exit), /* 0x11 017 */
185 185 0x11, PC_NETWORK_PROGRAM_1_0,
186 186 SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
187 187 { "SmbSeek", SMB_SDT_OPS(seek), /* 0x12 018 */
188 188 0x12, PC_NETWORK_PROGRAM_1_0 },
189 189 { "SmbLockAndRead", SMB_SDT_OPS(lock_and_read), /* 0x13 019 */
190 - 0x13, LANMAN1_0 },
190 + 0x13, LANMAN1_0, SDDF_READOP},
191 191 { "SmbWriteAndUnlock", SMB_SDT_OPS(write_and_unlock), /* 0x14 020 */
192 - 0x14, LANMAN1_0 },
192 + 0x14, LANMAN1_0, SDDF_WRITEOP },
193 193 { "Invalid", SMB_SDT_OPS(invalid), 0x15, 0 }, /* 0x15 021 */
194 194 { "Invalid", SMB_SDT_OPS(invalid), 0x16, 0 }, /* 0x16 022 */
195 195 { "Invalid", SMB_SDT_OPS(invalid), 0x17, 0 }, /* 0x17 023 */
196 196 { "Invalid", SMB_SDT_OPS(invalid), 0x18, 0 }, /* 0x18 024 */
197 197 { "Invalid", SMB_SDT_OPS(invalid), 0x19, 0 }, /* 0x19 025 */
198 - { "SmbReadRaw", SMB_SDT_OPS(invalid), 0x1A, 0 }, /* 0x1A 026 */
198 + { "SmbReadRaw", SMB_SDT_OPS(read_raw), /* 0x1A 026 */
199 + 0x1A, LANMAN1_0 },
199 200 { "Invalid", SMB_SDT_OPS(invalid), 0x1B, 0 }, /* 0x1B 027 */
200 201 { "Invalid", SMB_SDT_OPS(invalid), 0x1C, 0 }, /* 0x1C 028 */
201 - { "SmbWriteRaw", SMB_SDT_OPS(invalid), 0x1D, 0 }, /* 0x1D 029 */
202 + { "SmbWriteRaw", SMB_SDT_OPS(write_raw), /* 0x1D 029 */
203 + 0x1D, LANMAN1_0 },
202 204 { "Invalid", SMB_SDT_OPS(invalid), 0x1E, 0 }, /* 0x1E 030 */
203 205 { "Invalid", SMB_SDT_OPS(invalid), 0x1F, 0 }, /* 0x1F 031 */
204 206 { "Invalid", SMB_SDT_OPS(invalid), 0x20, 0 }, /* 0x20 032 */
205 207 { "Invalid", SMB_SDT_OPS(invalid), 0x21, 0 }, /* 0x21 033 */
206 208 { "SmbSetInformation2", SMB_SDT_OPS(set_information2), /* 0x22 034 */
207 209 0x22, LANMAN1_0 },
208 210 { "SmbQueryInformation2",
209 211 SMB_SDT_OPS(query_information2), /* 0x23 035 */
210 212 0x23, LANMAN1_0 },
211 213 { "SmbLockingX", SMB_SDT_OPS(locking_andx), /* 0x24 036 */
212 214 0x24, LANMAN1_0 },
213 215 { "SmbTransaction", SMB_SDT_OPS(transaction), /* 0x25 037 */
214 216 0x25, LANMAN1_0 },
215 217 { "SmbTransactionSecondary",
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
216 218 SMB_SDT_OPS(transaction_secondary), /* 0x26 038 */
217 219 0x26, LANMAN1_0 },
218 220 { "SmbIoctl", SMB_SDT_OPS(ioctl), /* 0x27 039 */
219 221 0x27, LANMAN1_0 },
220 222 { "Invalid", SMB_SDT_OPS(invalid), 0x28, 0 }, /* 0x28 040 */
221 223 { "Invalid", SMB_SDT_OPS(invalid), 0x29, 0 }, /* 0x29 041 */
222 224 { "Invalid", SMB_SDT_OPS(invalid), 0x2A, 0 }, /* 0x2A 042 */
223 225 { "SmbEcho", SMB_SDT_OPS(echo), /* 0x2B 043 */
224 226 0x2B, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
225 227 { "SmbWriteAndClose", SMB_SDT_OPS(write_and_close), /* 0x2C 044 */
226 - 0x2C, LANMAN1_0 },
228 + 0x2C, LANMAN1_0, SDDF_WRITEOP },
227 229 { "SmbOpenX", SMB_SDT_OPS(open_andx), /* 0x2D 045 */
228 230 0x2D, LANMAN1_0 },
229 231 { "SmbReadX", SMB_SDT_OPS(read_andx), /* 0x2E 046 */
230 - 0x2E, LANMAN1_0 },
232 + 0x2E, LANMAN1_0, SDDF_READOP },
231 233 { "SmbWriteX", SMB_SDT_OPS(write_andx), /* 0x2F 047 */
232 - 0x2F, LANMAN1_0 },
234 + 0x2F, LANMAN1_0, SDDF_WRITEOP },
233 235 { "Invalid", SMB_SDT_OPS(invalid), 0x30, 0 }, /* 0x30 048 */
234 236 { "SmbCloseAndTreeDisconnect",
235 237 SMB_SDT_OPS(close_and_tree_disconnect), /* 0x31 049 */
236 238 0x31, LANMAN1_0 },
237 239 { "SmbTransaction2", SMB_SDT_OPS(transaction2), /* 0x32 050 */
238 240 0x32, LM1_2X002 },
239 241 { "SmbTransaction2Secondary",
240 242 SMB_SDT_OPS(transaction2_secondary), /* 0x33 051 */
241 243 0x33, LM1_2X002 },
242 244 { "SmbFindClose2", SMB_SDT_OPS(find_close2), /* 0x34 052 */
243 245 0x34, LM1_2X002 },
244 246 { "Invalid", SMB_SDT_OPS(invalid), 0x35, 0 }, /* 0x35 053 */
245 247 { "Invalid", SMB_SDT_OPS(invalid), 0x36, 0 }, /* 0x36 054 */
246 248 { "Invalid", SMB_SDT_OPS(invalid), 0x37, 0 }, /* 0x37 055 */
247 249 { "Invalid", SMB_SDT_OPS(invalid), 0x38, 0 }, /* 0x38 056 */
248 250 { "Invalid", SMB_SDT_OPS(invalid), 0x39, 0 }, /* 0x39 057 */
249 251 { "Invalid", SMB_SDT_OPS(invalid), 0x3A, 0 }, /* 0x3A 058 */
250 252 { "Invalid", SMB_SDT_OPS(invalid), 0x3B, 0 }, /* 0x3B 059 */
251 253 { "Invalid", SMB_SDT_OPS(invalid), 0x3C, 0 }, /* 0x3C 060 */
252 254 { "Invalid", SMB_SDT_OPS(invalid), 0x3D, 0 }, /* 0x3D 061 */
253 255 { "Invalid", SMB_SDT_OPS(invalid), 0x3E, 0 }, /* 0x3E 062 */
254 256 { "Invalid", SMB_SDT_OPS(invalid), 0x3F, 0 }, /* 0x3F 063 */
255 257 { "Invalid", SMB_SDT_OPS(invalid), 0x40, 0 }, /* 0x40 064 */
256 258 { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 065 */
257 259 { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 066 */
258 260 { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 067 */
259 261 { "Invalid", SMB_SDT_OPS(invalid), 0x44, 0 }, /* 0x44 068 */
260 262 { "Invalid", SMB_SDT_OPS(invalid), 0x45, 0 }, /* 0x45 069 */
261 263 { "Invalid", SMB_SDT_OPS(invalid), 0x46, 0 }, /* 0x46 070 */
262 264 { "Invalid", SMB_SDT_OPS(invalid), 0x47, 0 }, /* 0x47 071 */
263 265 { "Invalid", SMB_SDT_OPS(invalid), 0x48, 0 }, /* 0x48 072 */
264 266 { "Invalid", SMB_SDT_OPS(invalid), 0x49, 0 }, /* 0x49 073 */
265 267 { "Invalid", SMB_SDT_OPS(invalid), 0x4A, 0 }, /* 0x4A 074 */
266 268 { "Invalid", SMB_SDT_OPS(invalid), 0x4B, 0 }, /* 0x4B 075 */
267 269 { "Invalid", SMB_SDT_OPS(invalid), 0x4C, 0 }, /* 0x4C 076 */
268 270 { "Invalid", SMB_SDT_OPS(invalid), 0x4D, 0 }, /* 0x4D 077 */
269 271 { "Invalid", SMB_SDT_OPS(invalid), 0x4E, 0 }, /* 0x4E 078 */
270 272 { "Invalid", SMB_SDT_OPS(invalid), 0x4F, 0 }, /* 0x4F 079 */
271 273 { "Invalid", SMB_SDT_OPS(invalid), 0x50, 0 }, /* 0x50 080 */
272 274 { "Invalid", SMB_SDT_OPS(invalid), 0x51, 0 }, /* 0x51 081 */
273 275 { "Invalid", SMB_SDT_OPS(invalid), 0x52, 0 }, /* 0x52 082 */
274 276 { "Invalid", SMB_SDT_OPS(invalid), 0x53, 0 }, /* 0x53 083 */
275 277 { "Invalid", SMB_SDT_OPS(invalid), 0x54, 0 }, /* 0x54 084 */
276 278 { "Invalid", SMB_SDT_OPS(invalid), 0x55, 0 }, /* 0x55 085 */
277 279 { "Invalid", SMB_SDT_OPS(invalid), 0x56, 0 }, /* 0x56 086 */
278 280 { "Invalid", SMB_SDT_OPS(invalid), 0x57, 0 }, /* 0x57 087 */
279 281 { "Invalid", SMB_SDT_OPS(invalid), 0x58, 0 }, /* 0x58 088 */
280 282 { "Invalid", SMB_SDT_OPS(invalid), 0x59, 0 }, /* 0x59 089 */
281 283 { "Invalid", SMB_SDT_OPS(invalid), 0x5A, 0 }, /* 0x5A 090 */
282 284 { "Invalid", SMB_SDT_OPS(invalid), 0x5B, 0 }, /* 0x5B 091 */
283 285 { "Invalid", SMB_SDT_OPS(invalid), 0x5C, 0 }, /* 0x5C 092 */
284 286 { "Invalid", SMB_SDT_OPS(invalid), 0x5D, 0 }, /* 0x5D 093 */
285 287 { "Invalid", SMB_SDT_OPS(invalid), 0x5E, 0 }, /* 0x5E 094 */
286 288 { "Invalid", SMB_SDT_OPS(invalid), 0x5F, 0 }, /* 0x5F 095 */
287 289 { "Invalid", SMB_SDT_OPS(invalid), 0x60, 0 }, /* 0x60 096 */
288 290 { "Invalid", SMB_SDT_OPS(invalid), 0x61, 0 }, /* 0x61 097 */
289 291 { "Invalid", SMB_SDT_OPS(invalid), 0x62, 0 }, /* 0x62 098 */
290 292 { "Invalid", SMB_SDT_OPS(invalid), 0x63, 0 }, /* 0x63 099 */
291 293 { "Invalid", SMB_SDT_OPS(invalid), 0x64, 0 }, /* 0x64 100 */
292 294 { "Invalid", SMB_SDT_OPS(invalid), 0x65, 0 }, /* 0x65 101 */
293 295 { "Invalid", SMB_SDT_OPS(invalid), 0x66, 0 }, /* 0x66 102 */
294 296 { "Invalid", SMB_SDT_OPS(invalid), 0x67, 0 }, /* 0x67 103 */
295 297 { "Invalid", SMB_SDT_OPS(invalid), 0x68, 0 }, /* 0x68 104 */
296 298 { "Invalid", SMB_SDT_OPS(invalid), 0x69, 0 }, /* 0x69 105 */
297 299 { "Invalid", SMB_SDT_OPS(invalid), 0x6A, 0 }, /* 0x6A 106 */
298 300 { "Invalid", SMB_SDT_OPS(invalid), 0x6B, 0 }, /* 0x6B 107 */
299 301 { "Invalid", SMB_SDT_OPS(invalid), 0x6C, 0 }, /* 0x6C 108 */
300 302 { "Invalid", SMB_SDT_OPS(invalid), 0x6D, 0 }, /* 0x6D 109 */
301 303 { "Invalid", SMB_SDT_OPS(invalid), 0x6E, 0 }, /* 0x6E 110 */
302 304 { "Invalid", SMB_SDT_OPS(invalid), 0x6F, 0 }, /* 0x6F 111 */
303 305 { "SmbTreeConnect", SMB_SDT_OPS(tree_connect), /* 0x70 112 */
304 306 0x70, PC_NETWORK_PROGRAM_1_0, SDDF_SUPPRESS_TID },
305 307 { "SmbTreeDisconnect", SMB_SDT_OPS(tree_disconnect), /* 0x71 113 */
306 308 0x71, PC_NETWORK_PROGRAM_1_0,
307 309 SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
308 310 /*
309 311 * NB: Negotiate gets special handling via
310 312 * smb_initial_request_handler. After that,
311 313 * another Negotiate is an invalid request.
312 314 */
313 315 { "SmbNegotiate", SMB_SDT_OPS(invalid), /* 0x72 114 */
314 316 0x72, PC_NETWORK_PROGRAM_1_0,
315 317 SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
316 318 { "SmbSessionSetupX", SMB_SDT_OPS(session_setup_andx), /* 0x73 115 */
317 319 0x73, LANMAN1_0, SDDF_SUPPRESS_TID | SDDF_SUPPRESS_UID },
318 320 { "SmbLogoffX", SMB_SDT_OPS(logoff_andx), /* 0x74 116 */
319 321 0x74, LM1_2X002, SDDF_SUPPRESS_TID },
320 322 { "SmbTreeConnectX", SMB_SDT_OPS(tree_connect_andx), /* 0x75 117 */
321 323 0x75, LANMAN1_0, SDDF_SUPPRESS_TID },
322 324 { "Invalid", SMB_SDT_OPS(invalid), 0x76, 0, 0 }, /* 0x76 118 */
323 325 { "Invalid", SMB_SDT_OPS(invalid), 0x77, 0, 0 }, /* 0x77 119 */
324 326 { "Invalid", SMB_SDT_OPS(invalid), 0x78, 0, 0 }, /* 0x78 120 */
325 327 { "Invalid", SMB_SDT_OPS(invalid), 0x79, 0, 0 }, /* 0x79 121 */
326 328 { "Invalid", SMB_SDT_OPS(invalid), 0x7A, 0, 0 }, /* 0x7A 122 */
327 329 { "Invalid", SMB_SDT_OPS(invalid), 0x7B, 0, 0 }, /* 0x7B 123 */
328 330 { "Invalid", SMB_SDT_OPS(invalid), 0x7C, 0, 0 }, /* 0x7C 124 */
329 331 { "Invalid", SMB_SDT_OPS(invalid), 0x7D, 0, 0 }, /* 0x7D 125 */
330 332 { "Invalid", SMB_SDT_OPS(invalid), 0x7E, 0, 0 }, /* 0x7E 126 */
331 333 { "Invalid", SMB_SDT_OPS(invalid), 0x7F, 0, 0 }, /* 0x7F 127 */
332 334 { "SmbQueryInformationDisk",
333 335 SMB_SDT_OPS(query_information_disk), /* 0x80 128 */
334 336 0x80, PC_NETWORK_PROGRAM_1_0, 0 },
335 337 { "SmbSearch", SMB_SDT_OPS(search), /* 0x81 129 */
336 338 0x81, PC_NETWORK_PROGRAM_1_0, 0 },
337 339 { "SmbFind", SMB_SDT_OPS(find), /* 0x82 130 */
338 340 0x82, LANMAN1_0, 0 },
339 341 { "SmbFindUnique", SMB_SDT_OPS(find_unique), /* 0x83 131 */
340 342 0x83, LANMAN1_0, 0 },
341 343 { "SmbFindClose", SMB_SDT_OPS(find_close), /* 0x84 132 */
342 344 0x84, LANMAN1_0, 0 },
343 345 { "Invalid", SMB_SDT_OPS(invalid), 0x85, 0, 0 }, /* 0x85 133 */
344 346 { "Invalid", SMB_SDT_OPS(invalid), 0x86, 0, 0 }, /* 0x86 134 */
345 347 { "Invalid", SMB_SDT_OPS(invalid), 0x87, 0, 0 }, /* 0x87 135 */
346 348 { "Invalid", SMB_SDT_OPS(invalid), 0x88, 0, 0 }, /* 0x88 136 */
347 349 { "Invalid", SMB_SDT_OPS(invalid), 0x89, 0, 0 }, /* 0x89 137 */
348 350 { "Invalid", SMB_SDT_OPS(invalid), 0x8A, 0, 0 }, /* 0x8A 138 */
349 351 { "Invalid", SMB_SDT_OPS(invalid), 0x8B, 0, 0 }, /* 0x8B 139 */
350 352 { "Invalid", SMB_SDT_OPS(invalid), 0x8C, 0, 0 }, /* 0x8C 140 */
351 353 { "Invalid", SMB_SDT_OPS(invalid), 0x8D, 0, 0 }, /* 0x8D 141 */
352 354 { "Invalid", SMB_SDT_OPS(invalid), 0x8E, 0, 0 }, /* 0x8E 142 */
353 355 { "Invalid", SMB_SDT_OPS(invalid), 0x8F, 0, 0 }, /* 0x8F 143 */
354 356 { "Invalid", SMB_SDT_OPS(invalid), 0x90, 0, 0 }, /* 0x90 144 */
355 357 { "Invalid", SMB_SDT_OPS(invalid), 0x91, 0, 0 }, /* 0x91 145 */
356 358 { "Invalid", SMB_SDT_OPS(invalid), 0x92, 0, 0 }, /* 0x92 146 */
357 359 { "Invalid", SMB_SDT_OPS(invalid), 0x93, 0, 0 }, /* 0x93 147 */
358 360 { "Invalid", SMB_SDT_OPS(invalid), 0x94, 0, 0 }, /* 0x94 148 */
359 361 { "Invalid", SMB_SDT_OPS(invalid), 0x95, 0, 0 }, /* 0x95 149 */
360 362 { "Invalid", SMB_SDT_OPS(invalid), 0x96, 0, 0 }, /* 0x96 150 */
361 363 { "Invalid", SMB_SDT_OPS(invalid), 0x97, 0, 0 }, /* 0x97 151 */
362 364 { "Invalid", SMB_SDT_OPS(invalid), 0x98, 0, 0 }, /* 0x98 152 */
363 365 { "Invalid", SMB_SDT_OPS(invalid), 0x99, 0, 0 }, /* 0x99 153 */
364 366 { "Invalid", SMB_SDT_OPS(invalid), 0x9A, 0, 0 }, /* 0x9A 154 */
365 367 { "Invalid", SMB_SDT_OPS(invalid), 0x9B, 0, 0 }, /* 0x9B 155 */
366 368 { "Invalid", SMB_SDT_OPS(invalid), 0x9C, 0, 0 }, /* 0x9C 156 */
367 369 { "Invalid", SMB_SDT_OPS(invalid), 0x9D, 0, 0 }, /* 0x9D 157 */
368 370 { "Invalid", SMB_SDT_OPS(invalid), 0x9E, 0, 0 }, /* 0x9E 158 */
369 371 { "Invalid", SMB_SDT_OPS(invalid), 0x9F, 0, 0 }, /* 0x9F 159 */
370 372 { "SmbNtTransact", SMB_SDT_OPS(nt_transact), /* 0xA0 160 */
371 373 0xA0, NT_LM_0_12, 0 },
372 374 { "SmbNtTransactSecondary",
373 375 SMB_SDT_OPS(nt_transact_secondary), /* 0xA1 161 */
374 376 0xA1, NT_LM_0_12, 0 },
375 377 { "SmbNtCreateX", SMB_SDT_OPS(nt_create_andx), /* 0xA2 162 */
376 378 0xA2, NT_LM_0_12, 0 },
377 379 { "Invalid", SMB_SDT_OPS(invalid), 0xA3, 0, 0 }, /* 0xA3 163 */
378 380 { "SmbNtCancel", SMB_SDT_OPS(nt_cancel), /* 0xA4 164 */
379 381 0xA4, NT_LM_0_12, 0 },
380 382 { "SmbNtRename", SMB_SDT_OPS(nt_rename), /* 0xA5 165 */
381 383 0xA5, NT_LM_0_12, 0 },
382 384 { "Invalid", SMB_SDT_OPS(invalid), 0xA6, 0, 0 }, /* 0xA6 166 */
383 385 { "Invalid", SMB_SDT_OPS(invalid), 0xA7, 0, 0 }, /* 0xA7 167 */
384 386 { "Invalid", SMB_SDT_OPS(invalid), 0xA8, 0, 0 }, /* 0xA8 168 */
385 387 { "Invalid", SMB_SDT_OPS(invalid), 0xA9, 0, 0 }, /* 0xA9 169 */
386 388 { "Invalid", SMB_SDT_OPS(invalid), 0xAA, 0, 0 }, /* 0xAA 170 */
387 389 { "Invalid", SMB_SDT_OPS(invalid), 0xAB, 0, 0 }, /* 0xAB 171 */
388 390 { "Invalid", SMB_SDT_OPS(invalid), 0xAC, 0, 0 }, /* 0xAC 172 */
389 391 { "Invalid", SMB_SDT_OPS(invalid), 0xAD, 0, 0 }, /* 0xAD 173 */
390 392 { "Invalid", SMB_SDT_OPS(invalid), 0xAE, 0, 0 }, /* 0xAE 174 */
391 393 { "Invalid", SMB_SDT_OPS(invalid), 0xAF, 0, 0 }, /* 0xAF 175 */
392 394 { "Invalid", SMB_SDT_OPS(invalid), 0xB0, 0, 0 }, /* 0xB0 176 */
393 395 { "Invalid", SMB_SDT_OPS(invalid), 0xB1, 0, 0 }, /* 0xB1 177 */
394 396 { "Invalid", SMB_SDT_OPS(invalid), 0xB2, 0, 0 }, /* 0xB2 178 */
395 397 { "Invalid", SMB_SDT_OPS(invalid), 0xB3, 0, 0 }, /* 0xB3 179 */
396 398 { "Invalid", SMB_SDT_OPS(invalid), 0xB4, 0, 0 }, /* 0xB4 180 */
397 399 { "Invalid", SMB_SDT_OPS(invalid), 0xB5, 0, 0 }, /* 0xB5 181 */
398 400 { "Invalid", SMB_SDT_OPS(invalid), 0xB6, 0, 0 }, /* 0xB6 182 */
399 401 { "Invalid", SMB_SDT_OPS(invalid), 0xB7, 0, 0 }, /* 0xB7 183 */
400 402 { "Invalid", SMB_SDT_OPS(invalid), 0xB8, 0, 0 }, /* 0xB8 184 */
|
↓ open down ↓ |
158 lines elided |
↑ open up ↑ |
401 403 { "Invalid", SMB_SDT_OPS(invalid), 0xB9, 0, 0 }, /* 0xB9 185 */
402 404 { "Invalid", SMB_SDT_OPS(invalid), 0xBA, 0, 0 }, /* 0xBA 186 */
403 405 { "Invalid", SMB_SDT_OPS(invalid), 0xBB, 0, 0 }, /* 0xBB 187 */
404 406 { "Invalid", SMB_SDT_OPS(invalid), 0xBC, 0, 0 }, /* 0xBC 188 */
405 407 { "Invalid", SMB_SDT_OPS(invalid), 0xBD, 0, 0 }, /* 0xBD 189 */
406 408 { "Invalid", SMB_SDT_OPS(invalid), 0xBE, 0, 0 }, /* 0xBE 190 */
407 409 { "Invalid", SMB_SDT_OPS(invalid), 0xBF, 0, 0 }, /* 0xBF 191 */
408 410 { "SmbOpenPrintFile", SMB_SDT_OPS(open_print_file), /* 0xC0 192 */
409 411 0xC0, PC_NETWORK_PROGRAM_1_0, 0 },
410 412 { "SmbWritePrintFile", SMB_SDT_OPS(write_print_file), /* 0xC1 193 */
411 - 0xC1, PC_NETWORK_PROGRAM_1_0, 0 },
413 + 0xC1, PC_NETWORK_PROGRAM_1_0, SDDF_WRITEOP },
412 414 { "SmbClosePrintFile", SMB_SDT_OPS(close_print_file), /* 0xC2 194 */
413 415 0xC2, PC_NETWORK_PROGRAM_1_0, 0 },
414 416 { "SmbGetPrintQueue", SMB_SDT_OPS(get_print_queue), /* 0xC3 195 */
415 417 0xC3, PC_NETWORK_PROGRAM_1_0, 0 },
416 418 { "Invalid", SMB_SDT_OPS(invalid), 0xC4, 0, 0 }, /* 0xC4 196 */
417 419 { "Invalid", SMB_SDT_OPS(invalid), 0xC5, 0, 0 }, /* 0xC5 197 */
418 420 { "Invalid", SMB_SDT_OPS(invalid), 0xC6, 0, 0 }, /* 0xC6 198 */
419 421 { "Invalid", SMB_SDT_OPS(invalid), 0xC7, 0, 0 }, /* 0xC7 199 */
420 422 { "Invalid", SMB_SDT_OPS(invalid), 0xC8, 0, 0 }, /* 0xC8 200 */
421 423 { "Invalid", SMB_SDT_OPS(invalid), 0xC9, 0, 0 }, /* 0xC9 201 */
422 424 { "Invalid", SMB_SDT_OPS(invalid), 0xCA, 0, 0 }, /* 0xCA 202 */
423 425 { "Invalid", SMB_SDT_OPS(invalid), 0xCB, 0, 0 }, /* 0xCB 203 */
424 426 { "Invalid", SMB_SDT_OPS(invalid), 0xCC, 0, 0 }, /* 0xCC 204 */
425 427 { "Invalid", SMB_SDT_OPS(invalid), 0xCD, 0, 0 }, /* 0xCD 205 */
426 428 { "Invalid", SMB_SDT_OPS(invalid), 0xCE, 0, 0 }, /* 0xCE 206 */
427 429 { "Invalid", SMB_SDT_OPS(invalid), 0xCF, 0, 0 }, /* 0xCF 207 */
428 430 { "Invalid", SMB_SDT_OPS(invalid), 0xD0, 0, 0 }, /* 0xD0 208 */
429 431 { "Invalid", SMB_SDT_OPS(invalid), 0xD1, 0, 0 }, /* 0xD1 209 */
430 432 { "Invalid", SMB_SDT_OPS(invalid), 0xD2, 0, 0 }, /* 0xD2 210 */
431 433 { "Invalid", SMB_SDT_OPS(invalid), 0xD3, 0, 0 }, /* 0xD3 211 */
432 434 { "Invalid", SMB_SDT_OPS(invalid), 0xD4, 0, 0 }, /* 0xD4 212 */
433 435 { "Invalid", SMB_SDT_OPS(invalid), 0xD5, 0, 0 }, /* 0xD5 213 */
434 436 { "Invalid", SMB_SDT_OPS(invalid), 0xD6, 0, 0 }, /* 0xD6 214 */
435 437 { "Invalid", SMB_SDT_OPS(invalid), 0xD7, 0, 0 }, /* 0xD7 215 */
436 438 { "Invalid", SMB_SDT_OPS(invalid), 0xD8, 0, 0 }, /* 0xD8 216 */
437 439 { "Invalid", SMB_SDT_OPS(invalid), 0xD9, 0, 0 }, /* 0xD9 217 */
438 440 { "Invalid", SMB_SDT_OPS(invalid), 0xDA, 0, 0 }, /* 0xDA 218 */
439 441 { "Invalid", SMB_SDT_OPS(invalid), 0xDB, 0, 0 }, /* 0xDB 219 */
440 442 { "Invalid", SMB_SDT_OPS(invalid), 0xDC, 0, 0 }, /* 0xDC 220 */
441 443 { "Invalid", SMB_SDT_OPS(invalid), 0xDD, 0, 0 }, /* 0xDD 221 */
442 444 { "Invalid", SMB_SDT_OPS(invalid), 0xDE, 0, 0 }, /* 0xDE 222 */
443 445 { "Invalid", SMB_SDT_OPS(invalid), 0xDF, 0, 0 }, /* 0xDF 223 */
444 446 { "Invalid", SMB_SDT_OPS(invalid), 0xE0, 0, 0 }, /* 0xE0 224 */
445 447 { "Invalid", SMB_SDT_OPS(invalid), 0xE1, 0, 0 }, /* 0xE1 225 */
446 448 { "Invalid", SMB_SDT_OPS(invalid), 0xE2, 0, 0 }, /* 0xE2 226 */
447 449 { "Invalid", SMB_SDT_OPS(invalid), 0xE3, 0, 0 }, /* 0xE3 227 */
448 450 { "Invalid", SMB_SDT_OPS(invalid), 0xE4, 0, 0 }, /* 0xE4 228 */
449 451 { "Invalid", SMB_SDT_OPS(invalid), 0xE5, 0, 0 }, /* 0xE5 229 */
450 452 { "Invalid", SMB_SDT_OPS(invalid), 0xE6, 0, 0 }, /* 0xE6 230 */
451 453 { "Invalid", SMB_SDT_OPS(invalid), 0xE7, 0, 0 }, /* 0xE7 231 */
452 454 { "Invalid", SMB_SDT_OPS(invalid), 0xE8, 0, 0 }, /* 0xE8 232 */
453 455 { "Invalid", SMB_SDT_OPS(invalid), 0xE9, 0, 0 }, /* 0xE9 233 */
454 456 { "Invalid", SMB_SDT_OPS(invalid), 0xEA, 0, 0 }, /* 0xEA 234 */
455 457 { "Invalid", SMB_SDT_OPS(invalid), 0xEB, 0, 0 }, /* 0xEB 235 */
456 458 { "Invalid", SMB_SDT_OPS(invalid), 0xEC, 0, 0 }, /* 0xEC 236 */
457 459 { "Invalid", SMB_SDT_OPS(invalid), 0xED, 0, 0 }, /* 0xED 237 */
458 460 { "Invalid", SMB_SDT_OPS(invalid), 0xEE, 0, 0 }, /* 0xEE 238 */
459 461 { "Invalid", SMB_SDT_OPS(invalid), 0xEF, 0, 0 }, /* 0xEF 239 */
460 462 { "Invalid", SMB_SDT_OPS(invalid), 0xF0, 0, 0 }, /* 0xF0 240 */
461 463 { "Invalid", SMB_SDT_OPS(invalid), 0xF1, 0, 0 }, /* 0xF1 241 */
462 464 { "Invalid", SMB_SDT_OPS(invalid), 0xF2, 0, 0 }, /* 0xF2 242 */
463 465 { "Invalid", SMB_SDT_OPS(invalid), 0xF3, 0, 0 }, /* 0xF3 243 */
464 466 { "Invalid", SMB_SDT_OPS(invalid), 0xF4, 0, 0 }, /* 0xF4 244 */
465 467 { "Invalid", SMB_SDT_OPS(invalid), 0xF5, 0, 0 }, /* 0xF5 245 */
466 468 { "Invalid", SMB_SDT_OPS(invalid), 0xF6, 0, 0 }, /* 0xF6 246 */
467 469 { "Invalid", SMB_SDT_OPS(invalid), 0xF7, 0, 0 }, /* 0xF7 247 */
468 470 { "Invalid", SMB_SDT_OPS(invalid), 0xF8, 0, 0 }, /* 0xF8 248 */
469 471 { "Invalid", SMB_SDT_OPS(invalid), 0xF9, 0, 0 }, /* 0xF9 249 */
470 472 { "Invalid", SMB_SDT_OPS(invalid), 0xFA, 0, 0 }, /* 0xFA 250 */
471 473 { "Invalid", SMB_SDT_OPS(invalid), 0xFB, 0, 0 }, /* 0xFB 251 */
472 474 { "Invalid", SMB_SDT_OPS(invalid), 0xFC, 0, 0 }, /* 0xFC 252 */
473 475 { "Invalid", SMB_SDT_OPS(invalid), 0xFD, 0, 0 }, /* 0xFD 253 */
474 476 { "Invalid", SMB_SDT_OPS(invalid), 0xFE, 0, 0 }, /* 0xFE 254 */
475 477 { "Invalid", SMB_SDT_OPS(invalid), 0xFF, 0, 0 } /* 0xFF 255 */
476 478 };
477 479
478 480 /*
479 481 * smbsr_cleanup
480 482 *
481 483 * If any user/tree/file is used by given request then
482 484 * the reference count for that resource has been incremented.
483 485 * This function decrements the reference count and close
484 486 * the resource if it's needed.
485 487 */
486 488
487 489 void
488 490 smbsr_cleanup(smb_request_t *sr)
489 491 {
490 492 ASSERT((sr->sr_state != SMB_REQ_STATE_CLEANED_UP) &&
491 493 (sr->sr_state != SMB_REQ_STATE_COMPLETED));
492 494
493 495 if (sr->r_xa) {
494 496 if (sr->r_xa->xa_flags & SMB_XA_FLAG_COMPLETE)
495 497 smb_xa_close(sr->r_xa);
|
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
496 498 smb_xa_rele(sr->session, sr->r_xa);
497 499 sr->r_xa = NULL;
498 500 }
499 501
500 502 /*
501 503 * Mark this request so we know that we've already cleaned it up.
502 504 * A request should only get cleaned up once so multiple calls to
503 505 * smbsr_cleanup for the same request indicate a bug.
504 506 */
505 507 mutex_enter(&sr->sr_mutex);
506 - if (sr->sr_state != SMB_REQ_STATE_CANCELED)
508 + if (sr->sr_state != SMB_REQ_STATE_CANCELLED)
507 509 sr->sr_state = SMB_REQ_STATE_CLEANED_UP;
508 510 mutex_exit(&sr->sr_mutex);
509 511 }
510 512
513 +int smb_cancel_in_reader = 1;
514 +
511 515 /*
512 516 * This is the SMB1 handler for new smb requests, called from
513 517 * smb_session_reader after SMB negotiate is done. For most SMB
514 518 * requests, we just enqueue them for the smb_session_worker to
515 519 * execute via the task queue, so they can block for resources
516 520 * without stopping the reader thread. A few protocol messages
517 521 * are special cases and are handled directly here in the reader
518 522 * thread so they don't wait for taskq scheduling. Later, a few
519 523 * MORE things could be handled here, such as REPLY messages
520 524 * (oplock break reply) and things like "NT_cancel".
521 525 *
522 526 * This function must either enqueue the new request for
523 527 * execution via the task queue, or execute it directly
524 528 * and then free it. If this returns non-zero, the caller
525 529 * will drop the session.
526 530 */
527 531 int
528 532 smb1sr_newrq(smb_request_t *sr)
529 533 {
530 - uint32_t magic;
534 + uint16_t pid_hi, pid_lo;
535 + int rc, save_offset;
531 536
532 - magic = SMB_READ_PROTOCOL(sr->sr_request_buf);
533 - if (magic != SMB_PROTOCOL_MAGIC) {
537 + /*
538 + * Decode the SMB header now (peek) so that
539 + * SMB_COM_NT_CANCEL can find this SR.
540 + */
541 + save_offset = sr->command.chain_offset;
542 + rc = smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT,
543 + &sr->smb_com,
544 + &sr->smb_rcls,
545 + &sr->smb_reh,
546 + &sr->smb_err,
547 + &sr->smb_flg,
548 + &sr->smb_flg2,
549 + &pid_hi,
550 + sr->smb_sig,
551 + &sr->smb_tid,
552 + &pid_lo,
553 + &sr->smb_uid,
554 + &sr->smb_mid);
555 + sr->command.chain_offset = save_offset;
556 + if (rc != 0) {
557 + /* Failed decoding the header. Drop 'em. */
534 558 smb_request_free(sr);
535 559 return (EPROTO);
536 560 }
561 + sr->smb_pid = (pid_hi << 16) | pid_lo;
537 562
538 - if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
539 - if (SMB_IS_NT_CANCEL(sr)) {
563 + if (sr->smb_com == SMB_COM_NT_CANCEL) {
564 + if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
540 565 sr->session->signing.seqnum++;
541 566 sr->sr_seqnum = sr->session->signing.seqnum + 1;
542 567 sr->reply_seqnum = 0;
543 - } else {
568 + }
569 +
570 + /*
571 + * Normally execute cancel requests immediately,
572 + * (here in the reader thread) so they won't wait
573 + * for other commands already in the task queue.
574 + * Disable this via smb_cancel_in_reader=0 for
575 + * testing or diagnostic efforts, in which case
576 + * cancel runs via taskq_dispatch.
577 + */
578 + if (smb_cancel_in_reader != 0) {
579 + rc = smb1sr_newrq_cancel(sr);
580 + smb_request_free(sr);
581 + return (rc);
582 + }
583 + } else {
584 + /* not NT cancel */
585 + if (sr->session->signing.flags & SMB_SIGNING_ENABLED) {
544 586 sr->session->signing.seqnum += 2;
545 587 sr->sr_seqnum = sr->session->signing.seqnum;
546 588 sr->reply_seqnum = sr->sr_seqnum + 1;
547 589 }
548 590 }
549 591
550 592 /*
551 593 * Submit the request to the task queue, which calls
552 594 * smb1_tq_work when the workload permits.
553 595 */
554 596 sr->sr_time_submitted = gethrtime();
555 597 sr->sr_state = SMB_REQ_STATE_SUBMITTED;
556 598 smb_srqueue_waitq_enter(sr->session->s_srqueue);
557 599 (void) taskq_dispatch(sr->sr_server->sv_worker_pool,
558 600 smb1_tq_work, sr, TQ_SLEEP);
559 601
560 602 return (0);
561 603 }
562 604
563 605 static void
564 606 smb1_tq_work(void *arg)
565 607 {
566 608 smb_request_t *sr;
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
567 609 smb_srqueue_t *srq;
568 610
569 611 sr = (smb_request_t *)arg;
570 612 SMB_REQ_VALID(sr);
571 613
572 614 srq = sr->session->s_srqueue;
573 615 smb_srqueue_waitq_to_runq(srq);
574 616 sr->sr_worker = curthread;
575 617 sr->sr_time_active = gethrtime();
576 618
619 + /*
620 + * Always dispatch to the work function, because cancelled
621 + * requests need an error reply (NT_STATUS_CANCELLED).
622 + */
577 623 mutex_enter(&sr->sr_mutex);
578 - switch (sr->sr_state) {
579 - case SMB_REQ_STATE_SUBMITTED:
580 - mutex_exit(&sr->sr_mutex);
581 - smb1sr_work(sr);
582 - sr = NULL;
583 - break;
624 + if (sr->sr_state == SMB_REQ_STATE_SUBMITTED)
625 + sr->sr_state = SMB_REQ_STATE_ACTIVE;
626 + mutex_exit(&sr->sr_mutex);
584 627
585 - default:
586 - /*
587 - * SMB1 requests that have been cancelled
588 - * have no reply. Just free it.
589 - */
590 - sr->sr_state = SMB_REQ_STATE_COMPLETED;
591 - mutex_exit(&sr->sr_mutex);
592 - smb_request_free(sr);
593 - break;
594 - }
628 + smb1sr_work(sr);
629 +
595 630 smb_srqueue_runq_exit(srq);
596 631 }
597 632
598 633 /*
599 634 * smb1sr_work
600 635 *
601 636 * In most cases, this should free the request before return.
602 637 * Exceptions are when a dispatch function returns SDRC_SR_KEPT.
603 638 */
604 639 void
605 640 smb1sr_work(struct smb_request *sr)
606 641 {
607 642 smb_sdrc_t sdrc;
608 643 const smb_disp_entry_t *sdd;
609 644 smb_disp_stats_t *sds;
610 645 boolean_t disconnect = B_FALSE;
611 646 smb_session_t *session;
612 647 smb_server_t *server;
648 + int32_t txbase;
649 + uint32_t rxbytes;
613 650 uint32_t byte_count;
614 651 uint32_t max_bytes;
615 652 uint16_t pid_hi, pid_lo;
616 653
617 654 session = sr->session;
618 655 server = session->s_server;
619 656
620 657 ASSERT(sr->tid_tree == 0);
621 658 ASSERT(sr->uid_user == 0);
622 659 ASSERT(sr->fid_ofile == 0);
623 660 sr->smb_fid = (uint16_t)-1;
624 661
625 662 /* temporary until we identify a user */
626 663 sr->user_cr = zone_kcred();
627 664 sr->orig_request_hdr = sr->command.chain_offset;
628 665
629 666 /*
630 667 * Decode the SMB header.
631 668 */
632 669 if (smb_mbc_decodef(&sr->command, SMB_HEADER_ED_FMT,
633 670 &sr->smb_com,
634 671 &sr->smb_rcls,
635 672 &sr->smb_reh,
636 673 &sr->smb_err,
637 674 &sr->smb_flg,
638 675 &sr->smb_flg2,
639 676 &pid_hi,
640 677 sr->smb_sig,
641 678 &sr->smb_tid,
642 679 &pid_lo,
643 680 &sr->smb_uid,
644 681 &sr->smb_mid) != 0) {
645 682 disconnect = B_TRUE;
646 683 goto drop_connection;
647 684 }
648 685 sr->smb_pid = (pid_hi << 16) | pid_lo;
649 686
650 687 /*
651 688 * The reply "header" is filled in now even though it will,
652 689 * most likely, be rewritten under reply_ready below. We
653 690 * could reserve the space but this is convenient in case
654 691 * the dialect dispatcher has to send a special reply (like
655 692 * TRANSACT).
656 693 *
657 694 * Ensure that the 32-bit error code flag is turned off.
658 695 * Clients seem to set it in transact requests and they may
659 696 * get confused if we return success or a 16-bit SMB code.
660 697 */
661 698 sr->smb_rcls = 0;
662 699 sr->smb_reh = 0;
663 700 sr->smb_err = 0;
664 701 sr->smb_flg2 &= ~SMB_FLAGS2_NT_STATUS;
665 702
666 703 (void) smb_mbc_encodef(&sr->reply, SMB_HEADER_ED_FMT,
667 704 sr->smb_com,
668 705 sr->smb_rcls,
669 706 sr->smb_reh,
670 707 sr->smb_err,
|
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
671 708 sr->smb_flg,
672 709 sr->smb_flg2,
673 710 pid_hi,
674 711 sr->smb_sig,
675 712 sr->smb_tid,
676 713 pid_lo,
677 714 sr->smb_uid,
678 715 sr->smb_mid);
679 716 sr->first_smb_com = sr->smb_com;
680 717
718 + /* Need this for early goto report_error cases. */
719 + sr->cur_reply_offset = sr->reply.chain_offset;
720 +
681 721 if ((session->signing.flags & SMB_SIGNING_CHECK) != 0) {
682 722 if ((sr->smb_flg2 & SMB_FLAGS2_SMB_SECURITY_SIGNATURE) == 0 ||
683 723 smb_sign_check_request(sr) != 0) {
684 724 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
685 725 ERRDOS, ERROR_ACCESS_DENIED);
686 726 disconnect = B_TRUE;
687 727 goto report_error;
688 728 }
689 729 }
690 730
691 731 andx_more:
692 732 sdd = &smb_disp_table[sr->smb_com];
693 733 ASSERT(sdd->sdt_function);
694 734 sds = &server->sv_disp_stats1[sr->smb_com];
695 735
696 736 if (smb_mbc_decodef(&sr->command, "b", &sr->smb_wct) != 0) {
697 737 disconnect = B_TRUE;
698 738 goto report_error;
|
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
699 739 }
700 740
701 741 (void) MBC_SHADOW_CHAIN(&sr->smb_vwv, &sr->command,
702 742 sr->command.chain_offset, sr->smb_wct * 2);
703 743
704 744 if (smb_mbc_decodef(&sr->command, "#.w", sr->smb_wct*2, &sr->smb_bcc)) {
705 745 disconnect = B_TRUE;
706 746 goto report_error;
707 747 }
708 748
709 - atomic_add_64(&sds->sdt_rxb,
710 - (int64_t)(sr->smb_wct * 2 + sr->smb_bcc + 1));
711 - sr->sr_txb = sr->reply.chain_offset;
712 -
713 749 /*
714 750 * Ignore smb_bcc if CAP_LARGE_READX/CAP_LARGE_WRITEX
715 751 * and this is SmbReadX/SmbWriteX since this enables
716 752 * large reads/write and bcc is only 16-bits.
717 753 */
718 754 max_bytes = sr->command.max_bytes - sr->command.chain_offset;
719 755 if (sr->smb_com == SMB_COM_WRITE_ANDX) {
720 756 /* Allow > BCC */
721 757 byte_count = max_bytes;
722 758 } else if (max_bytes < (uint32_t)sr->smb_bcc) {
723 759 /* BCC is bogus. Will fail later. */
724 760 byte_count = max_bytes;
725 761 } else {
726 762 /* ordinary case */
727 763 byte_count = (uint32_t)sr->smb_bcc;
728 764 }
729 765
766 + /* Save these for kstat updates below. */
767 + rxbytes = byte_count + 1 + 2 * sr->smb_wct;
768 + txbase = sr->reply.chain_offset;
769 +
730 770 (void) MBC_SHADOW_CHAIN(&sr->smb_data, &sr->command,
731 771 sr->command.chain_offset, byte_count);
732 772
733 773 sr->command.chain_offset += byte_count;
734 774 if (sr->command.chain_offset > sr->command.max_bytes) {
735 775 disconnect = B_TRUE;
736 776 goto report_error;
737 777 }
738 778
739 779 /* Store pointers for later */
740 780 sr->cur_reply_offset = sr->reply.chain_offset;
741 781
742 782 if (is_andx_com(sr->smb_com)) {
743 783 /* Peek ahead and don't disturb vwv */
744 784 if (smb_mbc_peek(&sr->smb_vwv, sr->smb_vwv.chain_offset, "b.w",
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
745 785 &sr->andx_com, &sr->andx_off) < 0) {
746 786 disconnect = B_TRUE;
747 787 goto report_error;
748 788 }
749 789 } else {
750 790 sr->andx_com = (unsigned char)-1;
751 791 }
752 792
753 793 mutex_enter(&sr->sr_mutex);
754 794 switch (sr->sr_state) {
755 - case SMB_REQ_STATE_SUBMITTED:
795 + case SMB_REQ_STATE_ACTIVE:
796 + break;
756 797 case SMB_REQ_STATE_CLEANED_UP:
757 798 sr->sr_state = SMB_REQ_STATE_ACTIVE;
758 799 break;
759 - case SMB_REQ_STATE_CANCELED:
800 + case SMB_REQ_STATE_CANCELLED:
801 + /*
802 + * Keep cancelled. Handlers that might block will
803 + * check the state and return NT_STATUS_CANCELLED.
804 + */
760 805 break;
761 806 default:
762 807 ASSERT(0);
763 808 break;
764 809 }
765 810 mutex_exit(&sr->sr_mutex);
766 811
767 812 /*
768 813 * Setup UID and TID information (if required). Both functions
769 814 * will set the sr credentials. In domain mode, the user and
770 815 * tree credentials should be the same. In share mode, the
771 816 * tree credentials (defined in the share definition) should
772 817 * override the user credentials.
773 818 */
774 819 if (!(sdd->sdt_flags & SDDF_SUPPRESS_UID) && (sr->uid_user == NULL)) {
775 820 sr->uid_user = smb_session_lookup_uid(session, sr->smb_uid);
776 821 if (sr->uid_user == NULL) {
777 822 smbsr_error(sr, 0, ERRSRV, ERRbaduid);
778 823 smbsr_cleanup(sr);
779 824 goto report_error;
780 825 }
781 826
782 827 sr->user_cr = smb_user_getcred(sr->uid_user);
783 828 }
784 829 if (!(sdd->sdt_flags & SDDF_SUPPRESS_TID) && (sr->tid_tree == NULL)) {
785 830 sr->tid_tree = smb_session_lookup_tree(session, sr->smb_tid);
786 831 if (sr->tid_tree == NULL) {
787 832 smbsr_error(sr, 0, ERRSRV, ERRinvnid);
788 833 smbsr_cleanup(sr);
789 834 goto report_error;
790 835 }
|
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
791 836 }
792 837
793 838 sr->sr_time_start = gethrtime();
794 839 if ((sdrc = (*sdd->sdt_pre_op)(sr)) == SDRC_SUCCESS)
795 840 sdrc = (*sdd->sdt_function)(sr);
796 841
797 842 if (sdrc != SDRC_SR_KEPT) {
798 843 (*sdd->sdt_post_op)(sr);
799 844 smbsr_cleanup(sr);
800 845 }
801 - smb_latency_add_sample(&sds->sdt_lat, gethrtime() - sr->sr_time_start);
802 846
803 - atomic_add_64(&sds->sdt_txb,
804 - (int64_t)(sr->reply.chain_offset - sr->sr_txb));
847 + /* Record latency and rx/tx bytes per: server, session, share. */
848 + {
849 + hrtime_t dt;
850 + int64_t rxb, txb;
851 + smb_disp_stats_t *client_sds; /* session */
852 + smb_disp_stats_t *share_sds; /* kshare */
853 + int cmd_type;
805 854
855 + if (sdd->sdt_flags & SDDF_READOP) {
856 + cmd_type = SMBSRV_CLSH_READ;
857 + } else if (sdd->sdt_flags & SDDF_WRITEOP) {
858 + cmd_type = SMBSRV_CLSH_WRITE;
859 + } else {
860 + cmd_type = SMBSRV_CLSH_OTHER;
861 + }
862 +
863 + dt = gethrtime() - sr->sr_time_start;
864 + rxb = (int64_t)rxbytes;
865 + txb = (int64_t)(sr->reply.chain_offset - txbase);
866 +
867 + smb_server_inc_req(server);
868 + smb_latency_add_sample(&sds->sdt_lat, dt);
869 + atomic_add_64(&sds->sdt_rxb, rxb);
870 + atomic_add_64(&sds->sdt_txb, txb);
871 +
872 + client_sds = &session->s_stats[cmd_type];
873 + smb_latency_add_sample(&client_sds->sdt_lat, dt);
874 + atomic_add_64(&client_sds->sdt_rxb, rxb);
875 + atomic_add_64(&client_sds->sdt_txb, txb);
876 +
877 + if ((sr->tid_tree != NULL) &&
878 + (sr->tid_tree->t_kshare != NULL)) {
879 + share_sds =
880 + &sr->tid_tree->t_kshare->shr_stats[cmd_type];
881 + smb_latency_add_sample(&share_sds->sdt_lat, dt);
882 + atomic_add_64(&share_sds->sdt_rxb, rxb);
883 + atomic_add_64(&share_sds->sdt_txb, txb);
884 + }
885 + }
886 +
806 887 switch (sdrc) {
807 888 case SDRC_SUCCESS:
808 889 break;
809 890
810 891 case SDRC_DROP_VC:
811 892 disconnect = B_TRUE;
812 893 goto drop_connection;
813 894
814 895 case SDRC_NO_REPLY:
815 896 /* will free sr */
816 897 goto out;
817 898
818 899 case SDRC_SR_KEPT:
819 900 /* Do NOT free sr */
820 901 sr = NULL;
821 902 goto out;
822 903
823 904 case SDRC_ERROR:
824 905 goto report_error;
825 906
826 907 case SDRC_NOT_IMPLEMENTED:
827 908 default:
828 909 smbsr_error(sr, 0, ERRDOS, ERRbadfunc);
829 910 goto report_error;
830 911 }
831 912
832 913 /*
833 914 * If there's no AndX command, we're done.
834 915 */
835 916 if (sr->andx_com == 0xff)
836 917 goto reply_ready;
837 918
838 919 /*
839 920 * Otherwise, we have to back-patch the AndXCommand and AndXOffset
840 921 * and continue processing.
841 922 */
842 923 sr->andx_prev_wct = sr->cur_reply_offset;
843 924 (void) smb_mbc_poke(&sr->reply, sr->andx_prev_wct + 1, "b.w",
844 925 sr->andx_com, MBC_LENGTH(&sr->reply));
845 926
846 927 sr->command.chain_offset = sr->orig_request_hdr + sr->andx_off;
847 928 sr->smb_com = sr->andx_com;
848 929 goto andx_more;
849 930
850 931 report_error:
851 932 sr->reply.chain_offset = sr->cur_reply_offset;
852 933 (void) smb_mbc_encodef(&sr->reply, "bw", 0, 0);
853 934
|
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
854 935 sr->smb_wct = 0;
855 936 sr->smb_bcc = 0;
856 937
857 938 if (sr->smb_rcls == 0 && sr->smb_reh == 0 && sr->smb_err == 0)
858 939 smbsr_error(sr, 0, ERRSRV, ERRerror);
859 940
860 941 reply_ready:
861 942 smbsr_send_reply(sr);
862 943
863 944 drop_connection:
864 - if (disconnect) {
865 - smb_rwx_rwenter(&session->s_lock, RW_WRITER);
866 - switch (session->s_state) {
867 - case SMB_SESSION_STATE_DISCONNECTED:
868 - case SMB_SESSION_STATE_TERMINATED:
869 - break;
870 - default:
871 - smb_soshutdown(session->sock);
872 - session->s_state = SMB_SESSION_STATE_DISCONNECTED;
873 - break;
874 - }
875 - smb_rwx_rwexit(&session->s_lock);
876 - }
945 + if (disconnect)
946 + smb_session_disconnect(session);
877 947
878 948 out:
879 949 if (sr != NULL) {
880 950 mutex_enter(&sr->sr_mutex);
881 951 sr->sr_state = SMB_REQ_STATE_COMPLETED;
882 952 mutex_exit(&sr->sr_mutex);
883 953 smb_request_free(sr);
884 954 }
885 955 }
886 956
887 957 int
888 958 smbsr_encode_empty_result(struct smb_request *sr)
889 959 {
890 960 return (smbsr_encode_result(sr, 0, 0, "bw", 0, 0));
891 961 }
892 962
893 963 int
894 964 smbsr_encode_result(struct smb_request *sr, int wct, int bcc,
895 965 const char *fmt, ...)
896 966 {
897 967 va_list ap;
898 968
899 969 if (MBC_LENGTH(&sr->reply) != sr->cur_reply_offset)
900 970 return (-1);
901 971
902 972 va_start(ap, fmt);
903 973 (void) smb_mbc_vencodef(&sr->reply, fmt, ap);
904 974 va_end(ap);
905 975
906 976 sr->smb_wct = (unsigned char)wct;
907 977 sr->smb_bcc = (uint16_t)bcc;
908 978
909 979 if (smbsr_check_result(sr, wct, bcc) != 0)
910 980 return (-1);
911 981
912 982 return (0);
913 983 }
914 984
915 985 static int
916 986 smbsr_check_result(struct smb_request *sr, int wct, int bcc)
917 987 {
918 988 int offset = sr->cur_reply_offset;
919 989 int total_bytes;
920 990 unsigned char temp, temp1;
921 991 struct mbuf *m;
922 992
923 993 total_bytes = 0;
924 994 m = sr->reply.chain;
925 995 while (m != 0) {
926 996 total_bytes += m->m_len;
927 997 m = m->m_next;
928 998 }
929 999
930 1000 if ((offset + 3) > total_bytes)
931 1001 return (-1);
932 1002
933 1003 (void) smb_mbc_peek(&sr->reply, offset, "b", &temp);
934 1004 if (temp != wct)
935 1005 return (-1);
936 1006
937 1007 if ((offset + (wct * 2 + 1)) > total_bytes)
938 1008 return (-1);
939 1009
940 1010 /* reply wct & vwv seem ok, consider data now */
941 1011 offset += wct * 2 + 1;
942 1012
943 1013 if ((offset + 2) > total_bytes)
944 1014 return (-1);
945 1015
946 1016 (void) smb_mbc_peek(&sr->reply, offset, "bb", &temp, &temp1);
947 1017 if (bcc == VAR_BCC) {
948 1018 if ((temp != 0xFF) || (temp1 != 0xFF)) {
949 1019 return (-1);
950 1020 } else {
951 1021 bcc = (total_bytes - offset) - 2;
952 1022 (void) smb_mbc_poke(&sr->reply, offset, "bb",
953 1023 bcc, bcc >> 8);
954 1024 }
955 1025 } else {
956 1026 if ((temp != (bcc&0xFF)) || (temp1 != ((bcc>>8)&0xFF)))
957 1027 return (-1);
958 1028 }
959 1029
960 1030 offset += bcc + 2;
961 1031
962 1032 if (offset != total_bytes)
963 1033 return (-1);
964 1034
965 1035 sr->smb_wct = (unsigned char)wct;
966 1036 sr->smb_bcc = (uint16_t)bcc;
967 1037 return (0);
968 1038 }
969 1039
970 1040 int
971 1041 smbsr_decode_vwv(struct smb_request *sr, const char *fmt, ...)
972 1042 {
973 1043 int rc;
974 1044 va_list ap;
975 1045
976 1046 va_start(ap, fmt);
977 1047 rc = smb_mbc_vdecodef(&sr->smb_vwv, fmt, ap);
978 1048 va_end(ap);
979 1049
980 1050 if (rc)
981 1051 smbsr_error(sr, 0, ERRSRV, ERRerror);
982 1052 return (rc);
983 1053 }
984 1054
985 1055 int
986 1056 smbsr_decode_data(struct smb_request *sr, const char *fmt, ...)
987 1057 {
988 1058 int rc;
989 1059 va_list ap;
990 1060
991 1061 va_start(ap, fmt);
992 1062 rc = smb_mbc_vdecodef(&sr->smb_data, fmt, ap);
993 1063 va_end(ap);
994 1064
995 1065 if (rc)
996 1066 smbsr_error(sr, 0, ERRSRV, ERRerror);
997 1067 return (rc);
998 1068 }
999 1069
1000 1070 boolean_t
1001 1071 smbsr_decode_data_avail(smb_request_t *sr)
1002 1072 {
1003 1073 return (sr->smb_data.chain_offset < sr->smb_data.max_bytes);
1004 1074 }
1005 1075
1006 1076 void
1007 1077 smbsr_send_reply(smb_request_t *sr)
1008 1078 {
1009 1079 uint16_t pid_hi, pid_lo;
1010 1080
1011 1081 if (SMB_TREE_IS_CASEINSENSITIVE(sr))
1012 1082 sr->smb_flg |= SMB_FLAGS_CASE_INSENSITIVE;
1013 1083 else
1014 1084 sr->smb_flg &= ~SMB_FLAGS_CASE_INSENSITIVE;
1015 1085 pid_hi = sr->smb_pid >> 16;
1016 1086 pid_lo = (uint16_t)sr->smb_pid;
1017 1087
1018 1088 (void) smb_mbc_poke(&sr->reply, 0, SMB_HEADER_ED_FMT,
1019 1089 sr->first_smb_com,
1020 1090 sr->smb_rcls,
1021 1091 sr->smb_reh,
1022 1092 sr->smb_err,
1023 1093 sr->smb_flg | SMB_FLAGS_REPLY,
1024 1094 sr->smb_flg2,
1025 1095 pid_hi,
1026 1096 sr->smb_sig,
1027 1097 sr->smb_tid,
1028 1098 pid_lo,
1029 1099 sr->smb_uid,
1030 1100 sr->smb_mid);
1031 1101
1032 1102 if (sr->session->signing.flags & SMB_SIGNING_ENABLED)
1033 1103 smb_sign_reply(sr, NULL);
1034 1104
1035 1105 if (smb_session_send(sr->session, 0, &sr->reply) == 0)
1036 1106 sr->reply.chain = 0;
1037 1107 }
1038 1108
1039 1109 void
1040 1110 smbsr_map_errno(int errnum, smb_error_t *err)
1041 1111 {
1042 1112 uint32_t status;
1043 1113 uint16_t doserr;
1044 1114
1045 1115 status = smb_errno2status(errnum);
1046 1116 doserr = smb_status2doserr(status);
1047 1117
1048 1118 err->status = status;
1049 1119 err->errcls = ERRDOS;
1050 1120 err->errcode = doserr;
1051 1121 }
1052 1122
1053 1123 void
1054 1124 smbsr_errno(struct smb_request *sr, int errnum)
1055 1125 {
1056 1126 smbsr_map_errno(errnum, &sr->smb_error);
1057 1127 smbsr_set_error(sr, &sr->smb_error);
1058 1128 }
1059 1129
1060 1130 /*
1061 1131 * Report a request processing status (error or warning).
1062 1132 */
1063 1133 void
1064 1134 smbsr_status(smb_request_t *sr, DWORD status, uint16_t errcls, uint16_t errcode)
1065 1135 {
1066 1136
1067 1137 sr->smb_error.status = status;
1068 1138
1069 1139 /*
1070 1140 * This function is SMB1 specific. While adding SMB2 support,
1071 1141 * calls to this function have been removed from common code.
1072 1142 * In case we missed any, check for SMB2 callers here, and
1073 1143 * vector into a wrapper function that we can watch for...
1074 1144 * (and track down with dtrace:)
1075 1145 */
1076 1146 if (sr->session->dialect >= SMB_VERS_2_BASE) {
1077 1147 smbsr_status_smb2(sr, status);
1078 1148 return;
1079 1149 }
1080 1150
1081 1151 if (status != 0 && errcls == 0 && errcode == 0) {
1082 1152 errcls = ERRDOS;
1083 1153 errcode = smb_status2doserr(status);
1084 1154 }
1085 1155
1086 1156 sr->smb_error.errcls = errcls;
1087 1157 sr->smb_error.errcode = errcode;
1088 1158
1089 1159 smbsr_set_error(sr, &sr->smb_error);
1090 1160 }
1091 1161
1092 1162 /*
1093 1163 * Setup a request processing error. This function can be used to
1094 1164 * report 32-bit status codes or DOS errors. Set the status code
1095 1165 * to 0 (NT_STATUS_SUCCESS) to explicitly report a DOS error,
1096 1166 * regardless of the client capabilities.
1097 1167 *
1098 1168 * If status is non-zero and the client supports 32-bit status
1099 1169 * codes, report the status. Otherwise, report the DOS error.
1100 1170 */
1101 1171 void
1102 1172 smbsr_set_error(smb_request_t *sr, smb_error_t *err)
1103 1173 {
1104 1174 uint32_t status;
1105 1175 uint32_t capabilities;
1106 1176
1107 1177 ASSERT(sr);
1108 1178 ASSERT(err);
1109 1179
1110 1180 status = err->status;
1111 1181 capabilities = sr->session->capabilities;
1112 1182
1113 1183 if ((err->errcls == 0) && (err->errcode == 0)) {
1114 1184 capabilities |= CAP_STATUS32;
1115 1185 if (status == 0)
1116 1186 status = NT_STATUS_INTERNAL_ERROR;
1117 1187 }
1118 1188
1119 1189 if ((capabilities & CAP_STATUS32) && (status != 0)) {
1120 1190 sr->smb_rcls = status & 0xff;
1121 1191 sr->smb_reh = (status >> 8) & 0xff;
1122 1192 sr->smb_err = status >> 16;
1123 1193 sr->smb_flg2 |= SMB_FLAGS2_NT_STATUS;
1124 1194 } else {
1125 1195 if ((err->errcls == 0) || (err->errcode == 0)) {
1126 1196 sr->smb_rcls = ERRSRV;
1127 1197 sr->smb_err = ERRerror;
1128 1198 } else {
1129 1199 sr->smb_rcls = (uint8_t)err->errcls;
1130 1200 sr->smb_err = (uint16_t)err->errcode;
1131 1201 }
1132 1202 }
1133 1203 }
1134 1204
1135 1205 smb_xa_t *
1136 1206 smbsr_lookup_xa(smb_request_t *sr)
1137 1207 {
1138 1208 ASSERT(sr->r_xa == 0);
1139 1209
1140 1210 sr->r_xa = smb_xa_find(sr->session, sr->smb_pid, sr->smb_mid);
1141 1211 return (sr->r_xa);
1142 1212 }
1143 1213
1144 1214 void
1145 1215 smbsr_release_file(smb_request_t *sr)
1146 1216 {
1147 1217 smb_ofile_t *of = sr->fid_ofile;
1148 1218
1149 1219 sr->fid_ofile = NULL;
1150 1220 (void) smb_ofile_release(of);
1151 1221 }
1152 1222
1153 1223 void
1154 1224 smbsr_lookup_file(smb_request_t *sr)
1155 1225 {
1156 1226 if (sr->fid_ofile == NULL)
1157 1227 sr->fid_ofile = smb_ofile_lookup_by_fid(sr, sr->smb_fid);
1158 1228 }
1159 1229
1160 1230 static int
1161 1231 is_andx_com(unsigned char com)
1162 1232 {
1163 1233 switch (com) {
1164 1234 case SMB_COM_LOCKING_ANDX:
1165 1235 case SMB_COM_OPEN_ANDX:
1166 1236 case SMB_COM_READ_ANDX:
1167 1237 case SMB_COM_WRITE_ANDX:
1168 1238 case SMB_COM_SESSION_SETUP_ANDX:
1169 1239 case SMB_COM_LOGOFF_ANDX:
1170 1240 case SMB_COM_TREE_CONNECT_ANDX:
1171 1241 case SMB_COM_NT_CREATE_ANDX:
1172 1242 return (1);
1173 1243 }
1174 1244 return (0);
1175 1245 }
1176 1246
1177 1247 /*
1178 1248 * Invalid command stubs.
|
↓ open down ↓ |
292 lines elided |
↑ open up ↑ |
1179 1249 *
1180 1250 * The Read/Write Block Multiplexed (mpx) protocol is used to maximize
1181 1251 * performance when reading/writing a large block of data: it can be
1182 1252 * used in parallel with other client/server operations. The mpx sub-
1183 1253 * protocol is not supported because we support only connection oriented
1184 1254 * transports and NT supports mpx only over connectionless transports.
1185 1255 */
1186 1256 smb_sdrc_t
1187 1257 smb_pre_invalid(smb_request_t *sr)
1188 1258 {
1189 - DTRACE_SMB_1(op__Invalid__start, smb_request_t *, sr);
1259 + DTRACE_SMB_START(op__Invalid, smb_request_t *, sr);
1190 1260 return (SDRC_SUCCESS);
1191 1261 }
1192 1262
1193 1263 void
1194 1264 smb_post_invalid(smb_request_t *sr)
1195 1265 {
1196 - DTRACE_SMB_1(op__Invalid__done, smb_request_t *, sr);
1266 + DTRACE_SMB_DONE(op__Invalid, smb_request_t *, sr);
1197 1267 }
1198 1268
1199 1269 smb_sdrc_t
1200 1270 smb_com_invalid(smb_request_t *sr)
1201 1271 {
1202 1272 smb_sdrc_t sdrc;
1203 1273
1204 1274 switch (sr->smb_com) {
1205 1275 case SMB_COM_WRITE_COMPLETE:
1206 1276 smbsr_error(sr, 0, ERRSRV, ERRerror);
1207 1277 sdrc = SDRC_ERROR;
1208 1278 break;
1209 1279
1210 1280 default:
1211 1281 smbsr_error(sr, NT_STATUS_NOT_IMPLEMENTED,
1212 1282 ERRDOS, ERROR_INVALID_FUNCTION);
1213 1283 sdrc = SDRC_NOT_IMPLEMENTED;
1214 1284 break;
1215 1285 }
1216 1286
1217 1287 return (sdrc);
1218 1288 }
1219 1289
1220 1290 /*
1221 1291 * smb_dispatch_stats_init
1222 1292 *
1223 1293 * Initializes dispatch statistics.
1224 1294 */
1225 1295 void
1226 1296 smb_dispatch_stats_init(smb_server_t *sv)
1227 1297 {
1228 1298 smb_disp_stats_t *sds = sv->sv_disp_stats1;
1229 1299 smb_kstat_req_t *ksr;
1230 1300 int i;
1231 1301
1232 1302 ksr = ((smbsrv_kstats_t *)sv->sv_ksp->ks_data)->ks_reqs1;
1233 1303
1234 1304 for (i = 0; i < SMB_COM_NUM; i++, ksr++) {
1235 1305 smb_latency_init(&sds[i].sdt_lat);
1236 1306 (void) strlcpy(ksr->kr_name, smb_disp_table[i].sdt_name,
1237 1307 sizeof (ksr->kr_name));
1238 1308 }
1239 1309 }
1240 1310
1241 1311 /*
1242 1312 * smb_dispatch_stats_fini
1243 1313 *
1244 1314 * Frees and destroyes the resources used for statistics.
1245 1315 */
1246 1316 void
1247 1317 smb_dispatch_stats_fini(smb_server_t *sv)
1248 1318 {
1249 1319 smb_disp_stats_t *sds = sv->sv_disp_stats1;
1250 1320 int i;
1251 1321
1252 1322 for (i = 0; i < SMB_COM_NUM; i++)
1253 1323 smb_latency_destroy(&sds[i].sdt_lat);
1254 1324 }
1255 1325
1256 1326 void
1257 1327 smb_dispatch_stats_update(smb_server_t *sv,
1258 1328 smb_kstat_req_t *ksr, int first, int nreq)
1259 1329 {
1260 1330 smb_disp_stats_t *sds = sv->sv_disp_stats1;
1261 1331 int i;
1262 1332 int last;
1263 1333
1264 1334 last = first + nreq - 1;
1265 1335
1266 1336 if ((first < SMB_COM_NUM) && (last < SMB_COM_NUM)) {
1267 1337 for (i = first; i <= last; i++, ksr++) {
1268 1338 ksr->kr_rxb = sds[i].sdt_rxb;
1269 1339 ksr->kr_txb = sds[i].sdt_txb;
1270 1340 mutex_enter(&sds[i].sdt_lat.ly_mutex);
1271 1341 ksr->kr_nreq = sds[i].sdt_lat.ly_a_nreq;
1272 1342 ksr->kr_sum = sds[i].sdt_lat.ly_a_sum;
1273 1343 ksr->kr_a_mean = sds[i].sdt_lat.ly_a_mean;
1274 1344 ksr->kr_a_stddev =
1275 1345 sds[i].sdt_lat.ly_a_stddev;
1276 1346 ksr->kr_d_mean = sds[i].sdt_lat.ly_d_mean;
1277 1347 ksr->kr_d_stddev =
1278 1348 sds[i].sdt_lat.ly_d_stddev;
1279 1349 sds[i].sdt_lat.ly_d_mean = 0;
1280 1350 sds[i].sdt_lat.ly_d_nreq = 0;
1281 1351 sds[i].sdt_lat.ly_d_stddev = 0;
1282 1352 sds[i].sdt_lat.ly_d_sum = 0;
1283 1353 mutex_exit(&sds[i].sdt_lat.ly_mutex);
1284 1354 }
1285 1355 }
1286 1356 }
|
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX