aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb2pdu.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r--fs/cifs/smb2pdu.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5ad88b4b9990..cf33622cdac8 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/smb2pdu.c 2 * fs/cifs/smb2pdu.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2009, 2011 4 * Copyright (C) International Business Machines Corp., 2009, 2012
5 * Etersoft, 2012 5 * Etersoft, 2012
6 * Author(s): Steve French (sfrench@us.ibm.com) 6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012 7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
@@ -304,24 +304,6 @@ free_rsp_buf(int resp_buftype, void *rsp)
304 cifs_buf_release(rsp); 304 cifs_buf_release(rsp);
305} 305}
306 306
307#define SMB2_NUM_PROT 2
308
309#define SMB2_PROT 0
310#define SMB21_PROT 1
311#define BAD_PROT 0xFFFF
312
313#define SMB2_PROT_ID 0x0202
314#define SMB21_PROT_ID 0x0210
315#define BAD_PROT_ID 0xFFFF
316
317static struct {
318 int index;
319 __le16 name;
320} smb2protocols[] = {
321 {SMB2_PROT, cpu_to_le16(SMB2_PROT_ID)},
322 {SMB21_PROT, cpu_to_le16(SMB21_PROT_ID)},
323 {BAD_PROT, cpu_to_le16(BAD_PROT_ID)}
324};
325 307
326/* 308/*
327 * 309 *
@@ -348,7 +330,6 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
348 int resp_buftype; 330 int resp_buftype;
349 struct TCP_Server_Info *server; 331 struct TCP_Server_Info *server;
350 unsigned int sec_flags; 332 unsigned int sec_flags;
351 u16 i;
352 u16 temp = 0; 333 u16 temp = 0;
353 int blob_offset, blob_length; 334 int blob_offset, blob_length;
354 char *security_blob; 335 char *security_blob;
@@ -377,11 +358,10 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
377 358
378 req->hdr.SessionId = 0; 359 req->hdr.SessionId = 0;
379 360
380 for (i = 0; i < SMB2_NUM_PROT; i++) 361 req->Dialects[0] = cpu_to_le16(ses->server->vals->protocol_id);
381 req->Dialects[i] = smb2protocols[i].name;
382 362
383 req->DialectCount = cpu_to_le16(i); 363 req->DialectCount = cpu_to_le16(1); /* One vers= at a time for now */
384 inc_rfc1001_len(req, i * 2); 364 inc_rfc1001_len(req, 2);
385 365
386 /* only one of SMB2 signing flags may be set in SMB2 request */ 366 /* only one of SMB2 signing flags may be set in SMB2 request */
387 if ((sec_flags & CIFSSEC_MUST_SIGN) == CIFSSEC_MUST_SIGN) 367 if ((sec_flags & CIFSSEC_MUST_SIGN) == CIFSSEC_MUST_SIGN)
@@ -391,7 +371,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
391 371
392 req->SecurityMode = cpu_to_le16(temp); 372 req->SecurityMode = cpu_to_le16(temp);
393 373
394 req->Capabilities = cpu_to_le32(SMB2_GLOBAL_CAP_DFS); 374 req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
395 375
396 memcpy(req->ClientGUID, cifs_client_guid, SMB2_CLIENT_GUID_SIZE); 376 memcpy(req->ClientGUID, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
397 377
@@ -411,10 +391,14 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
411 391
412 cFYI(1, "mode 0x%x", rsp->SecurityMode); 392 cFYI(1, "mode 0x%x", rsp->SecurityMode);
413 393
414 if (rsp->DialectRevision == smb2protocols[SMB21_PROT].name) 394 /* BB we may eventually want to match the negotiated vs. requested
395 dialect, even though we are only requesting one at a time */
396 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID))
397 cFYI(1, "negotiated smb2.0 dialect");
398 else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID))
415 cFYI(1, "negotiated smb2.1 dialect"); 399 cFYI(1, "negotiated smb2.1 dialect");
416 else if (rsp->DialectRevision == smb2protocols[SMB2_PROT].name) 400 else if (rsp->DialectRevision == cpu_to_le16(SMB30_PROT_ID))
417 cFYI(1, "negotiated smb2 dialect"); 401 cFYI(1, "negotiated smb3.0 dialect");
418 else { 402 else {
419 cERROR(1, "Illegal dialect returned by server %d", 403 cERROR(1, "Illegal dialect returned by server %d",
420 le16_to_cpu(rsp->DialectRevision)); 404 le16_to_cpu(rsp->DialectRevision));