]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb: move create_durable_req_v2 to common/smb2pdu.h
authorChenXiaoSong <chenxiaosong@kylinos.cn>
Sun, 2 Nov 2025 07:30:48 +0000 (15:30 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Dec 2025 03:11:44 +0000 (21:11 -0600)
Modify the following places:

  - some fields in "struct create_durable_req_v2" ->
                           struct durable_context_v2
  - durable_context_v2 -> durable_context_v2_req
  - create_durable_v2 -> create_durable_req_v2

Then move duplicate definitions to common header file.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb2pdu.c
fs/smb/client/smb2pdu.h
fs/smb/common/smb2pdu.h
fs/smb/server/smb2pdu.c
fs/smb/server/smb2pdu.h

index 8b4a4573e9c372478af9b2c10525e0656f53a1b9..fe2147c45839823e23b888236daed39b51abe548 100644 (file)
@@ -2424,21 +2424,21 @@ add_lease_context(struct TCP_Server_Info *server,
        return 0;
 }
 
-static struct create_durable_v2 *
+static struct create_durable_req_v2 *
 create_durable_v2_buf(struct cifs_open_parms *oparms)
 {
        struct cifs_fid *pfid = oparms->fid;
-       struct create_durable_v2 *buf;
+       struct create_durable_req_v2 *buf;
 
-       buf = kzalloc(sizeof(struct create_durable_v2), GFP_KERNEL);
+       buf = kzalloc(sizeof(struct create_durable_req_v2), GFP_KERNEL);
        if (!buf)
                return NULL;
 
        buf->ccontext.DataOffset = cpu_to_le16(offsetof
-                                       (struct create_durable_v2, dcontext));
-       buf->ccontext.DataLength = cpu_to_le32(sizeof(struct durable_context_v2));
+                                       (struct create_durable_req_v2, dcontext));
+       buf->ccontext.DataLength = cpu_to_le32(sizeof(struct durable_context_v2_req));
        buf->ccontext.NameOffset = cpu_to_le16(offsetof
-                               (struct create_durable_v2, Name));
+                               (struct create_durable_req_v2, Name));
        buf->ccontext.NameLength = cpu_to_le16(4);
 
        /*
@@ -2508,7 +2508,7 @@ add_durable_v2_context(struct kvec *iov, unsigned int *num_iovec,
        iov[num].iov_base = create_durable_v2_buf(oparms);
        if (iov[num].iov_base == NULL)
                return -ENOMEM;
-       iov[num].iov_len = sizeof(struct create_durable_v2);
+       iov[num].iov_len = sizeof(struct create_durable_req_v2);
        *num_iovec = num + 1;
        return 0;
 }
index 0ce9f93f108f1706e1e69ca5754f880923884e05..a700b404a57c6e354d3ff83be8e206404c3a2c21 100644 (file)
@@ -137,18 +137,6 @@ struct share_redirect_error_context_rsp {
 /* See MS-SMB2 2.2.13.2.11 */
 /* Flags */
 #define SMB2_DHANDLE_FLAG_PERSISTENT   0x00000002
-struct durable_context_v2 {
-       __le32 Timeout;
-       __le32 Flags;
-       __u64 Reserved;
-       __u8 CreateGuid[16];
-} __packed;
-
-struct create_durable_v2 {
-       struct create_context_hdr ccontext;
-       __u8   Name[8];
-       struct durable_context_v2 dcontext;
-} __packed;
 
 /* See MS-SMB2 2.2.13.2.12 */
 struct durable_reconnect_context_v2 {
index a7ea4214d06184ed80c18b7fa3ad8258cb4fee92..681855ebacc9d8df964a2af2b6dac5c614decba7 100644 (file)
@@ -1290,6 +1290,20 @@ struct create_mxac_req {
        __le64 Timestamp;
 } __packed;
 
+/* See MS-SMB2 2.2.13.2.11 */
+struct durable_context_v2_req {
+       __le32 Timeout;
+       __le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
+       __u64 Reserved;
+       __u8 CreateGuid[16];
+} __packed;
+
+struct create_durable_req_v2 {
+       struct create_context_hdr ccontext;
+       __u8   Name[8];
+       struct durable_context_v2_req dcontext;
+} __packed;
+
 /* See MS-SMB2 2.2.14.2.5 */
 struct create_mxac_rsp {
        struct create_context_hdr ccontext;
index 2cef4e192dbe841a33ddf08920f17debb7f8e616..07d21d2f882ff9a19cffd4cab7b463b5a3402464 100644 (file)
@@ -2806,7 +2806,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
                        durable_v2_blob =
                                (struct create_durable_req_v2 *)context;
                        ksmbd_debug(SMB, "Request for durable v2 open\n");
-                       dh_info->fp = ksmbd_lookup_fd_cguid(durable_v2_blob->CreateGuid);
+                       dh_info->fp = ksmbd_lookup_fd_cguid(durable_v2_blob->dcontext.CreateGuid);
                        if (dh_info->fp) {
                                if (!memcmp(conn->ClientGUID, dh_info->fp->client_guid,
                                            SMB2_CLIENT_GUID_SIZE)) {
@@ -2824,11 +2824,11 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
                        if ((lc && (lc->req_state & SMB2_LEASE_HANDLE_CACHING_LE)) ||
                            req_op_level == SMB2_OPLOCK_LEVEL_BATCH) {
                                dh_info->CreateGuid =
-                                       durable_v2_blob->CreateGuid;
+                                       durable_v2_blob->dcontext.CreateGuid;
                                dh_info->persistent =
-                                       le32_to_cpu(durable_v2_blob->Flags);
+                                       le32_to_cpu(durable_v2_blob->dcontext.Flags);
                                dh_info->timeout =
-                                       le32_to_cpu(durable_v2_blob->Timeout);
+                                       le32_to_cpu(durable_v2_blob->dcontext.Timeout);
                                dh_info->type = dh_idx;
                        }
                        break;
index 807079d19d1e11b233f216f9805f75ee159a79d7..93d43da626d4b609b92e90c1f794f13772b3ab36 100644 (file)
@@ -66,15 +66,6 @@ struct preauth_integrity_info {
 /* Apple Defined Contexts */
 #define SMB2_CREATE_AAPL               "AAPL"
 
-struct create_durable_req_v2 {
-       struct create_context_hdr ccontext;
-       __u8   Name[8];
-       __le32 Timeout;
-       __le32 Flags;
-       __u8 Reserved[8];
-       __u8 CreateGuid[16];
-} __packed;
-
 #define DURABLE_HANDLE_MAX_TIMEOUT     300000
 
 struct create_durable_reconn_req {