mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-14 09:25:12 +00:00
cifs: add a third receive phase to cifs_demultiplex_thread
Have the demultiplex thread receive just enough to get to the MID, and then find it before receiving the rest. Later, we'll use this to swap in a preallocated receive buffer for some calls. Reviewed-and-Tested-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Jeff Layton <jlayton@redhat.com>
This commit is contained in:
parent
1041e3f991
commit
89482a56a0
@ -746,11 +746,25 @@ cifs_demultiplex_thread(void *p)
|
|||||||
if (!is_smb_response(server, buf[0]))
|
if (!is_smb_response(server, buf[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* check the length */
|
/* make sure we have enough to get to the MID */
|
||||||
if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) ||
|
if (pdu_length < sizeof(struct smb_hdr) - 1 - 4) {
|
||||||
(pdu_length < sizeof(struct smb_hdr) - 1 - 4)) {
|
cERROR(1, "SMB response too short (%u bytes)",
|
||||||
cERROR(1, "Invalid size SMB length %d pdu_length %d",
|
pdu_length);
|
||||||
4, pdu_length + 4);
|
cifs_reconnect(server);
|
||||||
|
wake_up(&server->response_q);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read down to the MID */
|
||||||
|
length = read_from_socket(server, buf + 4,
|
||||||
|
sizeof(struct smb_hdr) - 1 - 4);
|
||||||
|
if (length < 0)
|
||||||
|
continue;
|
||||||
|
total_read += length;
|
||||||
|
|
||||||
|
if (pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
|
||||||
|
cERROR(1, "SMB response too long (%u bytes)",
|
||||||
|
pdu_length);
|
||||||
cifs_reconnect(server);
|
cifs_reconnect(server);
|
||||||
wake_up(&server->response_q);
|
wake_up(&server->response_q);
|
||||||
continue;
|
continue;
|
||||||
@ -759,12 +773,15 @@ cifs_demultiplex_thread(void *p)
|
|||||||
/* else length ok */
|
/* else length ok */
|
||||||
if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
|
if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
|
||||||
isLargeBuf = true;
|
isLargeBuf = true;
|
||||||
memcpy(bigbuf, smallbuf, 4);
|
memcpy(bigbuf, smallbuf, total_read);
|
||||||
smb_buffer = (struct smb_hdr *)bigbuf;
|
smb_buffer = (struct smb_hdr *)bigbuf;
|
||||||
buf = bigbuf;
|
buf = bigbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = read_from_socket(server, buf + 4, pdu_length);
|
/* now read the rest */
|
||||||
|
length = read_from_socket(server,
|
||||||
|
buf + sizeof(struct smb_hdr) - 1,
|
||||||
|
pdu_length - sizeof(struct smb_hdr) + 1 + 4);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
continue;
|
continue;
|
||||||
total_read += length;
|
total_read += length;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user