summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2019-06-13 15:26:49 -0400
committerSteve French <stfrench@microsoft.com>2019-07-07 23:37:42 -0400
commit43cdae88de2e8ec101961708ef7e51ba96776035 (patch)
tree87ff14ba952874406dc968e6fce70c1eb0ab4e62
parent5fc3681fa5ed5cbbe70592967dcfa8f0848f75c0 (diff)
Fix match_server check to allow for auto dialect negotiate
When using multidialect negotiate (default or specifying vers=3.0 which allows any smb3 dialect), fix how we check for an existing server session. Before this fix if you mounted a second time to the same server (e.g. a different share on the same server) we would only reuse the existing smb session if a single dialect were requested (e.g. specifying vers=2.1 or vers=3.0 or vers=3.1.1 on the mount command). If a default mount (e.g. not specifying vers=) is done then would always create a new socket connection and SMB3 (or SMB3.1.1) session each time we connect to a different share on the same server rather than reusing the existing one. Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/connect.c11
-rw-r--r--fs/cifs/smb1ops.c1
-rw-r--r--fs/cifs/smb2pdu.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8dd6637a3cbb..51f272377ae1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2544,8 +2544,15 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol)
2544 if (vol->nosharesock) 2544 if (vol->nosharesock)
2545 return 0; 2545 return 0;
2546 2546
2547 /* BB update this for smb3any and default case */ 2547 /* If multidialect negotiation see if existing sessions match one */
2548 if ((server->vals != vol->vals) || (server->ops != vol->ops)) 2548 if (strcmp(vol->vals->version_string, SMB3ANY_VERSION_STRING) == 0) {
2549 if (server->vals->protocol_id < SMB30_PROT_ID)
2550 return 0;
2551 } else if (strcmp(vol->vals->version_string,
2552 SMBDEFAULT_VERSION_STRING) == 0) {
2553 if (server->vals->protocol_id < SMB21_PROT_ID)
2554 return 0;
2555 } else if ((server->vals != vol->vals) || (server->ops != vol->ops))
2549 return 0; 2556 return 0;
2550 2557
2551 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) 2558 if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns))
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 9e430ae9314f..88ab87df8b3b 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -1233,6 +1233,7 @@ struct smb_version_operations smb1_operations = {
1233 1233
1234struct smb_version_values smb1_values = { 1234struct smb_version_values smb1_values = {
1235 .version_string = SMB1_VERSION_STRING, 1235 .version_string = SMB1_VERSION_STRING,
1236 .protocol_id = SMB10_PROT_ID,
1236 .large_lock_type = LOCKING_ANDX_LARGE_FILES, 1237 .large_lock_type = LOCKING_ANDX_LARGE_FILES,
1237 .exclusive_lock_type = 0, 1238 .exclusive_lock_type = 0,
1238 .shared_lock_type = LOCKING_ANDX_SHARED_LOCK, 1239 .shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index c09d9244b728..fa8c12a21f1b 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -227,6 +227,7 @@ struct smb2_negotiate_req {
227} __packed; 227} __packed;
228 228
229/* Dialects */ 229/* Dialects */
230#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
230#define SMB20_PROT_ID 0x0202 231#define SMB20_PROT_ID 0x0202
231#define SMB21_PROT_ID 0x0210 232#define SMB21_PROT_ID 0x0210
232#define SMB30_PROT_ID 0x0300 233#define SMB30_PROT_ID 0x0300