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>

authored by Zhang Xiaoxu and committed by Steve French d291e703 b6b3624d

Changed files
+13 -9
fs
+1 -2
fs/cifs/cifsencrypt.c
··· 32 32 int rc; 33 33 struct kvec *iov = rqst->rq_iov; 34 34 int n_vec = rqst->rq_nvec; 35 - bool is_smb2 = HEADER_PREAMBLE_SIZE(server) == 0; 36 35 37 36 /* iov[0] is actual data and not the rfc1002 length for SMB2+ */ 38 - if (is_smb2) { 37 + if (!is_smb1(server)) { 39 38 if (iov[0].iov_len <= 4) 40 39 return -EIO; 41 40 i = 0;
+5
fs/cifs/cifsglob.h
··· 752 752 #endif 753 753 }; 754 754 755 + static inline bool is_smb1(struct TCP_Server_Info *server) 756 + { 757 + return HEADER_PREAMBLE_SIZE(server) != 0; 758 + } 759 + 755 760 static inline void cifs_server_lock(struct TCP_Server_Info *server) 756 761 { 757 762 unsigned int nofs_flag = memalloc_nofs_save();
+5 -5
fs/cifs/connect.c
··· 871 871 /* 872 872 * SMB1 does not use credits. 873 873 */ 874 - if (HEADER_PREAMBLE_SIZE(server)) 874 + if (is_smb1(server)) 875 875 return 0; 876 876 877 877 return le16_to_cpu(shdr->CreditRequest); ··· 1121 1121 /* 1122 1122 * SMB1 does not use credits. 1123 1123 */ 1124 - if (HEADER_PREAMBLE_SIZE(server)) 1124 + if (is_smb1(server)) 1125 1125 return; 1126 1126 1127 1127 if (shdr->CreditRequest) { ··· 1179 1179 if (length < 0) 1180 1180 continue; 1181 1181 1182 - if (HEADER_PREAMBLE_SIZE(server) == 0) 1183 - server->total_read = 0; 1184 - else 1182 + if (is_smb1(server)) 1185 1183 server->total_read = length; 1184 + else 1185 + server->total_read = 0; 1186 1186 1187 1187 /* 1188 1188 * The right amount was read from socket - 4 bytes,
+2 -2
fs/cifs/transport.c
··· 261 261 int nvec; 262 262 unsigned long buflen = 0; 263 263 264 - if (HEADER_PREAMBLE_SIZE(server) == 0 && rqst->rq_nvec >= 2 && 264 + if (!is_smb1(server) && rqst->rq_nvec >= 2 && 265 265 rqst->rq_iov[0].iov_len == 4) { 266 266 iov = &rqst->rq_iov[1]; 267 267 nvec = rqst->rq_nvec - 1; ··· 346 346 sigprocmask(SIG_BLOCK, &mask, &oldmask); 347 347 348 348 /* Generate a rfc1002 marker for SMB2+ */ 349 - if (HEADER_PREAMBLE_SIZE(server) == 0) { 349 + if (!is_smb1(server)) { 350 350 struct kvec hiov = { 351 351 .iov_base = &rfc1002_marker, 352 352 .iov_len = 4