]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: move smb_version_values to common/smbglob.h
authorZhangGuoDong <zhangguodong@kylinos.cn>
Mon, 27 Oct 2025 07:12:54 +0000 (15:12 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Dec 2025 03:11:44 +0000 (21:11 -0600)
Merge the struct members of the server and the client:

  - req_capabilities: from client
  - header_preamble_size: from client
  - cap_unicode: from client
  - capabilities: from server, rename to req_capabilities
  - max_read_size: from server
  - max_write_size: from server
  - max_trans_size: from server
  - max_credits: from server
  - create_durable_size: from server
  - create_durable_v2_size: from server
  - create_mxac_size: from server
  - create_disk_id_size: from server
  - create_posix_size: from server

Then move duplicate definitions to common header file.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsglob.h
fs/smb/common/smbglob.h
fs/smb/server/smb2misc.c
fs/smb/server/smb2ops.c
fs/smb/server/smb2pdu.c
fs/smb/server/smb_common.h

index 8fd9aa7e2009ec2ef851c0946a79a28150437a10..accca43f7af54138d06339886063d923dd7f9626 100644 (file)
@@ -633,28 +633,6 @@ struct smb_version_operations {
                                               struct kvec *xattr_iov);
 };
 
-struct smb_version_values {
-       char            *version_string;
-       __u16           protocol_id;
-       __u32           req_capabilities;
-       __u32           large_lock_type;
-       __u32           exclusive_lock_type;
-       __u32           shared_lock_type;
-       __u32           unlock_lock_type;
-       size_t          header_preamble_size;
-       size_t          header_size;
-       size_t          max_header_size;
-       size_t          read_rsp_size;
-       __le16          lock_cmd;
-       unsigned int    cap_unix;
-       unsigned int    cap_nt_find;
-       unsigned int    cap_large_files;
-       unsigned int    cap_unicode;
-       __u16           signing_enabled;
-       __u16           signing_required;
-       size_t          create_lease_size;
-};
-
 #define HEADER_SIZE(server) (server->vals->header_size)
 #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
 #define HEADER_PREAMBLE_SIZE(server) (server->vals->header_preamble_size)
index c51d227977c45d352b1bfe7006ecd18281e6b834..84aa6826c3eae530e992351047988f761b4b41f9 100644 (file)
@@ -9,6 +9,37 @@
 #ifndef _COMMON_SMB_GLOB_H
 #define _COMMON_SMB_GLOB_H
 
+struct smb_version_values {
+       char            *version_string;
+       __u16           protocol_id;
+       __le16          lock_cmd;
+       __u32           req_capabilities;
+       __u32           max_read_size;
+       __u32           max_write_size;
+       __u32           max_trans_size;
+       __u32           max_credits;
+       __u32           large_lock_type;
+       __u32           exclusive_lock_type;
+       __u32           shared_lock_type;
+       __u32           unlock_lock_type;
+       size_t          header_preamble_size;
+       size_t          header_size;
+       size_t          max_header_size;
+       size_t          read_rsp_size;
+       unsigned int    cap_unix;
+       unsigned int    cap_nt_find;
+       unsigned int    cap_large_files;
+       unsigned int    cap_unicode;
+       __u16           signing_enabled;
+       __u16           signing_required;
+       size_t          create_lease_size;
+       size_t          create_durable_size;
+       size_t          create_durable_v2_size;
+       size_t          create_mxac_size;
+       size_t          create_disk_id_size;
+       size_t          create_posix_size;
+};
+
 static inline void inc_rfc1001_len(void *buf, int count)
 {
        be32_add_cpu((__be32 *)buf, count);
index ae501024665e1f6731dc4ffaa1f9e630a6eb01ad..67a2d7a793f6ed525f9e58d40ffd2e803c0ed98d 100644 (file)
@@ -460,7 +460,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
        }
 
 validate_credit:
