aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2013-10-09 12:03:04 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2013-10-09 12:03:04 +0000
commit1008ac5eb7b01f2c2dd02c21a49c587e3615428d (patch)
treea3caab6e0ecc84ff09d8c357cc58191e7bfb5125 /sys/cam
parentc11a15bf8d77625b462f4007508b8dee6cee22cb (diff)
downloadsrc-1008ac5eb7b01f2c2dd02c21a49c587e3615428d.tar.gz
src-1008ac5eb7b01f2c2dd02c21a49c587e3615428d.zip
Fix NOP-In/NOP-Out payload handling. Previous way didn't work at all; fortunately
nothing seems to actually use this feature, but it's required by standard. Approved by: re (glebius) Sponsored by: FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=256187
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index e8e2d33a42dd..1f310d926f85 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -455,6 +455,9 @@ cfiscsi_pdu_handle_nop_out(struct icl_pdu *request)
struct iscsi_bhs_nop_out *bhsno;
struct iscsi_bhs_nop_in *bhsni;
struct icl_pdu *response;
+ void *data = NULL;
+ size_t datasize;
+ int error;
cs = PDU_SESSION(request);
bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs;
@@ -468,9 +471,26 @@ cfiscsi_pdu_handle_nop_out(struct icl_pdu *request)
return;
}
+ datasize = icl_pdu_data_segment_length(request);
+ if (datasize > 0) {
+ data = malloc(datasize, M_CFISCSI, M_NOWAIT | M_ZERO);
+ if (data == NULL) {
+ CFISCSI_SESSION_WARN(cs, "failed to allocate memory; "
+ "dropping connection");
+ icl_pdu_free(request);
+ cfiscsi_session_terminate(cs);
+ return;
+ }
+ icl_pdu_get_data(request, 0, data, datasize);
+ }
+
response = cfiscsi_pdu_new_response(request, M_NOWAIT);
if (response == NULL) {
+ CFISCSI_SESSION_WARN(cs, "failed to allocate memory; "
+ "droppping connection");
+ free(data, M_CFISCSI);
icl_pdu_free(request);
+ cfiscsi_session_terminate(cs);
return;
}
bhsni = (struct iscsi_bhs_nop_in *)response->ip_bhs;
@@ -478,14 +498,19 @@ cfiscsi_pdu_handle_nop_out(struct icl_pdu *request)
bhsni->bhsni_flags = 0x80;
bhsni->bhsni_initiator_task_tag = bhsno->bhsno_initiator_task_tag;
bhsni->bhsni_target_transfer_tag = 0xffffffff;
-
-#if 0
- /* XXX */
- response->ip_data_len = request->ip_data_len;
- response->ip_data_mbuf = request->ip_data_mbuf;
- request->ip_data_len = 0;
- request->ip_data_mbuf = NULL;
-#endif
+ if (datasize > 0) {
+ error = icl_pdu_append_data(response, data, datasize, M_NOWAIT);
+ if (error != 0) {
+ CFISCSI_SESSION_WARN(cs, "failed to allocate memory; "
+ "dropping connection");
+ free(data, M_CFISCSI);
+ icl_pdu_free(request);
+ icl_pdu_free(response);
+ cfiscsi_session_terminate(cs);
+ return;
+ }
+ free(data, M_CFISCSI);
+ }
icl_pdu_free(request);
cfiscsi_pdu_queue(response);