cifs: New optype for session operations.
authorShyam Prasad N <sprasad@microsoft.com>
Thu, 4 Feb 2021 06:49:52 +0000 (22:49 -0800)
committerSteve French <stfrench@microsoft.com>
Tue, 16 Feb 2021 21:35:57 +0000 (15:35 -0600)
We used to share the CIFS_NEG_OP flag between negotiate and
session authentication. There was an assumption in the code that
CIFS_NEG_OP is used by negotiate only. So introcuded CIFS_SESS_OP
and used it for session setup optypes.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsglob.h
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/transport.c

index 50fcb65..3152601 100644 (file)
@@ -1704,7 +1704,9 @@ static inline bool is_retryable_error(int error)
 #define   CIFS_ECHO_OP      0x080    /* echo request */
 #define   CIFS_OBREAK_OP   0x0100    /* oplock break request */
 #define   CIFS_NEG_OP      0x0200    /* negotiate request */
-#define   CIFS_OP_MASK     0x0380    /* mask request type */
+/* Lower bitmask values are reserved by others below. */
+#define   CIFS_SESS_OP     0x2000    /* session setup request */
+#define   CIFS_OP_MASK     0x2380    /* mask request type */
 
 #define   CIFS_HAS_CREDITS 0x0400    /* already has credits */
 #define   CIFS_TRANSFORM_REQ 0x0800    /* transform request before sending */
index f192748..84d1f26 100644 (file)
@@ -84,7 +84,9 @@ smb2_add_credits(struct TCP_Server_Info *server,
                pr_warn_once("server overflowed SMB3 credits\n");
        }
        server->in_flight--;
-       if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
+       if (server->in_flight == 0 &&
+          ((optype & CIFS_OP_MASK) != CIFS_NEG_OP) &&
+          ((optype & CIFS_OP_MASK) != CIFS_SESS_OP))
                rc = change_conf(server);
        /*
         * Sometimes server returns 0 credits on oplock break ack - we need to
index e1391bd..4bbb612 100644 (file)
@@ -1261,7 +1261,7 @@ SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data)
                            cifs_ses_server(sess_data->ses),
                            &rqst,
                            &sess_data->buf0_type,
-                           CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov);
+                           CIFS_LOG_ERROR | CIFS_SESS_OP, &rsp_iov);
        cifs_small_buf_release(sess_data->iov[0].iov_base);
        memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec));
 
index 4a2b836..41223a9 100644 (file)
@@ -1171,7 +1171,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
        /*
         * Compounding is never used during session establish.
         */
-       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP))
+       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP))
                smb311_update_preauth_hash(ses, rqst[0].rq_iov,
                                           rqst[0].rq_nvec);
 
@@ -1236,7 +1236,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
        /*
         * Compounding is never used during session establish.
         */
-       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) {
+       if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
                struct kvec iov = {
                        .iov_base = resp_iov[0].iov_base,
                        .iov_len = resp_iov[0].iov_len