-       if ((work->conn->vals->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) &&
+       if ((work->conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) &&
            smb2_validate_credit_charge(work->conn, hdr))
                return 1;
 
index 606aa3c5189a28de2e49e602e2c08362c91f46b7..bcf05caa2304d9e71670e514397d45e217e7bbb0 100644 (file)
@@ -15,7 +15,7 @@
 static struct smb_version_values smb21_server_values = {
        .version_string = SMB21_VERSION_STRING,
        .protocol_id = SMB21_PROT_ID,
-       .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+       .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
        .max_read_size = SMB21_DEFAULT_IOSIZE,
        .max_write_size = SMB21_DEFAULT_IOSIZE,
        .max_trans_size = SMB21_DEFAULT_IOSIZE,
@@ -41,7 +41,7 @@ static struct smb_version_values smb21_server_values = {
 static struct smb_version_values smb30_server_values = {
        .version_string = SMB30_VERSION_STRING,
        .protocol_id = SMB30_PROT_ID,
-       .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+       .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
        .max_read_size = SMB3_DEFAULT_IOSIZE,
        .max_write_size = SMB3_DEFAULT_IOSIZE,
        .max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -68,7 +68,7 @@ static struct smb_version_values smb30_server_values = {
 static struct smb_version_values smb302_server_values = {
        .version_string = SMB302_VERSION_STRING,
        .protocol_id = SMB302_PROT_ID,
-       .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+       .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
        .max_read_size = SMB3_DEFAULT_IOSIZE,
        .max_write_size = SMB3_DEFAULT_IOSIZE,
        .max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -95,7 +95,7 @@ static struct smb_version_values smb302_server_values = {
 static struct smb_version_values smb311_server_values = {
        .version_string = SMB311_VERSION_STRING,
        .protocol_id = SMB311_PROT_ID,
-       .capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
+       .req_capabilities = SMB2_GLOBAL_CAP_LARGE_MTU,
        .max_read_size = SMB3_DEFAULT_IOSIZE,
        .max_write_size = SMB3_DEFAULT_IOSIZE,
        .max_trans_size = SMB3_DEFAULT_TRANS_SIZE,
@@ -204,7 +204,7 @@ void init_smb2_1_server(struct ksmbd_conn *conn)
        conn->signing_algorithm = SIGNING_ALG_HMAC_SHA256_LE;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING;
 }
 
 /**
@@ -221,20 +221,20 @@ void init_smb3_0_server(struct ksmbd_conn *conn)
        conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
                        SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION &&
            conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION ||
            (!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) &&
             conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION))
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
 }
 
 /**
@@ -251,19 +251,19 @@ void init_smb3_02_server(struct ksmbd_conn *conn)
        conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
                        SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION ||
            (!(server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_ENCRYPTION_OFF) &&
             conn->cli_cap & SMB2_GLOBAL_CAP_ENCRYPTION))
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
 }
 
 /**
@@ -280,14 +280,14 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
        conn->signing_algorithm = SIGNING_ALG_AES_CMAC_LE;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING |
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_LEASING |
                        SMB2_GLOBAL_CAP_DIRECTORY_LEASING;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
 
        if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE)
-               conn->vals->capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
+               conn->vals->req_capabilities |= SMB2_GLOBAL_CAP_PERSISTENT_HANDLES;
 
        INIT_LIST_HEAD(&conn->preauth_sess_table);
        return 0;
index 09ac08c818df0f5a3e448ca1078201b990d9a54a..d52528792e46486ff80a92518bd5acffbe4478dd 100644 (file)
@@ -282,7 +282,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
        /* Not setting conn guid rsp->ServerGUID, as it
         * not used by client for identifying connection
         */
-       rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+       rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
        /* Default Max Message Size till SMB2.0, 64K*/
        rsp->MaxTransactSize = cpu_to_le32(conn->vals->max_trans_size);
        rsp->MaxReadSize = cpu_to_le32(conn->vals->max_read_size);
@@ -956,7 +956,7 @@ bool smb3_encryption_negotiated(struct ksmbd_conn *conn)
         * SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag.
         * SMB 3.1.1 uses the cipher_type field.
         */
-       return (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
+       return (conn->vals->req_capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
            conn->cipher_type;
 }
 
@@ -1210,7 +1210,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
                rc = -EINVAL;
                goto err_out;
        }
-       rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+       rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
 
        /* For stats */
        conn->connection_type = conn->dialect;
@@ -3464,7 +3464,7 @@ int smb2_open(struct ksmbd_work *work)
        share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp);
        if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) ||
            (req_op_level == SMB2_OPLOCK_LEVEL_LEASE &&
-            !(conn->vals->capabilities & SMB2_GLOBAL_CAP_LEASING))) {
+            !(conn->vals->req_capabilities & SMB2_GLOBAL_CAP_LEASING))) {
                if (share_ret < 0 && !S_ISDIR(file_inode(fp->filp)->i_mode)) {
                        rc = share_ret;
                        goto err_out1;
@@ -7974,7 +7974,7 @@ static int fsctl_validate_negotiate_info(struct ksmbd_conn *conn,
                goto err_out;
        }
 
-       neg_rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
+       neg_rsp->Capabilities = cpu_to_le32(conn->vals->req_capabilities);
        memset(neg_rsp->Guid, 0, SMB2_CLIENT_GUID_SIZE);
        neg_rsp->SecurityMode = cpu_to_le16(conn->srv_sec_mode);
        neg_rsp->Dialect = cpu_to_le16(conn->dialect);
index 560308e0d042ff5b71d92a3b74a3e7058cea19e4..93f28defef3e216d8401e29ae1684d602a17e943 100644 (file)
@@ -338,35 +338,6 @@ struct file_id_full_dir_info {
        char FileName[];
 } __packed; /* level 0x105 FF rsp data */
 
-struct smb_version_values {
-       char            *version_string;
-       __u16           protocol_id;
-       __le16          lock_cmd;
-       __u32           capabilities;
-       __u32           max_read_size;
-       __u32           max_write_size;
-       __u32           max_trans_size;
-       __u32           max_credits;
-       __u32           large_lock_type;
-       __u32           exclusive_lock_type;
-       __u32           shared_lock_type;
-       __u32           unlock_lock_type;
-       size_t          header_size;
-       size_t          max_header_size;
-       size_t          read_rsp_size;
-       unsigned int    cap_unix;
-       unsigned int    cap_nt_find;
-       unsigned int    cap_large_files;
-       __u16           signing_enabled;
-       __u16           signing_required;
-       size_t          create_lease_size;
-       size_t          create_durable_size;
-       size_t          create_durable_v2_size;
-       size_t          create_mxac_size;
-       size_t          create_disk_id_size;
-       size_t          create_posix_size;
-};
-
 struct filesystem_posix_info {
        /* For undefined recommended transfer size return -1 in that field */
        __le32 OptimalTransferSize;  /* bsize on some os, iosize on other os */