]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Fix match_server check to allow for auto dialect negotiate
authorSteve French <stfrench@microsoft.com>
Thu, 13 Jun 2019 19:26:49 +0000 (14:26 -0500)
committerSteve French <stfrench@microsoft.com>
Mon, 8 Jul 2019 03:37:42 +0000 (22:37 -0500)
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>
fs/cifs/connect.c
fs/cifs/smb1ops.c
fs/cifs/smb2pdu.h

index 8dd6637a3cbb7887e582652c47cc0735916e0cd4..51f272377ae14e68a9169e14f191c6c1dd9e4275 100644 (file)
@@ -2544,8 +2544,15 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol)
        if (vol->nosharesock)
                return 0;
 
-       /* BB update this for smb3any and default case */
-       if ((server->vals != vol->vals) || (server->ops != vol->ops))
+       /* If multidialect negotiation see if existing sessions match one */
+       if (strcmp(vol->vals->version_string, SMB3ANY_VERSION_STRING) == 0) {
+               if (server->vals->protocol_id < SMB30_PROT_ID)
+                       return 0;
+       } else if (strcmp(vol->vals->version_string,
+                  SMBDEFAULT_VERSION_STRING) == 0) {
+               if (server->vals->protocol_id < SMB21_PROT_ID)
+                       return 0;
+       } else if ((server->vals != vol->vals) || (server->ops != vol->ops))
                return 0;
 
        if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns))
index 9e430ae9314fd7a8eae349632228d8bd4411a287..88ab87df8b3b987469d9b94613026f5edf5f8150 100644 (file)
@@ -1233,6 +1233,7 @@ struct smb_version_operations smb1_operations = {
 
 struct smb_version_values smb1_values = {
        .version_string = SMB1_VERSION_STRING,
+       .protocol_id = SMB10_PROT_ID,
        .large_lock_type = LOCKING_ANDX_LARGE_FILES,
        .exclusive_lock_type = 0,
        .shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
index c09d9244b7286ba240d27bef1e606f43d1ba3b0e..fa8c12a21f1b647d20cb1cf3e77e1256a5550ba1 100644 (file)
@@ -227,6 +227,7 @@ struct smb2_negotiate_req {
 } __packed;
 
 /* Dialects */
+#define SMB10_PROT_ID 0x0000 /* local only, not sent on wire w/CIFS negprot */
 #define SMB20_PROT_ID 0x0202
 #define SMB21_PROT_ID 0x0210
 #define SMB30_PROT_ID 0x0300