ksmbd: remove and replace macros with inline functions in smb_common.h

Remove and replace macros with inline functions
in smb_common.h

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Hyunchul Lee 2021-06-25 11:53:26 +09:00 committed by Namjae Jeon
parent d4075abbc6
commit d8fb29980c
4 changed files with 16 additions and 15 deletions

View File

@ -154,11 +154,9 @@ void ksmbd_session_destroy(struct ksmbd_session *sess)
list_del(&sess->sessions_entry); list_del(&sess->sessions_entry);
if (IS_SMB2(sess->conn)) {
down_write(&sessions_table_lock); down_write(&sessions_table_lock);
hash_del(&sess->hlist); hash_del(&sess->hlist);
up_write(&sessions_table_lock); up_write(&sessions_table_lock);
}
if (sess->user) if (sess->user)
ksmbd_free_user(sess->user); ksmbd_free_user(sess->user);

View File

@ -631,7 +631,8 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
rsp_hdr = work->response_buf; rsp_hdr = work->response_buf;
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2); memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
rsp_hdr->smb2_buf_length = cpu_to_be32(HEADER_SIZE_NO_BUF_LEN(conn)); rsp_hdr->smb2_buf_length =
cpu_to_be32(smb2_hdr_size_no_buflen(conn->vals));
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER; rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE; rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
rsp_hdr->CreditRequest = cpu_to_le16(0); rsp_hdr->CreditRequest = cpu_to_le16(0);
@ -737,7 +738,8 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
rsp_hdr = work->response_buf; rsp_hdr = work->response_buf;
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2); memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
rsp_hdr->smb2_buf_length = cpu_to_be32(HEADER_SIZE_NO_BUF_LEN(conn)); rsp_hdr->smb2_buf_length =
cpu_to_be32(smb2_hdr_size_no_buflen(conn->vals));
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER; rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE; rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
rsp_hdr->CreditRequest = cpu_to_le16(0); rsp_hdr->CreditRequest = cpu_to_le16(0);

View File

@ -243,7 +243,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2); memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
rsp_hdr->smb2_buf_length = rsp_hdr->smb2_buf_length =
cpu_to_be32(HEADER_SIZE_NO_BUF_LEN(conn)); cpu_to_be32(smb2_hdr_size_no_buflen(conn->vals));
rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER; rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE; rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
@ -497,7 +497,8 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work)
struct ksmbd_conn *conn = work->conn; struct ksmbd_conn *conn = work->conn;
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2); memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
rsp_hdr->smb2_buf_length = cpu_to_be32(HEADER_SIZE_NO_BUF_LEN(conn)); rsp_hdr->smb2_buf_length =
cpu_to_be32(smb2_hdr_size_no_buflen(conn->vals));
rsp_hdr->ProtocolId = rcv_hdr->ProtocolId; rsp_hdr->ProtocolId = rcv_hdr->ProtocolId;
rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE; rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
rsp_hdr->Command = rcv_hdr->Command; rsp_hdr->Command = rcv_hdr->Command;

View File

@ -50,12 +50,6 @@
extern struct list_head global_lock_list; extern struct list_head global_lock_list;
#define IS_SMB2(x) ((x)->vals->protocol_id != SMB10_PROT_ID)
#define HEADER_SIZE(conn) ((conn)->vals->header_size)
#define HEADER_SIZE_NO_BUF_LEN(conn) ((conn)->vals->header_size - 4)
#define MAX_HEADER_SIZE(conn) ((conn)->vals->max_header_size)
/* RFC 1002 session packet types */ /* RFC 1002 session packet types */
#define RFC1002_SESSION_MESSAGE 0x00 #define RFC1002_SESSION_MESSAGE 0x00
#define RFC1002_SESSION_REQUEST 0x81 #define RFC1002_SESSION_REQUEST 0x81
@ -490,6 +484,12 @@ struct smb_version_cmds {
int (*proc)(struct ksmbd_work *swork); int (*proc)(struct ksmbd_work *swork);
}; };
static inline size_t
smb2_hdr_size_no_buflen(struct smb_version_values *vals)
{
return vals->header_size - 4;
}
int ksmbd_min_protocol(void); int ksmbd_min_protocol(void);
int ksmbd_max_protocol(void); int ksmbd_max_protocol(void);