Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: remove struct smb2_hdr

struct smb2_hdr is now just a wrapper for smb2_sync_hdr.
We can thus get rid of smb2_hdr completely and access the sync header directly.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Ronnie Sahlberg and committed by
Steve French
49f466bd d81243c6

+41 -55
+1 -1
fs/cifs/misc.c
··· 148 148 * SMB2 header is bigger than CIFS one - no problems to clean some 149 149 * more bytes for CIFS. 150 150 */ 151 - size_t buf_size = sizeof(struct smb2_hdr); 151 + size_t buf_size = sizeof(struct smb2_sync_hdr); 152 152 153 153 /* 154 154 * We could use negotiated size instead of max_msgsize -
-5
fs/cifs/smb2glob.h
··· 61 61 /* Maximum buffer size value we can send with 1 credit */ 62 62 #define SMB2_MAX_BUFFER_SIZE 65536 63 63 64 - static inline struct smb2_sync_hdr *get_sync_hdr(void *buf) 65 - { 66 - return &(((struct smb2_hdr *)buf)->sync_hdr); 67 - } 68 - 69 64 #endif /* _SMB2_GLOB_H */
+1 -1
fs/cifs/smb2maperror.c
··· 2451 2451 int 2452 2452 map_smb2_to_linux_error(char *buf, bool log_err) 2453 2453 { 2454 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 2454 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2455 2455 unsigned int i; 2456 2456 int rc = -EIO; 2457 2457 __le32 smb2err = shdr->Status;
+1 -1
fs/cifs/smb2misc.c
··· 716 716 int 717 717 smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server) 718 718 { 719 - struct smb2_sync_hdr *sync_hdr = get_sync_hdr(buffer); 719 + struct smb2_sync_hdr *sync_hdr = (struct smb2_sync_hdr *)buffer; 720 720 struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer; 721 721 struct cifs_tcon *tcon; 722 722 struct close_cancelled_open *cancelled;
+6 -6
fs/cifs/smb2ops.c
··· 123 123 static unsigned int 124 124 smb2_get_credits(struct mid_q_entry *mid) 125 125 { 126 - struct smb2_sync_hdr *shdr = get_sync_hdr(mid->resp_buf); 126 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)mid->resp_buf; 127 127 128 128 return le16_to_cpu(shdr->CreditRequest); 129 129 } ··· 190 190 smb2_find_mid(struct TCP_Server_Info *server, char *buf) 191 191 { 192 192 struct mid_q_entry *mid; 193 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 193 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 194 194 __u64 wire_mid = le64_to_cpu(shdr->MessageId); 195 195 196 196 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) { ··· 215 215 smb2_dump_detail(void *buf, struct TCP_Server_Info *server) 216 216 { 217 217 #ifdef CONFIG_CIFS_DEBUG2 218 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 218 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 219 219 220 220 cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", 221 221 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, ··· 1303 1303 static bool 1304 1304 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length) 1305 1305 { 1306 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 1306 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 1307 1307 1308 1308 if (shdr->Status != STATUS_PENDING) 1309 1309 return false; ··· 1321 1321 static bool 1322 1322 smb2_is_session_expired(char *buf) 1323 1323 { 1324 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 1324 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 1325 1325 1326 1326 if (shdr->Status != STATUS_NETWORK_SESSION_EXPIRED && 1327 1327 shdr->Status != STATUS_USER_SESSION_DELETED) ··· 2534 2534 unsigned int cur_page_idx; 2535 2535 unsigned int pad_len; 2536 2536 struct cifs_readdata *rdata = mid->callback_data; 2537 - struct smb2_sync_hdr *shdr = get_sync_hdr(buf); 2537 + struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 2538 2538 struct bio_vec *bvec = NULL; 2539 2539 struct iov_iter iter; 2540 2540 struct kvec iov;
+14 -14
fs/cifs/smb2pdu.c
··· 767 767 server->capabilities |= SMB2_NT_FIND | SMB2_LARGE_FILES; 768 768 769 769 security_blob = smb2_get_data_area_len(&blob_offset, &blob_length, 770 - &rsp->hdr.sync_hdr); 770 + (struct smb2_sync_hdr *)rsp); 771 771 /* 772 772 * See MS-SMB2 section 2.2.4: if no blob, client picks default which 773 773 * for us will be ··· 1131 1131 goto out_put_spnego_key; 1132 1132 1133 1133 rsp = (struct smb2_sess_setup_rsp *)sess_data->iov[0].iov_base; 1134 - ses->Suid = rsp->hdr.sync_hdr.SessionId; 1134 + ses->Suid = rsp->sync_hdr.SessionId; 1135 1135 1136 1136 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1137 1137 ··· 1207 1207 1208 1208 /* If true, rc here is expected and not an error */ 1209 1209 if (sess_data->buf0_type != CIFS_NO_BUFFER && 1210 - rsp->hdr.sync_hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) 1210 + rsp->sync_hdr.Status == STATUS_MORE_PROCESSING_REQUIRED) 1211 1211 rc = 0; 1212 1212 1213 1213 if (rc) ··· 1228 1228 cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n"); 1229 1229 1230 1230 1231 - ses->Suid = rsp->hdr.sync_hdr.SessionId; 1231 + ses->Suid = rsp->sync_hdr.SessionId; 1232 1232 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1233 1233 1234 1234 out: ··· 1286 1286 1287 1287 rsp = (struct smb2_sess_setup_rsp *)sess_data->iov[0].iov_base; 1288 1288 1289 - ses->Suid = rsp->hdr.sync_hdr.SessionId; 1289 + ses->Suid = rsp->sync_hdr.SessionId; 1290 1290 ses->session_flags = le16_to_cpu(rsp->SessionFlags); 1291 1291 1292 1292 rc = SMB2_sess_establish_session(sess_data); ··· 1535 1535 tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess); 1536 1536 tcon->tidStatus = CifsGood; 1537 1537 tcon->need_reconnect = false; 1538 - tcon->tid = rsp->hdr.sync_hdr.TreeId; 1538 + tcon->tid = rsp->sync_hdr.TreeId; 1539 1539 strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); 1540 1540 1541 1541 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && ··· 1555 1555 return rc; 1556 1556 1557 1557 tcon_error_exit: 1558 - if (rsp && rsp->hdr.sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { 1558 + if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { 1559 1559 cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); 1560 1560 } 1561 1561 goto tcon_exit; ··· 2526 2526 unsigned int credits_received = 1; 2527 2527 2528 2528 if (mid->mid_state == MID_RESPONSE_RECEIVED) 2529 - credits_received = le16_to_cpu(rsp->hdr.sync_hdr.CreditRequest); 2529 + credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); 2530 2530 2531 2531 DeleteMidQEntry(mid); 2532 2532 add_credits(server, credits_received, CIFS_ECHO_OP); ··· 3006 3006 3007 3007 switch (mid->mid_state) { 3008 3008 case MID_RESPONSE_RECEIVED: 3009 - credits_received = le16_to_cpu(rsp->hdr.sync_hdr.CreditRequest); 3009 + credits_received = le16_to_cpu(rsp->sync_hdr.CreditRequest); 3010 3010 wdata->result = smb2_check_receive(mid, tcon->ses->server, 0); 3011 3011 if (wdata->result != 0) 3012 3012 break; ··· 3398 3398 3399 3399 if (rc) { 3400 3400 if (rc == -ENODATA && 3401 - rsp->hdr.sync_hdr.Status == STATUS_NO_MORE_FILES) { 3401 + rsp->sync_hdr.Status == STATUS_NO_MORE_FILES) { 3402 3402 srch_inf->endOfSearch = true; 3403 3403 rc = 0; 3404 3404 } ··· 3781 3781 rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; 3782 3782 3783 3783 info = (struct smb2_fs_full_size_info *)(server->vals->header_preamble_size + 3784 - le16_to_cpu(rsp->OutputBufferOffset) + (char *)&rsp->hdr); 3784 + le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp); 3785 3785 rc = validate_iov(server, 3786 3786 le16_to_cpu(rsp->OutputBufferOffset), 3787 3787 le32_to_cpu(rsp->OutputBufferLength), &rsp_iov, ··· 3846 3846 3847 3847 if (level == FS_ATTRIBUTE_INFORMATION) 3848 3848 memcpy(&tcon->fsAttrInfo, server->vals->header_preamble_size + offset 3849 - + (char *)&rsp->hdr, min_t(unsigned int, 3849 + + (char *)rsp, min_t(unsigned int, 3850 3850 rsp_len, max_len)); 3851 3851 else if (level == FS_DEVICE_INFORMATION) 3852 3852 memcpy(&tcon->fsDevInfo, server->vals->header_preamble_size + offset 3853 - + (char *)&rsp->hdr, sizeof(FILE_SYSTEM_DEVICE_INFO)); 3853 + + (char *)rsp, sizeof(FILE_SYSTEM_DEVICE_INFO)); 3854 3854 else if (level == FS_SECTOR_SIZE_INFORMATION) { 3855 3855 struct smb3_fs_ss_info *ss_info = (struct smb3_fs_ss_info *) 3856 - (server->vals->header_preamble_size + offset + (char *)&rsp->hdr); 3856 + (server->vals->header_preamble_size + offset + (char *)rsp); 3857 3857 tcon->ss_flags = le32_to_cpu(ss_info->Flags); 3858 3858 tcon->perf_sector_size = 3859 3859 le32_to_cpu(ss_info->PhysicalBytesPerSectorForPerf);
+18 -27
fs/cifs/smb2pdu.h
··· 122 122 __le16 StructureSize2; /* size of wct area (varies, request specific) */ 123 123 } __packed; 124 124 125 - struct smb2_hdr { 126 - struct smb2_sync_hdr sync_hdr; 127 - } __packed; 128 - 129 - struct smb2_pdu { 130 - struct smb2_hdr hdr; 131 - __le16 StructureSize2; /* size of wct area (varies, request specific) */ 132 - } __packed; 133 - 134 125 #define SMB3_AES128CMM_NONCE 11 135 126 #define SMB3_AES128GCM_NONCE 12 136 127 ··· 156 165 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) 157 166 158 167 struct smb2_err_rsp { 159 - struct smb2_hdr hdr; 168 + struct smb2_sync_hdr sync_hdr; 160 169 __le16 StructureSize; 161 170 __le16 Reserved; /* MBZ */ 162 171 __le32 ByteCount; /* even if zero, at least one byte follows */ ··· 294 303 } __packed; 295 304 296 305 struct smb2_negotiate_rsp { 297 - struct smb2_hdr hdr; 306 + struct smb2_sync_hdr sync_hdr; 298 307 __le16 StructureSize; /* Must be 65 */ 299 308 __le16 SecurityMode; 300 309 __le16 DialectRevision; ··· 334 343 #define SMB2_SESSION_FLAG_IS_NULL 0x0002 335 344 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 336 345 struct smb2_sess_setup_rsp { 337 - struct smb2_hdr hdr; 346 + struct smb2_sync_hdr sync_hdr; 338 347 __le16 StructureSize; /* Must be 9 */ 339 348 __le16 SessionFlags; 340 349 __le16 SecurityBufferOffset; ··· 349 358 } __packed; 350 359 351 360 struct smb2_logoff_rsp { 352 - struct smb2_hdr hdr; 361 + struct smb2_sync_hdr sync_hdr; 353 362 __le16 StructureSize; /* Must be 4 */ 354 363 __le16 Reserved; 355 364 } __packed; ··· 445 454 } __packed; 446 455 447 456 struct smb2_tree_connect_rsp { 448 - struct smb2_hdr hdr; 457 + struct smb2_sync_hdr sync_hdr; 449 458 __le16 StructureSize; /* Must be 16 */ 450 459 __u8 ShareType; /* see below */ 451 460 __u8 Reserved; ··· 496 505 } __packed; 497 506 498 507 struct smb2_tree_disconnect_rsp { 499 - struct smb2_hdr hdr; 508 + struct smb2_sync_hdr sync_hdr; 500 509 __le16 StructureSize; /* Must be 4 */ 501 510 __le16 Reserved; 502 511 } __packed; ··· 633 642 } __packed; 634 643 635 644 struct smb2_create_rsp { 636 - struct smb2_hdr hdr; 645 + struct smb2_sync_hdr sync_hdr; 637 646 __le16 StructureSize; /* Must be 89 */ 638 647 __u8 OplockLevel; 639 648 __u8 Reserved; ··· 896 905 } __packed; 897 906 898 907 struct smb2_ioctl_rsp { 899 - struct smb2_hdr hdr; 908 + struct smb2_sync_hdr sync_hdr; 900 909 __le16 StructureSize; /* Must be 57 */ 901 910 __u16 Reserved; 902 911 __le32 CtlCode; ··· 923 932 } __packed; 924 933 925 934 struct smb2_close_rsp { 926 - struct smb2_hdr hdr; 935 + struct smb2_sync_hdr sync_hdr; 927 936 __le16 StructureSize; /* 60 */ 928 937 __le16 Flags; 929 938 __le32 Reserved; ··· 946 955 } __packed; 947 956 948 957 struct smb2_flush_rsp { 949 - struct smb2_hdr hdr; 958 + struct smb2_sync_hdr sync_hdr; 950 959 __le16 StructureSize; 951 960 __le16 Reserved; 952 961 } __packed; ··· 978 987 } __packed; 979 988 980 989 struct smb2_read_rsp { 981 - struct smb2_hdr hdr; 990 + struct smb2_sync_hdr sync_hdr; 982 991 __le16 StructureSize; /* Must be 17 */ 983 992 __u8 DataOffset; 984 993 __u8 Reserved; ··· 1009 1018 } __packed; 1010 1019 1011 1020 struct smb2_write_rsp { 1012 - struct smb2_hdr hdr; 1021 + struct smb2_sync_hdr sync_hdr; 1013 1022 __le16 StructureSize; /* Must be 17 */ 1014 1023 __u8 DataOffset; 1015 1024 __u8 Reserved; ··· 1043 1052 } __packed; 1044 1053 1045 1054 struct smb2_lock_rsp { 1046 - struct smb2_hdr hdr; 1055 + struct smb2_sync_hdr sync_hdr; 1047 1056 __le16 StructureSize; /* Must be 4 */ 1048 1057 __le16 Reserved; 1049 1058 } __packed; ··· 1055 1064 } __packed; 1056 1065 1057 1066 struct smb2_echo_rsp { 1058 - struct smb2_hdr hdr; 1067 + struct smb2_sync_hdr sync_hdr; 1059 1068 __le16 StructureSize; /* Must be 4 */ 1060 1069 __u16 Reserved; 1061 1070 } __packed; ··· 1081 1090 } __packed; 1082 1091 1083 1092 struct smb2_query_directory_rsp { 1084 - struct smb2_hdr hdr; 1093 + struct smb2_sync_hdr sync_hdr; 1085 1094 __le16 StructureSize; /* Must be 9 */ 1086 1095 __le16 OutputBufferOffset; 1087 1096 __le32 OutputBufferLength; ··· 1130 1139 } __packed; 1131 1140 1132 1141 struct smb2_query_info_rsp { 1133 - struct smb2_hdr hdr; 1142 + struct smb2_sync_hdr sync_hdr; 1134 1143 __le16 StructureSize; /* Must be 9 */ 1135 1144 __le16 OutputBufferOffset; 1136 1145 __le32 OutputBufferLength; ··· 1152 1161 } __packed; 1153 1162 1154 1163 struct smb2_set_info_rsp { 1155 - struct smb2_hdr hdr; 1164 + struct smb2_sync_hdr sync_hdr; 1156 1165 __le16 StructureSize; /* Must be 2 */ 1157 1166 } __packed; 1158 1167 ··· 1169 1178 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 1170 1179 1171 1180 struct smb2_lease_break { 1172 - struct smb2_hdr hdr; 1181 + struct smb2_sync_hdr sync_hdr; 1173 1182 __le16 StructureSize; /* Must be 44 */ 1174 1183 __le16 Reserved; 1175 1184 __le32 Flags;