]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - fs/cifs/smb2ops.c
Allow setting per-file compression via SMB2/3
[mirror_ubuntu-artful-kernel.git] / fs / cifs / smb2ops.c
1 /*
2 * SMB2 version specific operations
3 *
4 * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
5 *
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2 as published
8 * by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 #include <linux/pagemap.h>
21 #include <linux/vfs.h>
22 #include "cifsglob.h"
23 #include "smb2pdu.h"
24 #include "smb2proto.h"
25 #include "cifsproto.h"
26 #include "cifs_debug.h"
27 #include "cifs_unicode.h"
28 #include "smb2status.h"
29 #include "smb2glob.h"
30
31 static int
32 change_conf(struct TCP_Server_Info *server)
33 {
34 server->credits += server->echo_credits + server->oplock_credits;
35 server->oplock_credits = server->echo_credits = 0;
36 switch (server->credits) {
37 case 0:
38 return -1;
39 case 1:
40 server->echoes = false;
41 server->oplocks = false;
42 cifs_dbg(VFS, "disabling echoes and oplocks\n");
43 break;
44 case 2:
45 server->echoes = true;
46 server->oplocks = false;
47 server->echo_credits = 1;
48 cifs_dbg(FYI, "disabling oplocks\n");
49 break;
50 default:
51 server->echoes = true;
52 server->oplocks = true;
53 server->echo_credits = 1;
54 server->oplock_credits = 1;
55 }
56 server->credits -= server->echo_credits + server->oplock_credits;
57 return 0;
58 }
59
60 static void
61 smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
62 const int optype)
63 {
64 int *val, rc = 0;
65 spin_lock(&server->req_lock);
66 val = server->ops->get_credits_field(server, optype);
67 *val += add;
68 server->in_flight--;
69 if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
70 rc = change_conf(server);
71 /*
72 * Sometimes server returns 0 credits on oplock break ack - we need to
73 * rebalance credits in this case.
74 */
75 else if (server->in_flight > 0 && server->oplock_credits == 0 &&
76 server->oplocks) {
77 if (server->credits > 1) {
78 server->credits--;
79 server->oplock_credits++;
80 }
81 }
82 spin_unlock(&server->req_lock);
83 wake_up(&server->request_q);
84 if (rc)
85 cifs_reconnect(server);
86 }
87
88 static void
89 smb2_set_credits(struct TCP_Server_Info *server, const int val)
90 {
91 spin_lock(&server->req_lock);
92 server->credits = val;
93 spin_unlock(&server->req_lock);
94 }
95
96 static int *
97 smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
98 {
99 switch (optype) {
100 case CIFS_ECHO_OP:
101 return &server->echo_credits;
102 case CIFS_OBREAK_OP:
103 return &server->oplock_credits;
104 default:
105 return &server->credits;
106 }
107 }
108
109 static unsigned int
110 smb2_get_credits(struct mid_q_entry *mid)
111 {
112 return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
113 }
114
115 static __u64
116 smb2_get_next_mid(struct TCP_Server_Info *server)
117 {
118 __u64 mid;
119 /* for SMB2 we need the current value */
120 spin_lock(&GlobalMid_Lock);
121 mid = server->CurrentMid++;
122 spin_unlock(&GlobalMid_Lock);
123 return mid;
124 }
125
126 static struct mid_q_entry *
127 smb2_find_mid(struct TCP_Server_Info *server, char *buf)
128 {
129 struct mid_q_entry *mid;
130 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
131
132 spin_lock(&GlobalMid_Lock);
133 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
134 if ((mid->mid == hdr->MessageId) &&
135 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
136 (mid->command == hdr->Command)) {
137 spin_unlock(&GlobalMid_Lock);
138 return mid;
139 }
140 }
141 spin_unlock(&GlobalMid_Lock);
142 return NULL;
143 }
144
145 static void
146 smb2_dump_detail(void *buf)
147 {
148 #ifdef CONFIG_CIFS_DEBUG2
149 struct smb2_hdr *smb = (struct smb2_hdr *)buf;
150
151 cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
152 smb->Command, smb->Status, smb->Flags, smb->MessageId,
153 smb->ProcessId);
154 cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
155 #endif
156 }
157
158 static bool
159 smb2_need_neg(struct TCP_Server_Info *server)
160 {
161 return server->max_read == 0;
162 }
163
164 static int
165 smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
166 {
167 int rc;
168 ses->server->CurrentMid = 0;
169 rc = SMB2_negotiate(xid, ses);
170 /* BB we probably don't need to retry with modern servers */
171 if (rc == -EAGAIN)
172 rc = -EHOSTDOWN;
173 return rc;
174 }
175
176 static unsigned int
177 smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
178 {
179 struct TCP_Server_Info *server = tcon->ses->server;
180 unsigned int wsize;
181
182 /* start with specified wsize, or default */
183 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
184 wsize = min_t(unsigned int, wsize, server->max_write);
185 /*
186 * limit write size to 2 ** 16, because we don't support multicredit
187 * requests now.
188 */
189 wsize = min_t(unsigned int, wsize, 2 << 15);
190
191 return wsize;
192 }
193
194 static unsigned int
195 smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
196 {
197 struct TCP_Server_Info *server = tcon->ses->server;
198 unsigned int rsize;
199
200 /* start with specified rsize, or default */
201 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
202 rsize = min_t(unsigned int, rsize, server->max_read);
203 /*
204 * limit write size to 2 ** 16, because we don't support multicredit
205 * requests now.
206 */
207 rsize = min_t(unsigned int, rsize, 2 << 15);
208
209 return rsize;
210 }
211
212 static int
213 smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
214 struct cifs_sb_info *cifs_sb, const char *full_path)
215 {
216 int rc;
217 __le16 *utf16_path;
218 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
219 struct cifs_open_parms oparms;
220 struct cifs_fid fid;
221
222 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
223 if (!utf16_path)
224 return -ENOMEM;
225
226 oparms.tcon = tcon;
227 oparms.desired_access = FILE_READ_ATTRIBUTES;
228 oparms.disposition = FILE_OPEN;
229 oparms.create_options = 0;
230 oparms.fid = &fid;
231 oparms.reconnect = false;
232
233 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
234 if (rc) {
235 kfree(utf16_path);
236 return rc;
237 }
238
239 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
240 kfree(utf16_path);
241 return rc;
242 }
243
244 static int
245 smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
246 struct cifs_sb_info *cifs_sb, const char *full_path,
247 u64 *uniqueid, FILE_ALL_INFO *data)
248 {
249 *uniqueid = le64_to_cpu(data->IndexNumber);
250 return 0;
251 }
252
253 static int
254 smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
255 struct cifs_fid *fid, FILE_ALL_INFO *data)
256 {
257 int rc;
258 struct smb2_file_all_info *smb2_data;
259
260 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
261 GFP_KERNEL);
262 if (smb2_data == NULL)
263 return -ENOMEM;
264
265 rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
266 smb2_data);
267 if (!rc)
268 move_smb2_info_to_cifs(data, smb2_data);
269 kfree(smb2_data);
270 return rc;
271 }
272
273 static bool
274 smb2_can_echo(struct TCP_Server_Info *server)
275 {
276 return server->echoes;
277 }
278
279 static void
280 smb2_clear_stats(struct cifs_tcon *tcon)
281 {
282 #ifdef CONFIG_CIFS_STATS
283 int i;
284 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
285 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
286 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
287 }
288 #endif
289 }
290
291 static void
292 smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
293 {
294 seq_puts(m, "\n\tShare Capabilities:");
295 if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
296 seq_puts(m, " DFS,");
297 if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
298 seq_puts(m, " CONTINUOUS AVAILABILITY,");
299 if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
300 seq_puts(m, " SCALEOUT,");
301 if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
302 seq_puts(m, " CLUSTER,");
303 if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
304 seq_puts(m, " ASYMMETRIC,");
305 if (tcon->capabilities == 0)
306 seq_puts(m, " None");
307 seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
308 }
309
310 static void
311 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
312 {
313 #ifdef CONFIG_CIFS_STATS
314 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
315 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
316 seq_printf(m, "\nNegotiates: %d sent %d failed",
317 atomic_read(&sent[SMB2_NEGOTIATE_HE]),
318 atomic_read(&failed[SMB2_NEGOTIATE_HE]));
319 seq_printf(m, "\nSessionSetups: %d sent %d failed",
320 atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
321 atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
322 seq_printf(m, "\nLogoffs: %d sent %d failed",
323 atomic_read(&sent[SMB2_LOGOFF_HE]),
324 atomic_read(&failed[SMB2_LOGOFF_HE]));
325 seq_printf(m, "\nTreeConnects: %d sent %d failed",
326 atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
327 atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
328 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
329 atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
330 atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
331 seq_printf(m, "\nCreates: %d sent %d failed",
332 atomic_read(&sent[SMB2_CREATE_HE]),
333 atomic_read(&failed[SMB2_CREATE_HE]));
334 seq_printf(m, "\nCloses: %d sent %d failed",
335 atomic_read(&sent[SMB2_CLOSE_HE]),
336 atomic_read(&failed[SMB2_CLOSE_HE]));
337 seq_printf(m, "\nFlushes: %d sent %d failed",
338 atomic_read(&sent[SMB2_FLUSH_HE]),
339 atomic_read(&failed[SMB2_FLUSH_HE]));
340 seq_printf(m, "\nReads: %d sent %d failed",
341 atomic_read(&sent[SMB2_READ_HE]),
342 atomic_read(&failed[SMB2_READ_HE]));
343 seq_printf(m, "\nWrites: %d sent %d failed",
344 atomic_read(&sent[SMB2_WRITE_HE]),
345 atomic_read(&failed[SMB2_WRITE_HE]));
346 seq_printf(m, "\nLocks: %d sent %d failed",
347 atomic_read(&sent[SMB2_LOCK_HE]),
348 atomic_read(&failed[SMB2_LOCK_HE]));
349 seq_printf(m, "\nIOCTLs: %d sent %d failed",
350 atomic_read(&sent[SMB2_IOCTL_HE]),
351 atomic_read(&failed[SMB2_IOCTL_HE]));
352 seq_printf(m, "\nCancels: %d sent %d failed",
353 atomic_read(&sent[SMB2_CANCEL_HE]),
354 atomic_read(&failed[SMB2_CANCEL_HE]));
355 seq_printf(m, "\nEchos: %d sent %d failed",
356 atomic_read(&sent[SMB2_ECHO_HE]),
357 atomic_read(&failed[SMB2_ECHO_HE]));
358 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
359 atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
360 atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
361 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
362 atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
363 atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
364 seq_printf(m, "\nQueryInfos: %d sent %d failed",
365 atomic_read(&sent[SMB2_QUERY_INFO_HE]),
366 atomic_read(&failed[SMB2_QUERY_INFO_HE]));
367 seq_printf(m, "\nSetInfos: %d sent %d failed",
368 atomic_read(&sent[SMB2_SET_INFO_HE]),
369 atomic_read(&failed[SMB2_SET_INFO_HE]));
370 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
371 atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
372 atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
373 #endif
374 }
375
376 static void
377 smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
378 {
379 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
380 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
381
382 cfile->fid.persistent_fid = fid->persistent_fid;
383 cfile->fid.volatile_fid = fid->volatile_fid;
384 server->ops->set_oplock_level(cinode, oplock, fid->epoch,
385 &fid->purge_cache);
386 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
387 }
388
389 static void
390 smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
391 struct cifs_fid *fid)
392 {
393 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
394 }
395
396 static int
397 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
398 struct cifs_fid *fid)
399 {
400 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
401 }
402
403 static unsigned int
404 smb2_read_data_offset(char *buf)
405 {
406 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
407 return rsp->DataOffset;
408 }
409
410 static unsigned int
411 smb2_read_data_length(char *buf)
412 {
413 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
414 return le32_to_cpu(rsp->DataLength);
415 }
416
417
418 static int
419 smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
420 struct cifs_io_parms *parms, unsigned int *bytes_read,
421 char **buf, int *buf_type)
422 {
423 parms->persistent_fid = cfile->fid.persistent_fid;
424 parms->volatile_fid = cfile->fid.volatile_fid;
425 return SMB2_read(xid, parms, bytes_read, buf, buf_type);
426 }
427
428 static int
429 smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
430 struct cifs_io_parms *parms, unsigned int *written,
431 struct kvec *iov, unsigned long nr_segs)
432 {
433
434 parms->persistent_fid = cfile->fid.persistent_fid;
435 parms->volatile_fid = cfile->fid.volatile_fid;
436 return SMB2_write(xid, parms, written, iov, nr_segs);
437 }
438
439 static int
440 smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
441 struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
442 {
443 __le64 eof = cpu_to_le64(size);
444 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
445 cfile->fid.volatile_fid, cfile->pid, &eof);
446 }
447
448 static int
449 smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
450 struct cifsFileInfo *cfile)
451 {
452 return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,
453 cfile->fid.volatile_fid);
454 }
455
456 static int
457 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
458 const char *path, struct cifs_sb_info *cifs_sb,
459 struct cifs_fid *fid, __u16 search_flags,
460 struct cifs_search_info *srch_inf)
461 {
462 __le16 *utf16_path;
463 int rc;
464 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
465 struct cifs_open_parms oparms;
466
467 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
468 if (!utf16_path)
469 return -ENOMEM;
470
471 oparms.tcon = tcon;
472 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
473 oparms.disposition = FILE_OPEN;
474 oparms.create_options = 0;
475 oparms.fid = fid;
476 oparms.reconnect = false;
477
478 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
479 kfree(utf16_path);
480 if (rc) {
481 cifs_dbg(VFS, "open dir failed\n");
482 return rc;
483 }
484
485 srch_inf->entries_in_buffer = 0;
486 srch_inf->index_of_last_entry = 0;
487
488 rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
489 fid->volatile_fid, 0, srch_inf);
490 if (rc) {
491 cifs_dbg(VFS, "query directory failed\n");
492 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
493 }
494 return rc;
495 }
496
497 static int
498 smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
499 struct cifs_fid *fid, __u16 search_flags,
500 struct cifs_search_info *srch_inf)
501 {
502 return SMB2_query_directory(xid, tcon, fid->persistent_fid,
503 fid->volatile_fid, 0, srch_inf);
504 }
505
506 static int
507 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
508 struct cifs_fid *fid)
509 {
510 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
511 }
512
513 /*
514 * If we negotiate SMB2 protocol and get STATUS_PENDING - update
515 * the number of credits and return true. Otherwise - return false.
516 */
517 static bool
518 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
519 {
520 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
521
522 if (hdr->Status != STATUS_PENDING)
523 return false;
524
525 if (!length) {
526 spin_lock(&server->req_lock);
527 server->credits += le16_to_cpu(hdr->CreditRequest);
528 spin_unlock(&server->req_lock);
529 wake_up(&server->request_q);
530 }
531
532 return true;
533 }
534
535 static int
536 smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
537 struct cifsInodeInfo *cinode)
538 {
539 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
540 return SMB2_lease_break(0, tcon, cinode->lease_key,
541 smb2_get_lease_state(cinode));
542
543 return SMB2_oplock_break(0, tcon, fid->persistent_fid,
544 fid->volatile_fid,
545 CIFS_CACHE_READ(cinode) ? 1 : 0);
546 }
547
548 static int
549 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
550 struct kstatfs *buf)
551 {
552 int rc;
553 __le16 srch_path = 0; /* Null - open root of share */
554 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
555 struct cifs_open_parms oparms;
556 struct cifs_fid fid;
557
558 oparms.tcon = tcon;
559 oparms.desired_access = FILE_READ_ATTRIBUTES;
560 oparms.disposition = FILE_OPEN;
561 oparms.create_options = 0;
562 oparms.fid = &fid;
563 oparms.reconnect = false;
564
565 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
566 if (rc)
567 return rc;
568 buf->f_type = SMB2_MAGIC_NUMBER;
569 rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
570 buf);
571 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
572 return rc;
573 }
574
575 static bool
576 smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
577 {
578 return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
579 ob1->fid.volatile_fid == ob2->fid.volatile_fid;
580 }
581
582 static int
583 smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
584 __u64 length, __u32 type, int lock, int unlock, bool wait)
585 {
586 if (unlock && !lock)
587 type = SMB2_LOCKFLAG_UNLOCK;
588 return SMB2_lock(xid, tlink_tcon(cfile->tlink),
589 cfile->fid.persistent_fid, cfile->fid.volatile_fid,
590 current->tgid, length, offset, type, wait);
591 }
592
593 static void
594 smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
595 {
596 memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
597 }
598
599 static void
600 smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
601 {
602 memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
603 }
604
605 static void
606 smb2_new_lease_key(struct cifs_fid *fid)
607 {
608 get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE);
609 }
610
611 static int
612 smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
613 const char *full_path, char **target_path,
614 struct cifs_sb_info *cifs_sb)
615 {
616 int rc;
617 __le16 *utf16_path;
618 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
619 struct cifs_open_parms oparms;
620 struct cifs_fid fid;
621 struct smb2_err_rsp *err_buf = NULL;
622 struct smb2_symlink_err_rsp *symlink;
623 unsigned int sub_len, sub_offset;
624
625 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
626
627 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
628 if (!utf16_path)
629 return -ENOMEM;
630
631 oparms.tcon = tcon;
632 oparms.desired_access = FILE_READ_ATTRIBUTES;
633 oparms.disposition = FILE_OPEN;
634 oparms.create_options = 0;
635 oparms.fid = &fid;
636 oparms.reconnect = false;
637
638 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
639
640 if (!rc || !err_buf) {
641 kfree(utf16_path);
642 return -ENOENT;
643 }
644 /* open must fail on symlink - reset rc */
645 rc = 0;
646 symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
647 sub_len = le16_to_cpu(symlink->SubstituteNameLength);
648 sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
649 *target_path = cifs_strndup_from_utf16(
650 (char *)symlink->PathBuffer + sub_offset,
651 sub_len, true, cifs_sb->local_nls);
652 if (!(*target_path)) {
653 kfree(utf16_path);
654 return -ENOMEM;
655 }
656 convert_delimiter(*target_path, '/');
657 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
658 kfree(utf16_path);
659 return rc;
660 }
661
662 static void
663 smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
664 unsigned int epoch, bool *purge_cache)
665 {
666 oplock &= 0xFF;
667 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
668 return;
669 if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
670 cinode->oplock = CIFS_CACHE_RHW_FLG;
671 cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
672 &cinode->vfs_inode);
673 } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
674 cinode->oplock = CIFS_CACHE_RW_FLG;
675 cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
676 &cinode->vfs_inode);
677 } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
678 cinode->oplock = CIFS_CACHE_READ_FLG;
679 cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
680 &cinode->vfs_inode);
681 } else
682 cinode->oplock = 0;
683 }
684
685 static void
686 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
687 unsigned int epoch, bool *purge_cache)
688 {
689 char message[5] = {0};
690
691 oplock &= 0xFF;
692 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
693 return;
694
695 cinode->oplock = 0;
696 if (oplock & SMB2_LEASE_READ_CACHING_HE) {
697 cinode->oplock |= CIFS_CACHE_READ_FLG;
698 strcat(message, "R");
699 }
700 if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
701 cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
702 strcat(message, "H");
703 }
704 if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
705 cinode->oplock |= CIFS_CACHE_WRITE_FLG;
706 strcat(message, "W");
707 }
708 if (!cinode->oplock)
709 strcat(message, "None");
710 cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
711 &cinode->vfs_inode);
712 }
713
714 static void
715 smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
716 unsigned int epoch, bool *purge_cache)
717 {
718 unsigned int old_oplock = cinode->oplock;
719
720 smb21_set_oplock_level(cinode, oplock, epoch, purge_cache);
721
722 if (purge_cache) {
723 *purge_cache = false;
724 if (old_oplock == CIFS_CACHE_READ_FLG) {
725 if (cinode->oplock == CIFS_CACHE_READ_FLG &&
726 (epoch - cinode->epoch > 0))
727 *purge_cache = true;
728 else if (cinode->oplock == CIFS_CACHE_RH_FLG &&
729 (epoch - cinode->epoch > 1))
730 *purge_cache = true;
731 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
732 (epoch - cinode->epoch > 1))
733 *purge_cache = true;
734 else if (cinode->oplock == 0 &&
735 (epoch - cinode->epoch > 0))
736 *purge_cache = true;
737 } else if (old_oplock == CIFS_CACHE_RH_FLG) {
738 if (cinode->oplock == CIFS_CACHE_RH_FLG &&
739 (epoch - cinode->epoch > 0))
740 *purge_cache = true;
741 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
742 (epoch - cinode->epoch > 1))
743 *purge_cache = true;
744 }
745 cinode->epoch = epoch;
746 }
747 }
748
749 static bool
750 smb2_is_read_op(__u32 oplock)
751 {
752 return oplock == SMB2_OPLOCK_LEVEL_II;
753 }
754
755 static bool
756 smb21_is_read_op(__u32 oplock)
757 {
758 return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
759 !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
760 }
761
762 static __le32
763 map_oplock_to_lease(u8 oplock)
764 {
765 if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
766 return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING;
767 else if (oplock == SMB2_OPLOCK_LEVEL_II)
768 return SMB2_LEASE_READ_CACHING;
769 else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
770 return SMB2_LEASE_HANDLE_CACHING | SMB2_LEASE_READ_CACHING |
771 SMB2_LEASE_WRITE_CACHING;
772 return 0;
773 }
774
775 static char *
776 smb2_create_lease_buf(u8 *lease_key, u8 oplock)
777 {
778 struct create_lease *buf;
779
780 buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
781 if (!buf)
782 return NULL;
783
784 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
785 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
786 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
787
788 buf->ccontext.DataOffset = cpu_to_le16(offsetof
789 (struct create_lease, lcontext));
790 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
791 buf->ccontext.NameOffset = cpu_to_le16(offsetof
792 (struct create_lease, Name));
793 buf->ccontext.NameLength = cpu_to_le16(4);
794 buf->Name[0] = 'R';
795 buf->Name[1] = 'q';
796 buf->Name[2] = 'L';
797 buf->Name[3] = 's';
798 return (char *)buf;
799 }
800
801 static char *
802 smb3_create_lease_buf(u8 *lease_key, u8 oplock)
803 {
804 struct create_lease_v2 *buf;
805
806 buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
807 if (!buf)
808 return NULL;
809
810 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
811 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
812 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
813
814 buf->ccontext.DataOffset = cpu_to_le16(offsetof
815 (struct create_lease_v2, lcontext));
816 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
817 buf->ccontext.NameOffset = cpu_to_le16(offsetof
818 (struct create_lease_v2, Name));
819 buf->ccontext.NameLength = cpu_to_le16(4);
820 buf->Name[0] = 'R';
821 buf->Name[1] = 'q';
822 buf->Name[2] = 'L';
823 buf->Name[3] = 's';
824 return (char *)buf;
825 }
826
827 static __u8
828 smb2_parse_lease_buf(void *buf, unsigned int *epoch)
829 {
830 struct create_lease *lc = (struct create_lease *)buf;
831
832 *epoch = 0; /* not used */
833 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
834 return SMB2_OPLOCK_LEVEL_NOCHANGE;
835 return le32_to_cpu(lc->lcontext.LeaseState);
836 }
837
838 static __u8
839 smb3_parse_lease_buf(void *buf, unsigned int *epoch)
840 {
841 struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
842
843 *epoch = le16_to_cpu(lc->lcontext.Epoch);
844 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
845 return SMB2_OPLOCK_LEVEL_NOCHANGE;
846 return le32_to_cpu(lc->lcontext.LeaseState);
847 }
848
849 struct smb_version_operations smb20_operations = {
850 .compare_fids = smb2_compare_fids,
851 .setup_request = smb2_setup_request,
852 .setup_async_request = smb2_setup_async_request,
853 .check_receive = smb2_check_receive,
854 .add_credits = smb2_add_credits,
855 .set_credits = smb2_set_credits,
856 .get_credits_field = smb2_get_credits_field,
857 .get_credits = smb2_get_credits,
858 .get_next_mid = smb2_get_next_mid,
859 .read_data_offset = smb2_read_data_offset,
860 .read_data_length = smb2_read_data_length,
861 .map_error = map_smb2_to_linux_error,
862 .find_mid = smb2_find_mid,
863 .check_message = smb2_check_message,
864 .dump_detail = smb2_dump_detail,
865 .clear_stats = smb2_clear_stats,
866 .print_stats = smb2_print_stats,
867 .is_oplock_break = smb2_is_valid_oplock_break,
868 .need_neg = smb2_need_neg,
869 .negotiate = smb2_negotiate,
870 .negotiate_wsize = smb2_negotiate_wsize,
871 .negotiate_rsize = smb2_negotiate_rsize,
872 .sess_setup = SMB2_sess_setup,
873 .logoff = SMB2_logoff,
874 .tree_connect = SMB2_tcon,
875 .tree_disconnect = SMB2_tdis,
876 .is_path_accessible = smb2_is_path_accessible,
877 .can_echo = smb2_can_echo,
878 .echo = SMB2_echo,
879 .query_path_info = smb2_query_path_info,
880 .get_srv_inum = smb2_get_srv_inum,
881 .query_file_info = smb2_query_file_info,
882 .set_path_size = smb2_set_path_size,
883 .set_file_size = smb2_set_file_size,
884 .set_file_info = smb2_set_file_info,
885 .set_compression = smb2_set_compression,
886 .mkdir = smb2_mkdir,
887 .mkdir_setinfo = smb2_mkdir_setinfo,
888 .rmdir = smb2_rmdir,
889 .unlink = smb2_unlink,
890 .rename = smb2_rename_path,
891 .create_hardlink = smb2_create_hardlink,
892 .query_symlink = smb2_query_symlink,
893 .open = smb2_open_file,
894 .set_fid = smb2_set_fid,
895 .close = smb2_close_file,
896 .flush = smb2_flush_file,
897 .async_readv = smb2_async_readv,
898 .async_writev = smb2_async_writev,
899 .sync_read = smb2_sync_read,
900 .sync_write = smb2_sync_write,
901 .query_dir_first = smb2_query_dir_first,
902 .query_dir_next = smb2_query_dir_next,
903 .close_dir = smb2_close_dir,
904 .calc_smb_size = smb2_calc_size,
905 .is_status_pending = smb2_is_status_pending,
906 .oplock_response = smb2_oplock_response,
907 .queryfs = smb2_queryfs,
908 .mand_lock = smb2_mand_lock,
909 .mand_unlock_range = smb2_unlock_range,
910 .push_mand_locks = smb2_push_mandatory_locks,
911 .get_lease_key = smb2_get_lease_key,
912 .set_lease_key = smb2_set_lease_key,
913 .new_lease_key = smb2_new_lease_key,
914 .calc_signature = smb2_calc_signature,
915 .is_read_op = smb2_is_read_op,
916 .set_oplock_level = smb2_set_oplock_level,
917 .create_lease_buf = smb2_create_lease_buf,
918 .parse_lease_buf = smb2_parse_lease_buf,
919 };
920
921 struct smb_version_operations smb21_operations = {
922 .compare_fids = smb2_compare_fids,
923 .setup_request = smb2_setup_request,
924 .setup_async_request = smb2_setup_async_request,
925 .check_receive = smb2_check_receive,
926 .add_credits = smb2_add_credits,
927 .set_credits = smb2_set_credits,
928 .get_credits_field = smb2_get_credits_field,
929 .get_credits = smb2_get_credits,
930 .get_next_mid = smb2_get_next_mid,
931 .read_data_offset = smb2_read_data_offset,
932 .read_data_length = smb2_read_data_length,
933 .map_error = map_smb2_to_linux_error,
934 .find_mid = smb2_find_mid,
935 .check_message = smb2_check_message,
936 .dump_detail = smb2_dump_detail,
937 .clear_stats = smb2_clear_stats,
938 .print_stats = smb2_print_stats,
939 .is_oplock_break = smb2_is_valid_oplock_break,
940 .need_neg = smb2_need_neg,
941 .negotiate = smb2_negotiate,
942 .negotiate_wsize = smb2_negotiate_wsize,
943 .negotiate_rsize = smb2_negotiate_rsize,
944 .sess_setup = SMB2_sess_setup,
945 .logoff = SMB2_logoff,
946 .tree_connect = SMB2_tcon,
947 .tree_disconnect = SMB2_tdis,
948 .is_path_accessible = smb2_is_path_accessible,
949 .can_echo = smb2_can_echo,
950 .echo = SMB2_echo,
951 .query_path_info = smb2_query_path_info,
952 .get_srv_inum = smb2_get_srv_inum,
953 .query_file_info = smb2_query_file_info,
954 .set_path_size = smb2_set_path_size,
955 .set_file_size = smb2_set_file_size,
956 .set_file_info = smb2_set_file_info,
957 .set_compression = smb2_set_compression,
958 .mkdir = smb2_mkdir,
959 .mkdir_setinfo = smb2_mkdir_setinfo,
960 .rmdir = smb2_rmdir,
961 .unlink = smb2_unlink,
962 .rename = smb2_rename_path,
963 .create_hardlink = smb2_create_hardlink,
964 .query_symlink = smb2_query_symlink,
965 .open = smb2_open_file,
966 .set_fid = smb2_set_fid,
967 .close = smb2_close_file,
968 .flush = smb2_flush_file,
969 .async_readv = smb2_async_readv,
970 .async_writev = smb2_async_writev,
971 .sync_read = smb2_sync_read,
972 .sync_write = smb2_sync_write,
973 .query_dir_first = smb2_query_dir_first,
974 .query_dir_next = smb2_query_dir_next,
975 .close_dir = smb2_close_dir,
976 .calc_smb_size = smb2_calc_size,
977 .is_status_pending = smb2_is_status_pending,
978 .oplock_response = smb2_oplock_response,
979 .queryfs = smb2_queryfs,
980 .mand_lock = smb2_mand_lock,
981 .mand_unlock_range = smb2_unlock_range,
982 .push_mand_locks = smb2_push_mandatory_locks,
983 .get_lease_key = smb2_get_lease_key,
984 .set_lease_key = smb2_set_lease_key,
985 .new_lease_key = smb2_new_lease_key,
986 .calc_signature = smb2_calc_signature,
987 .is_read_op = smb21_is_read_op,
988 .set_oplock_level = smb21_set_oplock_level,
989 .create_lease_buf = smb2_create_lease_buf,
990 .parse_lease_buf = smb2_parse_lease_buf,
991 };
992
993 struct smb_version_operations smb30_operations = {
994 .compare_fids = smb2_compare_fids,
995 .setup_request = smb2_setup_request,
996 .setup_async_request = smb2_setup_async_request,
997 .check_receive = smb2_check_receive,
998 .add_credits = smb2_add_credits,
999 .set_credits = smb2_set_credits,
1000 .get_credits_field = smb2_get_credits_field,
1001 .get_credits = smb2_get_credits,
1002 .get_next_mid = smb2_get_next_mid,
1003 .read_data_offset = smb2_read_data_offset,
1004 .read_data_length = smb2_read_data_length,
1005 .map_error = map_smb2_to_linux_error,
1006 .find_mid = smb2_find_mid,
1007 .check_message = smb2_check_message,
1008 .dump_detail = smb2_dump_detail,
1009 .clear_stats = smb2_clear_stats,
1010 .print_stats = smb2_print_stats,
1011 .dump_share_caps = smb2_dump_share_caps,
1012 .is_oplock_break = smb2_is_valid_oplock_break,
1013 .need_neg = smb2_need_neg,
1014 .negotiate = smb2_negotiate,
1015 .negotiate_wsize = smb2_negotiate_wsize,
1016 .negotiate_rsize = smb2_negotiate_rsize,
1017 .sess_setup = SMB2_sess_setup,
1018 .logoff = SMB2_logoff,
1019 .tree_connect = SMB2_tcon,
1020 .tree_disconnect = SMB2_tdis,
1021 .is_path_accessible = smb2_is_path_accessible,
1022 .can_echo = smb2_can_echo,
1023 .echo = SMB2_echo,
1024 .query_path_info = smb2_query_path_info,
1025 .get_srv_inum = smb2_get_srv_inum,
1026 .query_file_info = smb2_query_file_info,
1027 .set_path_size = smb2_set_path_size,
1028 .set_file_size = smb2_set_file_size,
1029 .set_file_info = smb2_set_file_info,
1030 .set_compression = smb2_set_compression,
1031 .mkdir = smb2_mkdir,
1032 .mkdir_setinfo = smb2_mkdir_setinfo,
1033 .rmdir = smb2_rmdir,
1034 .unlink = smb2_unlink,
1035 .rename = smb2_rename_path,
1036 .create_hardlink = smb2_create_hardlink,
1037 .query_symlink = smb2_query_symlink,
1038 .open = smb2_open_file,
1039 .set_fid = smb2_set_fid,
1040 .close = smb2_close_file,
1041 .flush = smb2_flush_file,
1042 .async_readv = smb2_async_readv,
1043 .async_writev = smb2_async_writev,
1044 .sync_read = smb2_sync_read,
1045 .sync_write = smb2_sync_write,
1046 .query_dir_first = smb2_query_dir_first,
1047 .query_dir_next = smb2_query_dir_next,
1048 .close_dir = smb2_close_dir,
1049 .calc_smb_size = smb2_calc_size,
1050 .is_status_pending = smb2_is_status_pending,
1051 .oplock_response = smb2_oplock_response,
1052 .queryfs = smb2_queryfs,
1053 .mand_lock = smb2_mand_lock,
1054 .mand_unlock_range = smb2_unlock_range,
1055 .push_mand_locks = smb2_push_mandatory_locks,
1056 .get_lease_key = smb2_get_lease_key,
1057 .set_lease_key = smb2_set_lease_key,
1058 .new_lease_key = smb2_new_lease_key,
1059 .generate_signingkey = generate_smb3signingkey,
1060 .calc_signature = smb3_calc_signature,
1061 .is_read_op = smb21_is_read_op,
1062 .set_oplock_level = smb3_set_oplock_level,
1063 .create_lease_buf = smb3_create_lease_buf,
1064 .parse_lease_buf = smb3_parse_lease_buf,
1065 };
1066
1067 struct smb_version_values smb20_values = {
1068 .version_string = SMB20_VERSION_STRING,
1069 .protocol_id = SMB20_PROT_ID,
1070 .req_capabilities = 0, /* MBZ */
1071 .large_lock_type = 0,
1072 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1073 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1074 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1075 .header_size = sizeof(struct smb2_hdr),
1076 .max_header_size = MAX_SMB2_HDR_SIZE,
1077 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1078 .lock_cmd = SMB2_LOCK,
1079 .cap_unix = 0,
1080 .cap_nt_find = SMB2_NT_FIND,
1081 .cap_large_files = SMB2_LARGE_FILES,
1082 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1083 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1084 .create_lease_size = sizeof(struct create_lease),
1085 };
1086
1087 struct smb_version_values smb21_values = {
1088 .version_string = SMB21_VERSION_STRING,
1089 .protocol_id = SMB21_PROT_ID,
1090 .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
1091 .large_lock_type = 0,
1092 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1093 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1094 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1095 .header_size = sizeof(struct smb2_hdr),
1096 .max_header_size = MAX_SMB2_HDR_SIZE,
1097 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1098 .lock_cmd = SMB2_LOCK,
1099 .cap_unix = 0,
1100 .cap_nt_find = SMB2_NT_FIND,
1101 .cap_large_files = SMB2_LARGE_FILES,
1102 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1103 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1104 .create_lease_size = sizeof(struct create_lease),
1105 };
1106
1107 struct smb_version_values smb30_values = {
1108 .version_string = SMB30_VERSION_STRING,
1109 .protocol_id = SMB30_PROT_ID,
1110 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
1111 .large_lock_type = 0,
1112 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1113 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1114 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1115 .header_size = sizeof(struct smb2_hdr),
1116 .max_header_size = MAX_SMB2_HDR_SIZE,
1117 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1118 .lock_cmd = SMB2_LOCK,
1119 .cap_unix = 0,
1120 .cap_nt_find = SMB2_NT_FIND,
1121 .cap_large_files = SMB2_LARGE_FILES,
1122 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1123 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1124 .create_lease_size = sizeof(struct create_lease_v2),
1125 };
1126
1127 struct smb_version_values smb302_values = {
1128 .version_string = SMB302_VERSION_STRING,
1129 .protocol_id = SMB302_PROT_ID,
1130 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
1131 .large_lock_type = 0,
1132 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1133 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1134 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1135 .header_size = sizeof(struct smb2_hdr),
1136 .max_header_size = MAX_SMB2_HDR_SIZE,
1137 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1138 .lock_cmd = SMB2_LOCK,
1139 .cap_unix = 0,
1140 .cap_nt_find = SMB2_NT_FIND,
1141 .cap_large_files = SMB2_LARGE_FILES,
1142 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1143 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1144 .create_lease_size = sizeof(struct create_lease_v2),
1145 };