7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2013 by Delphix. All rights reserved.
27 * Copyright (c) 2017, Joyent, Inc. All rights reserved.
28 */
29
30 #include <sys/conf.h>
31 #include <sys/stat.h>
32 #include <sys/file.h>
33 #include <sys/ddi.h>
34 #include <sys/sunddi.h>
35 #include <sys/modctl.h>
36 #include <sys/priv.h>
37 #include <sys/cpuvar.h>
38 #include <sys/socket.h>
39 #include <sys/strsubr.h>
40 #include <sys/sysmacros.h>
41 #include <sys/sdt.h>
42 #include <netinet/tcp.h>
43 #include <inet/tcp.h>
44 #include <sys/socketvar.h>
45 #include <sys/pathname.h>
46 #include <sys/fs/snode.h>
842 int total_len = 0;
843 int iovlen = 0;
844 struct iovec iov[2];
845 idm_so_conn_t *so_conn;
846 int rc;
847
848 so_conn = ic->ic_transport_private;
849
850 /*
851 * Read BHS
852 */
853 bhs = pdu->isp_hdr;
854 rc = idm_sorecv(so_conn->ic_so, pdu->isp_hdr, sizeof (iscsi_hdr_t));
855 if (rc != IDM_STATUS_SUCCESS) {
856 return (IDM_STATUS_FAIL);
857 }
858
859 /*
860 * Check actual AHS length against the amount available in the buffer
861 */
862 pdu->isp_hdrlen = sizeof (iscsi_hdr_t) +
863 (bhs->hlength * sizeof (uint32_t));
864 pdu->isp_datalen = n2h24(bhs->dlength);
865
866 if (!idm_dataseglenokay(ic, pdu)) {
867 IDM_CONN_LOG(CE_WARN,
868 "idm_sorecvhdr: invalid data segment length");
869 return (IDM_STATUS_FAIL);
870 }
871 if (bhs->hlength > IDM_SORX_CACHE_AHSLEN) {
872 /* Allocate a new header segment and change the callback */
873 new_hdr = kmem_alloc(pdu->isp_hdrlen, KM_SLEEP);
874 bcopy(pdu->isp_hdr, new_hdr, sizeof (iscsi_hdr_t));
875 pdu->isp_hdr = new_hdr;
876 pdu->isp_flags |= IDM_PDU_ADDL_HDR;
877
878 /*
879 * This callback will restore the expected values after
880 * the RX PDU has been processed.
881 */
882 pdu->isp_callback = idm_sorx_addl_pdu_cb;
883 }
884
885 /*
886 * Setup receipt of additional header and header digest (if enabled).
887 */
888 if (bhs->hlength > 0) {
889 iov[iovlen].iov_base = (caddr_t)(pdu->isp_hdr + 1);
890 ahslen = pdu->isp_hdrlen - sizeof (iscsi_hdr_t);
891 iov[iovlen].iov_len = ahslen;
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2013 by Delphix. All rights reserved.
27 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
28 * Copyright (c) 2017, Joyent, Inc. All rights reserved.
29 */
30
31 #include <sys/conf.h>
32 #include <sys/stat.h>
33 #include <sys/file.h>
34 #include <sys/ddi.h>
35 #include <sys/sunddi.h>
36 #include <sys/modctl.h>
37 #include <sys/priv.h>
38 #include <sys/cpuvar.h>
39 #include <sys/socket.h>
40 #include <sys/strsubr.h>
41 #include <sys/sysmacros.h>
42 #include <sys/sdt.h>
43 #include <netinet/tcp.h>
44 #include <inet/tcp.h>
45 #include <sys/socketvar.h>
46 #include <sys/pathname.h>
47 #include <sys/fs/snode.h>
843 int total_len = 0;
844 int iovlen = 0;
845 struct iovec iov[2];
846 idm_so_conn_t *so_conn;
847 int rc;
848
849 so_conn = ic->ic_transport_private;
850
851 /*
852 * Read BHS
853 */
854 bhs = pdu->isp_hdr;
855 rc = idm_sorecv(so_conn->ic_so, pdu->isp_hdr, sizeof (iscsi_hdr_t));
856 if (rc != IDM_STATUS_SUCCESS) {
857 return (IDM_STATUS_FAIL);
858 }
859
860 /*
861 * Check actual AHS length against the amount available in the buffer
862 */
863 if ((IDM_PDU_OPCODE(pdu) != ISCSI_OP_SCSI_CMD) &&
864 (bhs->hlength != 0)) {
865 /* ---- hlength is only only valid for SCSI Request ---- */
866 return (IDM_STATUS_FAIL);
867 }
868 pdu->isp_hdrlen = sizeof (iscsi_hdr_t) +
869 (bhs->hlength * sizeof (uint32_t));
870 pdu->isp_datalen = n2h24(bhs->dlength);
871
872 if (!idm_dataseglenokay(ic, pdu)) {
873 IDM_CONN_LOG(CE_WARN,
874 "idm_sorecvhdr: invalid data segment length");
875 return (IDM_STATUS_FAIL);
876 }
877 if (bhs->hlength > IDM_SORX_WIRE_AHSLEN) {
878 /* Allocate a new header segment and change the callback */
879 new_hdr = kmem_alloc(pdu->isp_hdrlen, KM_SLEEP);
880 bcopy(pdu->isp_hdr, new_hdr, sizeof (iscsi_hdr_t));
881 pdu->isp_hdr = new_hdr;
882 pdu->isp_flags |= IDM_PDU_ADDL_HDR;
883
884 /*
885 * This callback will restore the expected values after
886 * the RX PDU has been processed.
887 */
888 pdu->isp_callback = idm_sorx_addl_pdu_cb;
889 }
890
891 /*
892 * Setup receipt of additional header and header digest (if enabled).
893 */
894 if (bhs->hlength > 0) {
895 iov[iovlen].iov_base = (caddr_t)(pdu->isp_hdr + 1);
896 ahslen = pdu->isp_hdrlen - sizeof (iscsi_hdr_t);
897 iov[iovlen].iov_len = ahslen;
|