Skip to content

Commit 81a45de

Browse files
ChenXiaoSongsmfrench
authored andcommitted
smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h
Modify the following places: - some fields in "struct create_durable_reconn_v2_req" -> struct durable_reconnect_context_v2 - create_durable_reconn_v2_req -> create_durable_handle_reconnect_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>
1 parent 833a75f commit 81a45de

4 files changed

Lines changed: 21 additions & 33 deletions

File tree

fs/smb/client/smb2pdu.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,12 @@ struct share_redirect_error_context_rsp {
138138
/* Flags */
139139
#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
140140

141-
/* See MS-SMB2 2.2.13.2.12 */
142-
struct durable_reconnect_context_v2 {
143-
struct {
144-
__u64 PersistentFileId;
145-
__u64 VolatileFileId;
146-
} Fid;
147-
__u8 CreateGuid[16];
148-
__le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
149-
} __packed;
150-
151141
/* See MS-SMB2 2.2.14.2.12 */
152142
struct durable_reconnect_context_v2_rsp {
153143
__le32 Timeout;
154144
__le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
155145
} __packed;
156146

157-
struct create_durable_handle_reconnect_v2 {
158-
struct create_context_hdr ccontext;
159-
__u8 Name[8];
160-
struct durable_reconnect_context_v2 dcontext;
161-
__u8 Pad[4];
162-
} __packed;
163-
164147
/* See MS-SMB2 2.2.13.2.5 */
165148
struct crt_twarp_ctxt {
166149
struct create_context_hdr ccontext;

fs/smb/common/smb2pdu.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,22 @@ struct create_durable_req_v2 {
13041304
struct durable_context_v2_req dcontext;
13051305
} __packed;
13061306

1307+
/* See MS-SMB2 2.2.13.2.12 */
1308+
struct durable_reconnect_context_v2 {
1309+
struct {
1310+
__u64 PersistentFileId;
1311+
__u64 VolatileFileId;
1312+
} Fid;
1313+
__u8 CreateGuid[16];
1314+
__le32 Flags; /* see SMB2_DHANDLE_FLAG_PERSISTENT */
1315+
} __packed;
1316+
1317+
struct create_durable_handle_reconnect_v2 {
1318+
struct create_context_hdr ccontext;
1319+
__u8 Name[8];
1320+
struct durable_reconnect_context_v2 dcontext;
1321+
} __packed;
1322+
13071323
/* See MS-SMB2 2.2.14.2.5 */
13081324
struct create_mxac_rsp {
13091325
struct create_context_hdr ccontext;

fs/smb/server/smb2pdu.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27162716
switch (dh_idx) {
27172717
case DURABLE_RECONN_V2:
27182718
{
2719-
struct create_durable_reconn_v2_req *recon_v2;
2719+
struct create_durable_handle_reconnect_v2 *recon_v2;
27202720

27212721
if (dh_info->type == DURABLE_RECONN ||
27222722
dh_info->type == DURABLE_REQ_V2) {
@@ -2726,21 +2726,21 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
27262726

27272727
if (le16_to_cpu(context->DataOffset) +
27282728
le32_to_cpu(context->DataLength) <
2729-
sizeof(struct create_durable_reconn_v2_req)) {
2729+
sizeof(struct create_durable_handle_reconnect_v2)) {
27302730
err = -EINVAL;
27312731
goto out;
27322732
}
27332733

2734-
recon_v2 = (struct create_durable_reconn_v2_req *)context;
2735-
persistent_id = recon_v2->Fid.PersistentFileId;
2734+
recon_v2 = (struct create_durable_handle_reconnect_v2 *)context;
2735+
persistent_id = recon_v2->dcontext.Fid.PersistentFileId;
27362736
dh_info->fp = ksmbd_lookup_durable_fd(persistent_id);
27372737
if (!dh_info->fp) {
27382738
ksmbd_debug(SMB, "Failed to get durable handle state\n");
27392739
err = -EBADF;
27402740
goto out;
27412741
}
27422742

2743-
if (memcmp(dh_info->fp->create_guid, recon_v2->CreateGuid,
2743+
if (memcmp(dh_info->fp->create_guid, recon_v2->dcontext.CreateGuid,
27442744
SMB2_CREATE_GUID_SIZE)) {
27452745
err = -EBADF;
27462746
ksmbd_put_durable_fd(dh_info->fp);

fs/smb/server/smb2pdu.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ struct create_durable_reconn_req {
8080
} Data;
8181
} __packed;
8282

83-
struct create_durable_reconn_v2_req {
84-
struct create_context_hdr ccontext;
85-
__u8 Name[8];
86-
struct {
87-
__u64 PersistentFileId;
88-
__u64 VolatileFileId;
89-
} Fid;
90-
__u8 CreateGuid[16];
91-
__le32 Flags;
92-
} __packed;
93-
9483
struct create_alloc_size_req {
9584
struct create_context_hdr ccontext;
9685
__u8 Name[8];

0 commit comments

Comments
 (0)