ctl_frontend_iscsi.c (256163) | ctl_frontend_iscsi.c (256187) |
---|---|
1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256163 2013-10-08 19:18:02Z trasz $ | 29 * $FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256187 2013-10-09 12:03:04Z trasz $ |
30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> | 30 */ 31 32/* 33 * CTL frontend for the iSCSI protocol. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256163 2013-10-08 19:18:02Z trasz $"); | 37__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 256187 2013-10-09 12:03:04Z trasz $"); |
38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 404 unchanged lines hidden (view full) --- 450 451static void 452cfiscsi_pdu_handle_nop_out(struct icl_pdu *request) 453{ 454 struct cfiscsi_session *cs; 455 struct iscsi_bhs_nop_out *bhsno; 456 struct iscsi_bhs_nop_in *bhsni; 457 struct icl_pdu *response; | 38 39#include <sys/param.h> 40#include <sys/capability.h> 41#include <sys/condvar.h> 42#include <sys/file.h> 43#include <sys/kernel.h> 44#include <sys/kthread.h> 45#include <sys/lock.h> --- 404 unchanged lines hidden (view full) --- 450 451static void 452cfiscsi_pdu_handle_nop_out(struct icl_pdu *request) 453{ 454 struct cfiscsi_session *cs; 455 struct iscsi_bhs_nop_out *bhsno; 456 struct iscsi_bhs_nop_in *bhsni; 457 struct icl_pdu *response; |
458 void *data = NULL; 459 size_t datasize; 460 int error; |
|
458 459 cs = PDU_SESSION(request); 460 bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs; 461 462 if (bhsno->bhsno_initiator_task_tag == 0xffffffff) { 463 /* 464 * Nothing to do, iscsi_pdu_update_statsn() already 465 * zeroed the timeout. 466 */ 467 icl_pdu_free(request); 468 return; 469 } 470 | 461 462 cs = PDU_SESSION(request); 463 bhsno = (struct iscsi_bhs_nop_out *)request->ip_bhs; 464 465 if (bhsno->bhsno_initiator_task_tag == 0xffffffff) { 466 /* 467 * Nothing to do, iscsi_pdu_update_statsn() already 468 * zeroed the timeout. 469 */ 470 icl_pdu_free(request); 471 return; 472 } 473 |
474 datasize = icl_pdu_data_segment_length(request); 475 if (datasize > 0) { 476 data = malloc(datasize, M_CFISCSI, M_NOWAIT | M_ZERO); 477 if (data == NULL) { 478 CFISCSI_SESSION_WARN(cs, "failed to allocate memory; " 479 "dropping connection"); 480 icl_pdu_free(request); 481 cfiscsi_session_terminate(cs); 482 return; 483 } 484 icl_pdu_get_data(request, 0, data, datasize); 485 } 486 |
|
471 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 472 if (response == NULL) { | 487 response = cfiscsi_pdu_new_response(request, M_NOWAIT); 488 if (response == NULL) { |
489 CFISCSI_SESSION_WARN(cs, "failed to allocate memory; " 490 "droppping connection"); 491 free(data, M_CFISCSI); |
|
473 icl_pdu_free(request); | 492 icl_pdu_free(request); |
493 cfiscsi_session_terminate(cs); |
|
474 return; 475 } 476 bhsni = (struct iscsi_bhs_nop_in *)response->ip_bhs; 477 bhsni->bhsni_opcode = ISCSI_BHS_OPCODE_NOP_IN; 478 bhsni->bhsni_flags = 0x80; 479 bhsni->bhsni_initiator_task_tag = bhsno->bhsno_initiator_task_tag; 480 bhsni->bhsni_target_transfer_tag = 0xffffffff; | 494 return; 495 } 496 bhsni = (struct iscsi_bhs_nop_in *)response->ip_bhs; 497 bhsni->bhsni_opcode = ISCSI_BHS_OPCODE_NOP_IN; 498 bhsni->bhsni_flags = 0x80; 499 bhsni->bhsni_initiator_task_tag = bhsno->bhsno_initiator_task_tag; 500 bhsni->bhsni_target_transfer_tag = 0xffffffff; |
501 if (datasize > 0) { 502 error = icl_pdu_append_data(response, data, datasize, M_NOWAIT); 503 if (error != 0) { 504 CFISCSI_SESSION_WARN(cs, "failed to allocate memory; " 505 "dropping connection"); 506 free(data, M_CFISCSI); 507 icl_pdu_free(request); 508 icl_pdu_free(response); 509 cfiscsi_session_terminate(cs); 510 return; 511 } 512 free(data, M_CFISCSI); 513 } |
|
481 | 514 |
482#if 0 483 /* XXX */ 484 response->ip_data_len = request->ip_data_len; 485 response->ip_data_mbuf = request->ip_data_mbuf; 486 request->ip_data_len = 0; 487 request->ip_data_mbuf = NULL; 488#endif 489 | |
490 icl_pdu_free(request); 491 cfiscsi_pdu_queue(response); 492} 493 494static void 495cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request) 496{ 497 struct iscsi_bhs_scsi_command *bhssc; --- 2201 unchanged lines hidden --- | 515 icl_pdu_free(request); 516 cfiscsi_pdu_queue(response); 517} 518 519static void 520cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request) 521{ 522 struct iscsi_bhs_scsi_command *bhssc; --- 2201 unchanged lines hidden --- |