Skip to content

Commit 36c3154

Browse files
ZhangGuoDongsmfrench
authored andcommitted
smb: move get_rfc1002_len() to common/smbglob.h
Rename get_rfc1002_length() to get_rfc1002_len(), 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>
1 parent 34cf191 commit 36c3154

6 files changed

Lines changed: 13 additions & 19 deletions

File tree

fs/smb/client/cifsglob.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,6 @@ struct cifs_mnt_data {
670670
int flags;
671671
};
672672

673-
static inline unsigned int
674-
get_rfc1002_length(void *buf)
675-
{
676-
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
677-
}
678-
679673
struct TCP_Server_Info {
680674
struct list_head tcp_ses_list;
681675
struct list_head smb_ses_list;

fs/smb/client/cifssmb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
614614

615615
iov[0].iov_len = 4;
616616
iov[0].iov_base = smb;
617-
iov[1].iov_len = get_rfc1002_length(smb);
617+
iov[1].iov_len = get_rfc1002_len(smb);
618618
iov[1].iov_base = (char *)smb + 4;
619619

620620
rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
@@ -1458,7 +1458,7 @@ cifs_async_readv(struct cifs_io_subrequest *rdata)
14581458
rdata->iov[0].iov_base = smb;
14591459
rdata->iov[0].iov_len = 4;
14601460
rdata->iov[1].iov_base = (char *)smb + 4;
1461-
rdata->iov[1].iov_len = get_rfc1002_length(smb);
1461+
rdata->iov[1].iov_len = get_rfc1002_len(smb);
14621462

14631463
trace_smb3_read_enter(rdata->rreq->debug_id,
14641464
rdata->subreq.debug_index,
@@ -1830,7 +1830,7 @@ cifs_async_writev(struct cifs_io_subrequest *wdata)
18301830
/* 4 for RFC1001 length + 1 for BCC */
18311831
iov[0].iov_len = 4;
18321832
iov[0].iov_base = smb;
1833-
iov[1].iov_len = get_rfc1002_length(smb) + 1;
1833+
iov[1].iov_len = get_rfc1002_len(smb) + 1;
18341834
iov[1].iov_base = (char *)smb + 4;
18351835

18361836
rqst.rq_iov = iov;

fs/smb/client/cifstransport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
165165
int resp_buf_type;
166166

167167
iov[0].iov_base = in_buf;
168-
iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
168+
iov[0].iov_len = get_rfc1002_len(in_buf) + 4;
169169
flags |= CIFS_NO_RSP_BUF;
170170
rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
171171
cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
@@ -177,7 +177,7 @@ int
177177
cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
178178
bool log_error)
179179
{
180-
unsigned int len = get_rfc1002_length(mid->resp_buf) + 4;
180+
unsigned int len = get_rfc1002_len(mid->resp_buf) + 4;
181181

182182
dump_smb(mid->resp_buf, min_t(u32, 92, len));
183183

@@ -370,7 +370,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
370370
goto out;
371371
}
372372

373-
*pbytes_returned = get_rfc1002_length(midQ->resp_buf);
373+
*pbytes_returned = get_rfc1002_len(midQ->resp_buf);
374374
memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
375375
rc = cifs_check_receive(midQ, server, 0);
376376
out:
@@ -554,7 +554,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
554554
goto out;
555555
}
556556

557-
*pbytes_returned = get_rfc1002_length(midQ->resp_buf);
557+
*pbytes_returned = get_rfc1002_len(midQ->resp_buf);
558558
memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
559559
rc = cifs_check_receive(midQ, server, 0);
560560
out:

fs/smb/client/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ cifs_demultiplex_thread(void *p)
12951295
* The right amount was read from socket - 4 bytes,
12961296
* so we can now interpret the length field.
12971297
*/
1298-
pdu_length = get_rfc1002_length(buf);
1298+
pdu_length = get_rfc1002_len(buf);
12991299

13001300
cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
13011301
if (!is_smb_response(server, buf[0]))

fs/smb/common/smbglob.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ struct smb_version_values {
4040
size_t create_posix_size;
4141
};
4242

43+
static inline unsigned int get_rfc1002_len(void *buf)
44+
{
45+
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
46+
}
47+
4348
static inline void inc_rfc1001_len(void *buf, int count)
4449
{
4550
be32_add_cpu((__be32 *)buf, count);

fs/smb/server/smb_common.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,4 @@ unsigned int ksmbd_server_side_copy_max_chunk_size(void);
423423
unsigned int ksmbd_server_side_copy_max_total_size(void);
424424
bool is_asterisk(char *p);
425425
__le32 smb_map_generic_desired_access(__le32 daccess);
426-
427-
static inline unsigned int get_rfc1002_len(void *buf)
428-
{
429-
return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
430-
}
431426
#endif /* __SMB_COMMON_H__ */

0 commit comments

Comments
 (0)