cifs: Add helper function to check smb1+ server
SMB1 server's header_preamble_size is not 0, add use is_smb1 function to simplify the code, no actual functional changes. Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
b6b3624d01
commit
d291e703f4
@ -32,10 +32,9 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
|
|||||||
int rc;
|
int rc;
|
||||||
struct kvec *iov = rqst->rq_iov;
|
struct kvec *iov = rqst->rq_iov;
|
||||||
int n_vec = rqst->rq_nvec;
|
int n_vec = rqst->rq_nvec;
|
||||||
bool is_smb2 = HEADER_PREAMBLE_SIZE(server) == 0;
|
|
||||||
|
|
||||||
/* iov[0] is actual data and not the rfc1002 length for SMB2+ */
|
/* iov[0] is actual data and not the rfc1002 length for SMB2+ */
|
||||||
if (is_smb2) {
|
if (!is_smb1(server)) {
|
||||||
if (iov[0].iov_len <= 4)
|
if (iov[0].iov_len <= 4)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -752,6 +752,11 @@ struct TCP_Server_Info {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline bool is_smb1(struct TCP_Server_Info *server)
|
||||||
|
{
|
||||||
|
return HEADER_PREAMBLE_SIZE(server) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void cifs_server_lock(struct TCP_Server_Info *server)
|
static inline void cifs_server_lock(struct TCP_Server_Info *server)
|
||||||
{
|
{
|
||||||
unsigned int nofs_flag = memalloc_nofs_save();
|
unsigned int nofs_flag = memalloc_nofs_save();
|
||||||
|
@ -871,7 +871,7 @@ smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
|
|||||||
/*
|
/*
|
||||||
* SMB1 does not use credits.
|
* SMB1 does not use credits.
|
||||||
*/
|
*/
|
||||||
if (HEADER_PREAMBLE_SIZE(server))
|
if (is_smb1(server))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return le16_to_cpu(shdr->CreditRequest);
|
return le16_to_cpu(shdr->CreditRequest);
|
||||||
@ -1121,7 +1121,7 @@ smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
|
|||||||
/*
|
/*
|
||||||
* SMB1 does not use credits.
|
* SMB1 does not use credits.
|
||||||
*/
|
*/
|
||||||
if (HEADER_PREAMBLE_SIZE(server))
|
if (is_smb1(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (shdr->CreditRequest) {
|
if (shdr->CreditRequest) {
|
||||||
@ -1179,10 +1179,10 @@ cifs_demultiplex_thread(void *p)
|
|||||||
if (length < 0)
|
if (length < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (HEADER_PREAMBLE_SIZE(server) == 0)
|
if (is_smb1(server))
|
||||||
server->total_read = 0;
|
|
||||||
else
|
|
||||||
server->total_read = length;
|
server->total_read = length;
|
||||||
|
else
|
||||||
|
server->total_read = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The right amount was read from socket - 4 bytes,
|
* The right amount was read from socket - 4 bytes,
|
||||||
|
@ -261,7 +261,7 @@ smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst)
|
|||||||
int nvec;
|
int nvec;
|
||||||
unsigned long buflen = 0;
|
unsigned long buflen = 0;
|
||||||
|
|
||||||
if (HEADER_PREAMBLE_SIZE(server) == 0 && rqst->rq_nvec >= 2 &&
|
if (!is_smb1(server) && rqst->rq_nvec >= 2 &&
|
||||||
rqst->rq_iov[0].iov_len == 4) {
|
rqst->rq_iov[0].iov_len == 4) {
|
||||||
iov = &rqst->rq_iov[1];
|
iov = &rqst->rq_iov[1];
|
||||||
nvec = rqst->rq_nvec - 1;
|
nvec = rqst->rq_nvec - 1;
|
||||||
@ -346,7 +346,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
|
|||||||
sigprocmask(SIG_BLOCK, &mask, &oldmask);
|
sigprocmask(SIG_BLOCK, &mask, &oldmask);
|
||||||
|
|
||||||
/* Generate a rfc1002 marker for SMB2+ */
|
/* Generate a rfc1002 marker for SMB2+ */
|
||||||
if (HEADER_PREAMBLE_SIZE(server) == 0) {
|
if (!is_smb1(server)) {
|
||||||
struct kvec hiov = {
|
struct kvec hiov = {
|
||||||
.iov_base = &rfc1002_marker,
|
.iov_base = &rfc1002_marker,
|
||||||
.iov_len = 4
|
.iov_len = 4
|
||||||
|
Loading…
Reference in New Issue
Block a user