cifsd: remove unneeded macros

Remove unneeded RESPONSE_BUF, REQUEST_BUF, RESPONSE_SZ, INIT_AUX_PAYLOAD,
HAS_AUX_PAYLOAD, AUX_PAYLOAD, AUX_PAYLOAD_SIZE, RESP_HDR_SIZE,
HAS_TRANSFORM_BUF and TRANSFORM_BUF macros.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Namjae Jeon 2021-03-30 12:35:23 +09:00 committed by Steve French
parent 3161ad3a71
commit e506649907
9 changed files with 139 additions and 154 deletions

View File

@ -154,7 +154,7 @@ void ksmbd_conn_wait_idle(struct ksmbd_conn *conn)
int ksmbd_conn_write(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb_hdr *rsp_hdr = RESPONSE_BUF(work);
struct smb_hdr *rsp_hdr = work->response_buf;
size_t len = 0;
int sent;
struct kvec iov[3];
@ -166,21 +166,20 @@ int ksmbd_conn_write(struct ksmbd_work *work)
return -EINVAL;
}
if (HAS_TRANSFORM_BUF(work)) {
if (work->tr_buf) {
iov[iov_idx] = (struct kvec) { work->tr_buf,
sizeof(struct smb2_transform_hdr) };
len += iov[iov_idx++].iov_len;
}
if (HAS_AUX_PAYLOAD(work)) {
iov[iov_idx] = (struct kvec) { rsp_hdr, RESP_HDR_SIZE(work) };
if (work->aux_payload_sz) {
iov[iov_idx] = (struct kvec) { rsp_hdr, work->resp_hdr_sz };
len += iov[iov_idx++].iov_len;
iov[iov_idx] = (struct kvec) { AUX_PAYLOAD(work),
AUX_PAYLOAD_SIZE(work) };
iov[iov_idx] = (struct kvec) { work->aux_payload_buf, work->aux_payload_sz };
len += iov[iov_idx++].iov_len;
} else {
if (HAS_TRANSFORM_BUF(work))
iov[iov_idx].iov_len = RESP_HDR_SIZE(work);
if (work->tr_buf)
iov[iov_idx].iov_len = work->resp_hdr_sz;
else
iov[iov_idx].iov_len = get_rfc1002_len(rsp_hdr) + 4;
iov[iov_idx].iov_base = rsp_hdr;

View File

@ -40,18 +40,18 @@ void ksmbd_free_work_struct(struct ksmbd_work *work)
WARN_ON(work->saved_cred != NULL);
if (server_conf.flags & KSMBD_GLOBAL_FLAG_CACHE_TBUF &&
work->set_trans_buf)
ksmbd_release_buffer(RESPONSE_BUF(work));
ksmbd_release_buffer(work->response_buf);
else
ksmbd_free_response(RESPONSE_BUF(work));
ksmbd_free_response(work->response_buf);
if (server_conf.flags & KSMBD_GLOBAL_FLAG_CACHE_RBUF &&
work->set_read_buf)
ksmbd_release_buffer(AUX_PAYLOAD(work));
ksmbd_release_buffer(work->aux_payload_buf);
else
ksmbd_free_response(AUX_PAYLOAD(work));
ksmbd_free_response(work->aux_payload_buf);
ksmbd_free_response(TRANSFORM_BUF(work));
ksmbd_free_request(REQUEST_BUF(work));
ksmbd_free_response(work->tr_buf);
ksmbd_free_request(work->request_buf);
if (work->async_id)
ksmbd_release_id(work->conn->async_ida, work->async_id);
kmem_cache_free(work_cache, work);

View File

@ -27,12 +27,12 @@ struct ksmbd_work {
struct ksmbd_tree_connect *tcon;
/* Pointer to received SMB header */
char *request_buf;
void *request_buf;
/* Response buffer */
char *response_buf;
void *response_buf;
/* Read data buffer */
char *aux_payload_buf;
void *aux_payload_buf;
/* Next cmd hdr in compound req buf*/
int next_smb2_rcv_hdr_off;
@ -92,24 +92,10 @@ struct ksmbd_work {
#define WORK_CLOSED(w) ((w)->state == KSMBD_WORK_CLOSED)
#define WORK_ACTIVE(w) ((w)->state == KSMBD_WORK_ACTIVE)
#define RESPONSE_BUF(w) ((void *)(w)->response_buf)
#define REQUEST_BUF(w) ((void *)(w)->request_buf)
#define RESPONSE_BUF_NEXT(w) \
((void *)((w)->response_buf + (w)->next_smb2_rsp_hdr_off))
(((w)->response_buf + (w)->next_smb2_rsp_hdr_off))
#define REQUEST_BUF_NEXT(w) \
((void *)((w)->request_buf + (w)->next_smb2_rcv_hdr_off))
#define RESPONSE_SZ(w) ((w)->response_sz)
#define INIT_AUX_PAYLOAD(w) ((w)->aux_payload_buf = NULL)
#define HAS_AUX_PAYLOAD(w) ((w)->aux_payload_sz != 0)
#define AUX_PAYLOAD(w) ((void *)((w)->aux_payload_buf))
#define AUX_PAYLOAD_SIZE(w) ((w)->aux_payload_sz)
#define RESP_HDR_SIZE(w) ((w)->resp_hdr_sz)
#define HAS_TRANSFORM_BUF(w) ((w)->tr_buf != NULL)
#define TRANSFORM_BUF(w) ((void *)((w)->tr_buf))
(((w)->request_buf + (w)->next_smb2_rcv_hdr_off))
struct ksmbd_work *ksmbd_alloc_work_struct(void);
void ksmbd_free_work_struct(struct ksmbd_work *work);

View File

@ -608,14 +608,14 @@ static inline int allocate_oplock_break_buf(struct ksmbd_work *work)
* There are two ways this function can be called. 1- while file open we break
* from exclusive/batch lock to levelII oplock and 2- while file write/truncate
* we break from levelII oplock no oplock.
* REQUEST_BUF(work) contains oplock_info.
* work->request_buf contains oplock_info.
*/
static void __smb2_oplock_break_noti(struct work_struct *wk)
{
struct smb2_oplock_break *rsp = NULL;
struct ksmbd_work *work = container_of(wk, struct ksmbd_work, work);
struct ksmbd_conn *conn = work->conn;
struct oplock_break_info *br_info = REQUEST_BUF(work);
struct oplock_break_info *br_info = work->request_buf;
struct smb2_hdr *rsp_hdr;
struct ksmbd_file *fp;
@ -634,7 +634,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
return;
}
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
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->ProtocolId = SMB2_PROTO_NUMBER;
@ -650,7 +650,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
memset(rsp_hdr->Signature, 0, 16);
rsp = RESPONSE_BUF(work);
rsp = work->response_buf;
rsp->StructureSize = cpu_to_le16(24);
if (!br_info->open_trunc &&
@ -730,7 +730,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
{
struct smb2_lease_break *rsp = NULL;
struct ksmbd_work *work = container_of(wk, struct ksmbd_work, work);
struct lease_break_info *br_info = REQUEST_BUF(work);
struct lease_break_info *br_info = work->request_buf;
struct ksmbd_conn *conn = work->conn;
struct smb2_hdr *rsp_hdr;
@ -741,7 +741,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
return;
}
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
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->ProtocolId = SMB2_PROTO_NUMBER;
@ -756,7 +756,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
rsp_hdr->SessionId = 0;
memset(rsp_hdr->Signature, 0, 16);
rsp = RESPONSE_BUF(work);
rsp = work->response_buf;
rsp->StructureSize = cpu_to_le16(44);
rsp->Reserved = 0;
rsp->Flags = 0;

View File

@ -95,7 +95,7 @@ static inline int check_conn_state(struct ksmbd_work *work)
struct smb_hdr *rsp_hdr;
if (ksmbd_conn_exiting(work) || ksmbd_conn_need_reconnect(work)) {
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
rsp_hdr->Status.CifsError = STATUS_CONNECTION_DISCONNECTED;
return 1;
}
@ -169,7 +169,7 @@ static void __handle_ksmbd_work(struct ksmbd_work *work,
return;
if (conn->ops->is_transform_hdr &&
conn->ops->is_transform_hdr(REQUEST_BUF(work))) {
conn->ops->is_transform_hdr(work->request_buf)) {
rc = conn->ops->decrypt_req(work);
if (rc < 0) {
conn->ops->set_rsp_status(work, STATUS_DATA_ERROR);

View File

@ -355,7 +355,7 @@ static int smb2_validate_credit_charge(struct smb2_hdr *hdr)
int ksmbd_smb2_check_message(struct ksmbd_work *work)
{
struct smb2_pdu *pdu = REQUEST_BUF(work);
struct smb2_pdu *pdu = work->request_buf;
struct smb2_hdr *hdr = &pdu->hdr;
int command;
__u32 clc_len; /* calculated length */

View File

@ -44,8 +44,8 @@ static void __wbuf(struct ksmbd_work *work, void **req, void **rsp)
*req = REQUEST_BUF_NEXT(work);
*rsp = RESPONSE_BUF_NEXT(work);
} else {
*req = REQUEST_BUF(work);
*rsp = RESPONSE_BUF(work);
*req = work->request_buf;
*rsp = work->response_buf;
}
}
@ -94,7 +94,7 @@ struct channel *lookup_chann_list(struct ksmbd_session *sess)
*/
int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
{
struct smb2_hdr *req_hdr = REQUEST_BUF(work);
struct smb2_hdr *req_hdr = work->request_buf;
int tree_id;
work->tcon = NULL;
@ -131,7 +131,7 @@ void smb2_set_err_rsp(struct ksmbd_work *work)
if (work->next_smb2_rcv_hdr_off)
err_rsp = RESPONSE_BUF_NEXT(work);
else
err_rsp = RESPONSE_BUF(work);
err_rsp = work->response_buf;
if (err_rsp->hdr.Status != STATUS_STOPPED_ON_SYMLINK) {
err_rsp->StructureSize = SMB2_ERROR_STRUCTURE_SIZE2_LE;
@ -139,7 +139,7 @@ void smb2_set_err_rsp(struct ksmbd_work *work)
err_rsp->Reserved = 0;
err_rsp->ByteCount = 0;
err_rsp->ErrorData[0] = 0;
inc_rfc1001_len(RESPONSE_BUF(work), SMB2_ERROR_STRUCTURE_SIZE2);
inc_rfc1001_len(work->response_buf, SMB2_ERROR_STRUCTURE_SIZE2);
}
}
@ -151,7 +151,7 @@ void smb2_set_err_rsp(struct ksmbd_work *work)
*/
int is_smb2_neg_cmd(struct ksmbd_work *work)
{
struct smb2_hdr *hdr = REQUEST_BUF(work);
struct smb2_hdr *hdr = work->request_buf;
/* is it SMB2 header ? */
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
@ -175,7 +175,7 @@ int is_smb2_neg_cmd(struct ksmbd_work *work)
*/
int is_smb2_rsp(struct ksmbd_work *work)
{
struct smb2_hdr *hdr = RESPONSE_BUF(work);
struct smb2_hdr *hdr = work->response_buf;
/* is it SMB2 header ? */
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
@ -201,7 +201,7 @@ uint16_t get_smb2_cmd_val(struct ksmbd_work *work)
if (work->next_smb2_rcv_hdr_off)
rcv_hdr = REQUEST_BUF_NEXT(work);
else
rcv_hdr = REQUEST_BUF(work);
rcv_hdr = work->request_buf;
return le16_to_cpu(rcv_hdr->Command);
}
@ -217,7 +217,7 @@ void set_smb2_rsp_status(struct ksmbd_work *work, __le32 err)
if (work->next_smb2_rcv_hdr_off)
rsp_hdr = RESPONSE_BUF_NEXT(work);
else
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
rsp_hdr->Status = err;
smb2_set_err_rsp(work);
}
@ -241,7 +241,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
conn->dialect <= SMB311_PROT_ID))
return -EINVAL;
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
@ -260,7 +260,7 @@ int init_smb2_neg_rsp(struct ksmbd_work *work)
rsp_hdr->SessionId = 0;
memset(rsp_hdr->Signature, 0, 16);
rsp = RESPONSE_BUF(work);
rsp = work->response_buf;
WARN_ON(ksmbd_conn_good(work));
@ -410,11 +410,11 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work)
work->compound_sid = le64_to_cpu(rsp->SessionId);
}
len = get_rfc1002_len(RESPONSE_BUF(work)) - work->next_smb2_rsp_hdr_off;
len = get_rfc1002_len(work->response_buf) - work->next_smb2_rsp_hdr_off;
next_hdr_offset = le32_to_cpu(req->NextCommand);
new_len = ALIGN(len, 8);
inc_rfc1001_len(RESPONSE_BUF(work), ((sizeof(struct smb2_hdr) - 4)
inc_rfc1001_len(work->response_buf, ((sizeof(struct smb2_hdr) - 4)
+ new_len - len));
rsp->NextCommand = cpu_to_le32(new_len);
@ -459,7 +459,7 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work)
*/
bool is_chained_smb2_message(struct ksmbd_work *work)
{
struct smb2_hdr *hdr = REQUEST_BUF(work);
struct smb2_hdr *hdr = work->request_buf;
unsigned int len;
if (hdr->ProtocolId != SMB2_PROTO_NUMBER)
@ -475,12 +475,12 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
* This is last request in chained command,
* align response to 8 byte
*/
len = ALIGN(get_rfc1002_len(RESPONSE_BUF(work)), 8);
len = len - get_rfc1002_len(RESPONSE_BUF(work));
len = ALIGN(get_rfc1002_len(work->response_buf), 8);
len = len - get_rfc1002_len(work->response_buf);
if (len) {
ksmbd_debug(SMB, "padding len %u\n", len);
inc_rfc1001_len(RESPONSE_BUF(work), len);
if (HAS_AUX_PAYLOAD(work))
inc_rfc1001_len(work->response_buf, len);
if (work->aux_payload_sz)
work->aux_payload_sz += len;
}
}
@ -495,8 +495,8 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
*/
int init_smb2_rsp_hdr(struct ksmbd_work *work)
{
struct smb2_hdr *rsp_hdr = RESPONSE_BUF(work);
struct smb2_hdr *rcv_hdr = REQUEST_BUF(work);
struct smb2_hdr *rsp_hdr = work->response_buf;
struct smb2_hdr *rcv_hdr = work->request_buf;
struct ksmbd_conn *conn = work->conn;
memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
@ -533,7 +533,7 @@ int init_smb2_rsp_hdr(struct ksmbd_work *work)
*/
int smb2_allocate_rsp_buf(struct ksmbd_work *work)
{
struct smb2_hdr *hdr = REQUEST_BUF(work);
struct smb2_hdr *hdr = work->request_buf;
size_t small_sz = MAX_CIFS_SMALL_BUFFER_SIZE;
size_t large_sz = work->conn->vals->max_trans_size + MAX_SMB2_HDR_SIZE;
size_t sz = small_sz;
@ -547,7 +547,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
if (cmd == SMB2_QUERY_INFO_HE) {
struct smb2_query_info_req *req;
req = REQUEST_BUF(work);
req = work->request_buf;
if (req->InfoType == SMB2_O_INFO_FILE &&
(req->FileInfoClass == FILE_FULL_EA_INFORMATION ||
req->FileInfoClass == FILE_ALL_INFORMATION)) {
@ -566,7 +566,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
else
work->response_buf = ksmbd_alloc_response(sz);
if (!RESPONSE_BUF(work)) {
if (!work->response_buf) {
ksmbd_err("Failed to allocate %zu bytes buffer\n", sz);
return -ENOMEM;
}
@ -583,7 +583,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
*/
int smb2_check_user_session(struct ksmbd_work *work)
{
struct smb2_hdr *req_hdr = REQUEST_BUF(work);
struct smb2_hdr *req_hdr = work->request_buf;
struct ksmbd_conn *conn = work->conn;
unsigned int cmd = conn->ops->get_cmd_val(work);
unsigned long long sess_id;
@ -686,7 +686,7 @@ int setup_async_work(struct ksmbd_work *work, void (*fn)(void **), void **arg)
struct ksmbd_conn *conn = work->conn;
int id;
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
rsp_hdr->Flags |= SMB2_FLAGS_ASYNC_COMMAND;
id = ksmbd_acquire_async_msg_id(conn->async_ida);
@ -716,7 +716,7 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
{
struct smb2_hdr *rsp_hdr;
rsp_hdr = RESPONSE_BUF(work);
rsp_hdr = work->response_buf;
smb2_set_err_rsp(work);
rsp_hdr->Status = status;
@ -1030,8 +1030,8 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn,
int smb2_handle_negotiate(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_negotiate_req *req = REQUEST_BUF(work);
struct smb2_negotiate_rsp *rsp = RESPONSE_BUF(work);
struct smb2_negotiate_req *req = work->request_buf;
struct smb2_negotiate_rsp *rsp = work->response_buf;
int rc = 0;
__le32 status;
@ -1078,7 +1078,7 @@ int smb2_handle_negotiate(struct ksmbd_work *work)
}
ksmbd_gen_preauth_integrity_hash(conn,
REQUEST_BUF(work),
work->request_buf,
conn->preauth_info->Preauth_HashValue);
rsp->NegotiateContextOffset =
cpu_to_le32(OFFSET_OF_NEG_CONTEXT);
@ -1198,7 +1198,7 @@ static int generate_preauth_hash(struct ksmbd_work *work)
}
ksmbd_gen_preauth_integrity_hash(conn,
REQUEST_BUF(work),
work->request_buf,
sess->Preauth_HashValue);
return 0;
}
@ -1213,7 +1213,7 @@ static int decode_negotiation_token(struct ksmbd_work *work,
if (!conn->use_spnego)
return -EINVAL;
req = REQUEST_BUF(work);
req = work->request_buf;
sz = le16_to_cpu(req->SecurityBufferLength);
if (!ksmbd_decode_negTokenInit((char *)negblob, sz, conn)) {
@ -1229,8 +1229,8 @@ static int decode_negotiation_token(struct ksmbd_work *work,
static int ntlm_negotiate(struct ksmbd_work *work,
struct negotiate_message *negblob)
{
struct smb2_sess_setup_req *req = REQUEST_BUF(work);
struct smb2_sess_setup_rsp *rsp = RESPONSE_BUF(work);
struct smb2_sess_setup_req *req = work->request_buf;
struct smb2_sess_setup_rsp *rsp = work->response_buf;
struct challenge_message *chgblob;
unsigned char *spnego_blob = NULL;
u16 spnego_blob_len;
@ -1330,8 +1330,8 @@ static struct ksmbd_user *session_user(struct ksmbd_conn *conn,
static int ntlm_authenticate(struct ksmbd_work *work)
{
struct smb2_sess_setup_req *req = REQUEST_BUF(work);
struct smb2_sess_setup_rsp *rsp = RESPONSE_BUF(work);
struct smb2_sess_setup_req *req = work->request_buf;
struct smb2_sess_setup_rsp *rsp = work->response_buf;
struct ksmbd_conn *conn = work->conn;
struct ksmbd_session *sess = work->sess;
struct channel *chann = NULL;
@ -1473,8 +1473,8 @@ static int ntlm_authenticate(struct ksmbd_work *work)
#ifdef CONFIG_SMB_SERVER_KERBEROS5
static int krb5_authenticate(struct ksmbd_work *work)
{
struct smb2_sess_setup_req *req = REQUEST_BUF(work);
struct smb2_sess_setup_rsp *rsp = RESPONSE_BUF(work);
struct smb2_sess_setup_req *req = work->request_buf;
struct smb2_sess_setup_rsp *rsp = work->response_buf;
struct ksmbd_conn *conn = work->conn;
struct ksmbd_session *sess = work->sess;
char *in_blob, *out_blob;
@ -1570,8 +1570,8 @@ static int krb5_authenticate(struct ksmbd_work *work)
int smb2_sess_setup(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_sess_setup_req *req = REQUEST_BUF(work);
struct smb2_sess_setup_rsp *rsp = RESPONSE_BUF(work);
struct smb2_sess_setup_req *req = work->request_buf;
struct smb2_sess_setup_rsp *rsp = work->response_buf;
struct ksmbd_session *sess;
struct negotiate_message *negblob;
int rc = 0;
@ -1695,8 +1695,8 @@ out_err:
int smb2_tree_connect(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_tree_connect_req *req = REQUEST_BUF(work);
struct smb2_tree_connect_rsp *rsp = RESPONSE_BUF(work);
struct smb2_tree_connect_req *req = work->request_buf;
struct smb2_tree_connect_rsp *rsp = work->response_buf;
struct ksmbd_session *sess = work->sess;
char *treename = NULL, *name = NULL;
struct ksmbd_tree_conn_status status;
@ -1858,7 +1858,7 @@ static int smb2_create_open_flags(bool file_present, __le32 access,
*/
int smb2_tree_disconnect(struct ksmbd_work *work)
{
struct smb2_tree_disconnect_rsp *rsp = RESPONSE_BUF(work);
struct smb2_tree_disconnect_rsp *rsp = work->response_buf;
struct ksmbd_session *sess = work->sess;
struct ksmbd_tree_connect *tcon = work->tcon;
@ -1868,7 +1868,7 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
ksmbd_debug(SMB, "request\n");
if (!tcon) {
struct smb2_tree_disconnect_req *req = REQUEST_BUF(work);
struct smb2_tree_disconnect_req *req = work->request_buf;
ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId);
rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED;
@ -1890,7 +1890,7 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
int smb2_session_logoff(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_logoff_rsp *rsp = RESPONSE_BUF(work);
struct smb2_logoff_rsp *rsp = work->response_buf;
struct ksmbd_session *sess = work->sess;
rsp->StructureSize = cpu_to_le16(4);
@ -1907,7 +1907,7 @@ int smb2_session_logoff(struct ksmbd_work *work)
ksmbd_conn_wait_idle(conn);
if (ksmbd_tree_conn_session_logoff(sess)) {
struct smb2_logoff_req *req = REQUEST_BUF(work);
struct smb2_logoff_req *req = work->request_buf;
ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId);
rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED;
@ -1934,8 +1934,8 @@ int smb2_session_logoff(struct ksmbd_work *work)
*/
static noinline int create_smb2_pipe(struct ksmbd_work *work)
{
struct smb2_create_rsp *rsp = RESPONSE_BUF(work);
struct smb2_create_req *req = REQUEST_BUF(work);
struct smb2_create_rsp *rsp = work->response_buf;
struct smb2_create_req *req = work->request_buf;
int id;
int err;
char *name;
@ -2490,7 +2490,7 @@ int smb2_open(struct ksmbd_work *work)
umode_t posix_mode = 0;
__le32 daccess, maximal_access = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
if (req->hdr.NextCommand && !work->next_smb2_rcv_hdr_off &&
@ -3889,7 +3889,7 @@ int smb2_query_dir(struct ksmbd_work *work)
int buffer_sz;
struct smb2_query_dir_private query_dir_private = {NULL, };
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
if (ksmbd_override_fsids(work)) {
@ -5190,7 +5190,7 @@ int smb2_query_info(struct ksmbd_work *work)
struct smb2_query_info_rsp *rsp, *rsp_org;
int rc = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
ksmbd_debug(SMB, "GOT query info request\n");
@ -5244,8 +5244,8 @@ int smb2_query_info(struct ksmbd_work *work)
static noinline int smb2_close_pipe(struct ksmbd_work *work)
{
uint64_t id;
struct smb2_close_req *req = REQUEST_BUF(work);
struct smb2_close_rsp *rsp = RESPONSE_BUF(work);
struct smb2_close_req *req = work->request_buf;
struct smb2_close_rsp *rsp = work->response_buf;
id = le64_to_cpu(req->VolatileFileId);
ksmbd_session_rpc_close(work->sess, id);
@ -5283,7 +5283,7 @@ int smb2_close(struct ksmbd_work *work)
u64 time;
int err = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
if (test_share_config_flag(work->tcon->share_conf,
@ -5386,7 +5386,7 @@ out:
*/
int smb2_echo(struct ksmbd_work *work)
{
struct smb2_echo_rsp *rsp = RESPONSE_BUF(work);
struct smb2_echo_rsp *rsp = work->response_buf;
rsp->StructureSize = cpu_to_le16(4);
rsp->Reserved = 0;
@ -5974,7 +5974,7 @@ int smb2_set_info(struct ksmbd_work *work)
ksmbd_debug(SMB, "Received set info request\n");
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
if (work->next_smb2_rcv_hdr_off) {
req = REQUEST_BUF_NEXT(work);
rsp = RESPONSE_BUF_NEXT(work);
@ -5985,8 +5985,8 @@ int smb2_set_info(struct ksmbd_work *work)
pid = work->compound_pfid;
}
} else {
req = REQUEST_BUF(work);
rsp = RESPONSE_BUF(work);
req = work->request_buf;
rsp = work->response_buf;
}
if (!HAS_FILE_ID(id)) {
@ -6062,8 +6062,8 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
int nbytes = 0, err;
uint64_t id;
struct ksmbd_rpc_command *rpc_resp;
struct smb2_read_req *req = REQUEST_BUF(work);
struct smb2_read_rsp *rsp = RESPONSE_BUF(work);
struct smb2_read_req *req = work->request_buf;
struct smb2_read_rsp *rsp = work->response_buf;
id = le64_to_cpu(req->VolatileFileId);
@ -6155,7 +6155,7 @@ int smb2_read(struct ksmbd_work *work)
ssize_t nbytes = 0, remain_bytes = 0;
int err = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
if (test_share_config_flag(work->tcon->share_conf,
@ -6212,10 +6212,10 @@ int smb2_read(struct ksmbd_work *work)
if ((nbytes == 0 && length != 0) || nbytes < mincount) {
if (server_conf.flags & KSMBD_GLOBAL_FLAG_CACHE_RBUF)
ksmbd_release_buffer(AUX_PAYLOAD(work));
ksmbd_release_buffer(work->aux_payload_buf);
else
ksmbd_free_response(AUX_PAYLOAD(work));
INIT_AUX_PAYLOAD(work);
ksmbd_free_response(work->aux_payload_buf);
work->aux_payload_buf = NULL;
rsp->hdr.Status = STATUS_END_OF_FILE;
smb2_set_err_rsp(work);
ksmbd_fd_put(work, fp);
@ -6229,12 +6229,12 @@ int smb2_read(struct ksmbd_work *work)
req->Channel == SMB2_CHANNEL_RDMA_V1) {
/* write data to the client using rdma channel */
remain_bytes = smb2_read_rdma_channel(work, req,
AUX_PAYLOAD(work), nbytes);
work->aux_payload_buf, nbytes);
if (server_conf.flags & KSMBD_GLOBAL_FLAG_CACHE_RBUF)
ksmbd_release_buffer(AUX_PAYLOAD(work));
ksmbd_release_buffer(work->aux_payload_buf);
else
ksmbd_free_response(AUX_PAYLOAD(work));
INIT_AUX_PAYLOAD(work);
ksmbd_free_response(work->aux_payload_buf);
work->aux_payload_buf = NULL;
nbytes = 0;
if (remain_bytes < 0) {
@ -6287,8 +6287,8 @@ out:
*/
static noinline int smb2_write_pipe(struct ksmbd_work *work)
{
struct smb2_write_req *req = REQUEST_BUF(work);
struct smb2_write_rsp *rsp = RESPONSE_BUF(work);
struct smb2_write_req *req = work->request_buf;
struct smb2_write_rsp *rsp = work->response_buf;
struct ksmbd_rpc_command *rpc_resp;
uint64_t id = 0;
int err = 0, ret = 0;
@ -6418,7 +6418,7 @@ int smb2_write(struct ksmbd_work *work)
bool writethrough = false;
int err = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
if (test_share_config_flag(work->tcon->share_conf,
@ -6548,7 +6548,7 @@ int smb2_flush(struct ksmbd_work *work)
struct smb2_flush_rsp *rsp, *rsp_org;
int err;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
WORK_BUFFERS(work, req, rsp);
ksmbd_debug(SMB, "SMB2_FLUSH called for fid %llu\n",
@ -6583,7 +6583,7 @@ out:
int smb2_cancel(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_hdr *hdr = REQUEST_BUF(work);
struct smb2_hdr *hdr = work->request_buf;
struct smb2_hdr *chdr;
struct ksmbd_work *cancel_work = NULL;
struct list_head *tmp;
@ -6600,7 +6600,7 @@ int smb2_cancel(struct ksmbd_work *work)
list_for_each(tmp, command_list) {
cancel_work = list_entry(tmp, struct ksmbd_work,
async_request_entry);
chdr = REQUEST_BUF(cancel_work);
chdr = cancel_work->request_buf;
if (cancel_work->async_id !=
le64_to_cpu(hdr->Id.AsyncId))
@ -6621,7 +6621,7 @@ int smb2_cancel(struct ksmbd_work *work)
list_for_each(tmp, command_list) {
cancel_work = list_entry(tmp, struct ksmbd_work,
request_entry);
chdr = REQUEST_BUF(cancel_work);
chdr = cancel_work->request_buf;
if (chdr->MessageId != hdr->MessageId ||
cancel_work == work)
@ -6754,8 +6754,8 @@ static inline bool lock_defer_pending(struct file_lock *fl)
*/
int smb2_lock(struct ksmbd_work *work)
{
struct smb2_lock_req *req = REQUEST_BUF(work);
struct smb2_lock_rsp *rsp = RESPONSE_BUF(work);
struct smb2_lock_req *req = work->request_buf;
struct smb2_lock_rsp *rsp = work->response_buf;
struct smb2_lock_element *lock_ele;
struct ksmbd_file *fp = NULL;
struct file_lock *flock = NULL;
@ -7504,7 +7504,7 @@ int smb2_ioctl(struct ksmbd_work *work)
struct ksmbd_conn *conn = work->conn;
int ret = 0;
rsp_org = RESPONSE_BUF(work);
rsp_org = work->response_buf;
if (work->next_smb2_rcv_hdr_off) {
req = REQUEST_BUF_NEXT(work);
rsp = RESPONSE_BUF_NEXT(work);
@ -7514,8 +7514,8 @@ int smb2_ioctl(struct ksmbd_work *work)
id = work->compound_fid;
}
} else {
req = REQUEST_BUF(work);
rsp = RESPONSE_BUF(work);
req = work->request_buf;
rsp = work->response_buf;
}
if (!HAS_FILE_ID(id))
@ -7725,8 +7725,8 @@ out:
*/
static void smb20_oplock_break_ack(struct ksmbd_work *work)
{
struct smb2_oplock_break *req = REQUEST_BUF(work);
struct smb2_oplock_break *rsp = RESPONSE_BUF(work);
struct smb2_oplock_break *req = work->request_buf;
struct smb2_oplock_break *rsp = work->response_buf;
struct ksmbd_file *fp;
struct oplock_info *opinfo = NULL;
__le32 err = 0;
@ -7867,8 +7867,8 @@ static int check_lease_state(struct lease *lease, __le32 req_state)
static void smb21_lease_break_ack(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_lease_ack *req = REQUEST_BUF(work);
struct smb2_lease_ack *rsp = RESPONSE_BUF(work);
struct smb2_lease_ack *req = work->request_buf;
struct smb2_lease_ack *rsp = work->response_buf;
struct oplock_info *opinfo;
__le32 err = 0;
int ret = 0;
@ -8000,8 +8000,8 @@ err_out:
*/
int smb2_oplock_break(struct ksmbd_work *work)
{
struct smb2_oplock_break *req = REQUEST_BUF(work);
struct smb2_oplock_break *rsp = RESPONSE_BUF(work);
struct smb2_oplock_break *req = work->request_buf;
struct smb2_oplock_break *rsp = work->response_buf;
switch (le16_to_cpu(req->StructureSize)) {
case OP_BREAK_STRUCT_SIZE_20:
@ -8053,7 +8053,7 @@ int smb2_notify(struct ksmbd_work *work)
*/
bool smb2_is_sign_req(struct ksmbd_work *work, unsigned int command)
{
struct smb2_hdr *rcv_hdr2 = REQUEST_BUF(work);
struct smb2_hdr *rcv_hdr2 = work->request_buf;
if ((rcv_hdr2->Flags & SMB2_FLAGS_SIGNED) &&
command != SMB2_NEGOTIATE_HE &&
@ -8078,7 +8078,7 @@ int smb2_check_sign_req(struct ksmbd_work *work)
struct kvec iov[1];
size_t len;
hdr_org = hdr = REQUEST_BUF(work);
hdr_org = hdr = work->request_buf;
if (work->next_smb2_rcv_hdr_off)
hdr = REQUEST_BUF_NEXT(work);
@ -8122,7 +8122,7 @@ void smb2_set_sign_rsp(struct ksmbd_work *work)
size_t len;
int n_vec = 1;
hdr_org = hdr = RESPONSE_BUF(work);
hdr_org = hdr = work->response_buf;
if (work->next_smb2_rsp_hdr_off)
hdr = RESPONSE_BUF_NEXT(work);
@ -8146,11 +8146,11 @@ void smb2_set_sign_rsp(struct ksmbd_work *work)
iov[0].iov_base = (char *)&hdr->ProtocolId;
iov[0].iov_len = len;
if (HAS_AUX_PAYLOAD(work)) {
iov[0].iov_len -= AUX_PAYLOAD_SIZE(work);
if (work->aux_payload_sz) {
iov[0].iov_len -= work->aux_payload_sz;
iov[1].iov_base = AUX_PAYLOAD(work);
iov[1].iov_len = AUX_PAYLOAD_SIZE(work);
iov[1].iov_base = work->aux_payload_buf;
iov[1].iov_len = work->aux_payload_sz;
n_vec++;
}
@ -8176,7 +8176,7 @@ int smb3_check_sign_req(struct ksmbd_work *work)
struct kvec iov[1];
size_t len;
hdr_org = hdr = REQUEST_BUF(work);
hdr_org = hdr = work->request_buf;
if (work->next_smb2_rcv_hdr_off)
hdr = REQUEST_BUF_NEXT(work);
@ -8237,7 +8237,7 @@ void smb3_set_sign_rsp(struct ksmbd_work *work)
size_t len;
char *signing_key;
hdr_org = hdr = RESPONSE_BUF(work);
hdr_org = hdr = work->response_buf;
if (work->next_smb2_rsp_hdr_off)
hdr = RESPONSE_BUF_NEXT(work);
@ -8273,10 +8273,10 @@ void smb3_set_sign_rsp(struct ksmbd_work *work)
memset(hdr->Signature, 0, SMB2_SIGNATURE_SIZE);
iov[0].iov_base = (char *)&hdr->ProtocolId;
iov[0].iov_len = len;
if (HAS_AUX_PAYLOAD(work)) {
iov[0].iov_len -= AUX_PAYLOAD_SIZE(work);
iov[1].iov_base = AUX_PAYLOAD(work);
iov[1].iov_len = AUX_PAYLOAD_SIZE(work);
if (work->aux_payload_sz) {
iov[0].iov_len -= work->aux_payload_sz;
iov[1].iov_base = work->aux_payload_buf;
iov[1].iov_len = work->aux_payload_sz;
n_vec++;
}
@ -8336,11 +8336,11 @@ static void fill_transform_hdr(struct smb2_transform_hdr *tr_hdr,
int smb3_encrypt_resp(struct ksmbd_work *work)
{
char *buf = RESPONSE_BUF(work);
char *buf = work->response_buf;
struct smb2_transform_hdr *tr_hdr;
struct kvec iov[3];
int rc = -ENOMEM;
int buf_size = 0, rq_nvec = 2 + (HAS_AUX_PAYLOAD(work) ? 1 : 0);
int buf_size = 0, rq_nvec = 2 + (work->aux_payload_sz ? 1 : 0);
if (ARRAY_SIZE(iov) < rq_nvec)
return -ENOMEM;
@ -8358,11 +8358,11 @@ int smb3_encrypt_resp(struct ksmbd_work *work)
iov[1].iov_base = buf + 4;
iov[1].iov_len = get_rfc1002_len(buf);
if (HAS_AUX_PAYLOAD(work)) {
iov[1].iov_len = RESP_HDR_SIZE(work) - 4;
if (work->aux_payload_sz) {
iov[1].iov_len = work->resp_hdr_sz - 4;
iov[2].iov_base = AUX_PAYLOAD(work);
iov[2].iov_len = AUX_PAYLOAD_SIZE(work);
iov[2].iov_base = work->aux_payload_buf;
iov[2].iov_len = work->aux_payload_sz;
buf_size += iov[2].iov_len;
}
buf_size += iov[1].iov_len;
@ -8390,7 +8390,7 @@ int smb3_decrypt_req(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct ksmbd_session *sess;
char *buf = REQUEST_BUF(work);
char *buf = work->request_buf;
struct smb2_hdr *hdr;
unsigned int pdu_length = get_rfc1002_len(buf);
struct kvec iov[2];
@ -8437,7 +8437,7 @@ int smb3_decrypt_req(struct ksmbd_work *work)
bool smb3_11_final_sess_setup_resp(struct ksmbd_work *work)
{
struct ksmbd_conn *conn = work->conn;
struct smb2_hdr *rsp = RESPONSE_BUF(work);
struct smb2_hdr *rsp = work->response_buf;
if (conn->dialect < SMB30_PROT_ID)
return false;

View File

@ -116,7 +116,7 @@ int ksmbd_lookup_protocol_idx(char *str)
*/
int ksmbd_verify_smb_message(struct ksmbd_work *work)
{
struct smb2_hdr *smb2_hdr = REQUEST_BUF(work);
struct smb2_hdr *smb2_hdr = work->request_buf;
if (smb2_hdr->ProtocolId == SMB2_PROTO_NUMBER)
return ksmbd_smb2_check_message(work);
@ -408,7 +408,7 @@ static int __smb2_negotiate(struct ksmbd_conn *conn)
static int smb_handle_negotiate(struct ksmbd_work *work)
{
struct smb_negotiate_rsp *neg_rsp = RESPONSE_BUF(work);
struct smb_negotiate_rsp *neg_rsp = work->response_buf;
ksmbd_debug(SMB, "Unsupported SMB protocol\n");
neg_rsp->hdr.Status.CifsError = STATUS_INVALID_LOGON_TYPE;
@ -420,11 +420,11 @@ int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command)
struct ksmbd_conn *conn = work->conn;
int ret;
conn->dialect = ksmbd_negotiate_smb_dialect(REQUEST_BUF(work));
conn->dialect = ksmbd_negotiate_smb_dialect(work->request_buf);
ksmbd_debug(SMB, "conn->dialect 0x%x\n", conn->dialect);
if (command == SMB2_NEGOTIATE_HE) {
struct smb2_hdr *smb2_hdr = REQUEST_BUF(work);
struct smb2_hdr *smb2_hdr = work->request_buf;
if (smb2_hdr->ProtocolId != SMB2_PROTO_NUMBER) {
ksmbd_debug(SMB, "Downgrade to SMB1 negotiation\n");

View File

@ -372,7 +372,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work,
char namebuf[NAME_MAX];
int ret;
rbuf = AUX_PAYLOAD(work);
rbuf = work->aux_payload_buf;
filp = fp->filp;
inode = d_inode(filp->f_path.dentry);
if (S_ISDIR(inode->i_mode))