aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb2pdu.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-07-12 10:30:44 -0400
committerPavel Shilovsky <pshilovsky@samba.org>2012-07-24 13:55:17 -0400
commit9094fad1ed90caebd25b1bdec3c8982d079356ee (patch)
treea6a111f572f18533d31d80a771fe848507cb26b6 /fs/cifs/smb2pdu.c
parentf6d7617862e106affc59c6933099e45629af5c4e (diff)
CIFS: Add echo request support for SMB2
Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r--fs/cifs/smb2pdu.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 7ef5324786a6..373b6945161f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1074,3 +1074,52 @@ qinf_exit:
1074 free_rsp_buf(resp_buftype, rsp); 1074 free_rsp_buf(resp_buftype, rsp);
1075 return rc; 1075 return rc;
1076} 1076}
1077
1078/*
1079 * This is a no-op for now. We're not really interested in the reply, but
1080 * rather in the fact that the server sent one and that server->lstrp
1081 * gets updated.
1082 *
1083 * FIXME: maybe we should consider checking that the reply matches request?
1084 */
1085static void
1086smb2_echo_callback(struct mid_q_entry *mid)
1087{
1088 struct TCP_Server_Info *server = mid->callback_data;
1089 struct smb2_echo_rsp *smb2 = (struct smb2_echo_rsp *)mid->resp_buf;
1090 unsigned int credits_received = 1;
1091
1092 if (mid->mid_state == MID_RESPONSE_RECEIVED)
1093 credits_received = le16_to_cpu(smb2->hdr.CreditRequest);
1094
1095 DeleteMidQEntry(mid);
1096 add_credits(server, credits_received, CIFS_ECHO_OP);
1097}
1098
1099int
1100SMB2_echo(struct TCP_Server_Info *server)
1101{
1102 struct smb2_echo_req *req;
1103 int rc = 0;
1104 struct kvec iov;
1105
1106 cFYI(1, "In echo request");
1107
1108 rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req);
1109 if (rc)
1110 return rc;
1111
1112 req->hdr.CreditRequest = cpu_to_le16(1);
1113
1114 iov.iov_base = (char *)req;
1115 /* 4 for rfc1002 length field */
1116 iov.iov_len = get_rfc1002_length(req) + 4;
1117
1118 rc = cifs_call_async(server, &iov, 1, NULL, smb2_echo_callback, server,
1119 CIFS_ECHO_OP);
1120 if (rc)
1121 cFYI(1, "Echo request failed: %d", rc);
1122
1123 cifs_small_buf_release(req);
1124 return rc;
1125}