fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
49311b3511690f5b23558b0fba067bc8067c7a87Jack Meng * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSNS Client
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* For local use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_RCV_RSP_COUNT 10 /* Maximum number of unmatched xid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* One global queue to serve all LHBA instances. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* One global queue to serve all LHBA instances. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* One globally maintained transaction ID. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * One SCN callback registration per LHBA instance. For now, since we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * support only one instance, we create one place holder for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * One thread, port, local address, and listening socket per LHBA instance.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For now, since we support only one instance, we create one set of place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * holder for these data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t esi_scn_thr_to_shutdown = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This mutex protects all the per LHBA instance variables, i.e.,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China * esi_scn_thr_to_shutdown, esi_scn_thr_id, and instance_listening_so.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iSNS related helpers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Return status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int discover_isns_server(uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int create_esi_scn_thr(uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void esi_scn_thr_cleanup(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_status_t do_isns_dev_attr_reg(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name, uint8_t *node_alias, uint32_t node_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_status_t do_isns_dev_dereg(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make query to all iSNS servers visible to the specified LHBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The query could be made for all target nodes or for a specific target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_status_t do_isns_query(boolean_t is_query_all_nodes_b,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_name, uint8_t *source_node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t source_node_type, isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create DevAttrQuery message requesting portal group information for all
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target nodes. Send it to the specified iSNS server. Parse the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DevAttrQueryRsp PDU and translate the results into a portal group list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_status_t do_isns_dev_attr_query_all_nodes(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_addr_t *isns_server_addr, uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias, isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create DevAttrQuery message requesting portal group information for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified target node. Send it to the specified iSNS server. Parse the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DevAttrQueryRsp PDU and translate the results into a portal group list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_status_t do_isns_dev_attr_query_one_node(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_addr_t *isns_server_addr, uint8_t *target_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_name, uint8_t *source_node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t source_node_type, isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void isns_service_esi_scn(iscsi_thread_t *thread, void* arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void (*scn_callback_lookup(uint8_t *lhba_handle))(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Transport related helpers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *isns_open(iscsi_addr_t *isns_server_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ssize_t isns_send_pdu(void *socket, isns_pdu_t *pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_rcv_pdu(void *so, isns_pdu_t **pdu, size_t *pdu_size);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing Chinastatic boolean_t find_listening_addr(iscsi_addr_t *local_addr,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China void *listening_so);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic boolean_t find_local_portal(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iSNS protocol related helpers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_pdu_header(uint16_t func_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t max_pdu_size, uint32_t attr_id, uint32_t attr_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name, uint8_t *node_alias, uint32_t node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_dev_dereg_pdu(uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_dev_attr_qry_target_nodes_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name, uint8_t *node_alias, uint16_t *xid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_dev_attr_qry_one_pg_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *target_node_name, uint8_t *source_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_esi_rsp_pdu(uint32_t rsp_status_code,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *pdu, uint16_t *xid, isns_pdu_t **out_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_scn_reg_pdu(uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias, uint16_t *xid, isns_pdu_t **out_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_scn_dereg_pdu(uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic size_t isns_create_scn_rsp_pdu(uint32_t rsp_status_code,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *pdu, uint16_t *xid, isns_pdu_t **out_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_dev_attr_reg_rsp(isns_pdu_t *resp_pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_dev_attr_dereg_rsp(isns_pdu_t *resp_pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Process and parse a DevAttrQryRsp message. The routine creates a list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of Portal Group objects if the message is parasable without any issue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the parsing is not successful, the pg_list will be set to NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_dev_attr_qry_target_nodes_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_addr_t *isns_server_addr, uint16_t payload_funcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_scn_reg_rsp(isns_pdu_t *resp_pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_scn_dereg_rsp(isns_pdu_t *resp_pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_esi(isns_pdu_t *esi_pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t isns_process_scn(isns_pdu_t *scn_pdu_p, uint8_t *lhba_handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(®_query_taskq_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_query_taskq = ddi_taskq_create(NULL, "isns_reg_query_taskq",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&scn_taskq_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scn_taskq = ddi_taskq_create(NULL, "isns_scn_taskq",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&esi_scn_thr_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* MISC initializations. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*scn_callback)(void *))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look up the iSNS Server address(es) based on the specified ISID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discover_isns_server(lhba_handle, &isns_server_addr_list) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No iSNS server discovered - no registration needed. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check and create ESI/SCN threads and populate local address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < isns_server_addr_list->al_out_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(isns_server_addr_list->al_addrs[i])) == ISNS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Problem creating ESI/SCN thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free the server list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Register against all iSNS servers discovered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < isns_server_addr_list->al_out_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p = kmem_zalloc(sizeof (isns_reg_arg_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p->isns_server_addr, sizeof (iscsi_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p->node_name = kmem_zalloc(node_name_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(node_name, reg_args_p->node_name, node_name_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p->node_alias = kmem_zalloc(node_alias_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(node_alias, reg_args_p->node_alias, node_alias_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dispatch the registration request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the server list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Register the scn_callback. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*scn_callback)(void *))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap = (iscsi_addr_t *)kmem_zalloc(sizeof (iscsi_addr_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_server->e_insize == sizeof (struct in_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap->a_addr.i_addr.in4.s_addr = (isns_server->e_u.u_in4.s_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (isns_server->e_insize == sizeof (struct in6_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check and create ESI/SCN threads and populate local address */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = create_esi_scn_thr(lhba_handle, ap))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Problem creating ESI/SCN thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(isns_reg_one_server_create_esi_scn_thr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p = kmem_zalloc(sizeof (isns_reg_arg_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(ap, reg_args_p->isns_server_addr, sizeof (iscsi_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p->node_name = kmem_zalloc(node_name_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(node_name, reg_args_p->node_name, node_name_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args_p->node_alias = kmem_zalloc(node_alias_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(node_alias, reg_args_p->node_alias, node_alias_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dispatch the registration request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Register the scn_callback. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look up the iSNS Server address(es) based on the specified ISID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discover_isns_server(lhba_handle, &isns_server_addr_list) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(isns_server_addr_list, isns_svr_lst_sz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < isns_server_addr_list->al_out_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the server list. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Cleanup ESI/SCN thread. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap = (iscsi_addr_t *)kmem_zalloc(sizeof (iscsi_addr_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_server->e_insize == sizeof (struct in_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap->a_addr.i_addr.in4.s_addr = (isns_server->e_u.u_in4.s_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (isns_server->e_insize == sizeof (struct in6_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Clean up ESI/SCN thread resource if it is the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * last known iSNS server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query_one_server(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (do_isns_dev_attr_query_all_nodes(isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query_one_server_one_node(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not supported yet. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use supported iSNS server discovery method to find out all the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSNS servers. For now, only static configuration method is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_isns_addr_next(&void_p, &e) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte list_space += (sizeof (iscsi_addr_t) * (isns_server_count - 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *isns_server_addrs = (iscsi_addr_list_t *)kmem_zalloc(list_space,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*isns_server_addrs)->al_out_cnt = isns_server_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (persistent_isns_addr_next(&void_p, &e) == B_TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ap->a_addr.i_addr.in4.s_addr = (e.e_u.u_in4.s_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (e.e_insize == sizeof (struct in6_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_esi_scn_thr(uint8_t *lhba_handle, iscsi_addr_t *isns_server_address)
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China void *listening_so = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China boolean_t found = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bringing up of the thread should happen regardless of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * subsequent registration status. That means, do not destroy the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ESI/SCN thread already created.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check and create ESI/SCN thread. */
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China /* Determine local port and address. */
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China found = find_local_portal(isns_server_address,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China NULL, &listening_so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (found == B_FALSE) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (listening_so != NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->close(listening_so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China mutex_exit(&esi_scn_thr_mutex);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (ISNS_CANNOT_FIND_LOCAL_ADDR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Assume the LHBA handle has a length of 4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "isns_client_esi_%x%x%x%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte larg = kmem_zalloc(sizeof (isns_async_thread_arg_t), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Deregister stale registration (if any). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = do_isns_dev_dereg(reg_args->isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Cannot open connection to the server. Stop proceeding. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->isns_server_addr, sizeof (iscsi_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->node_name, reg_args->node_name_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->node_alias, reg_args->node_alias_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(register_isns_client_dereg, isns_status_t, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* New registration. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = do_isns_dev_attr_reg(reg_args->isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reg_args->node_name, reg_args->node_alias, reg_args->node_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(register_isns_client_reg, isns_status_t, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Cleanup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->isns_server_addr, sizeof (iscsi_addr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->node_name, reg_args->node_name_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(reg_args->node_alias, reg_args->node_alias_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_isns_dev_attr_reg(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name, uint8_t *node_alias, uint32_t node_type)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t bytes_received, in_pdu_size = 0, out_pdu_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log a message and return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rsp_status = isns_process_dev_attr_reg_rsp(in_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Always register SCN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t bytes_received, in_pdu_size = 0, out_pdu_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log a message and return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rsp_status = isns_process_dev_attr_dereg_rsp(in_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Always deregister SCN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look up the iSNS Server address(es) based on the specified ISID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (discover_isns_server(lhba_handle, &isns_server_addr_list) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(isns_server_addr_list, isns_svr_lst_sz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isns_server_addr_list->al_out_cnt should not be zero by the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * time it comes to this point.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pg_lists_sz = isns_server_addr_list->al_out_cnt *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pg_lists = (isns_portal_group_list_t **)kmem_zalloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < isns_server_addr_list->al_out_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Record the portal group list retrieved from this server. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (combined_qry_stat != isns_op_partially_failed) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Break out of the loop if we already got
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the node information for one node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Merge the retrieved portal lists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pg_lst_sz = sizeof (isns_portal_group_list_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pg_lst_sz += (combined_num_of_pgs - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pg_list = (isns_portal_group_list_t *)kmem_zalloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pg_list->pg_out_cnt = combined_num_of_pgs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < isns_server_addr_list->al_out_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < tmp_pg_lists[i]->pg_out_cnt; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pg_list_sz = sizeof (isns_portal_group_list_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pg_list_sz += (tmp_pg_lists[i]->pg_out_cnt - 1) *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(isns_server_addr_list, isns_svr_lst_sz);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(list, isns_portal_group_list_t *, combined_pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_isns_dev_attr_query_all_nodes(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_mult_payload_t *combined_pdu = NULL, *old_combined_pdu = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t old_combined_pdu_size = 0, combined_pdu_size = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log a message and return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Then, ask for all PG attributes. Filter the non-target nodes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_pdu_size = isns_create_dev_attr_qry_target_nodes_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make sure we are processing the right transaction id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check to see if FIRST and LAST PDU flag is set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if they are both set, then this response only has one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pdu and we can process the pdu
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((flags & ISNS_FLAG_FIRST_PDU) == ISNS_FLAG_FIRST_PDU) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((flags & ISNS_FLAG_LAST_PDU) == ISNS_FLAG_LAST_PDU)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this pdu is part of a multi-pdu response. save off the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the payload of this pdu and continue processing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flags & ISNS_FLAG_FIRST_PDU) == ISNS_FLAG_FIRST_PDU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This is the first pdu, make sure sequence ID is 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "first pdu is not sequence ID 0");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create new pdu and copy in data from old pdu */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pdu_size = ISNSP_MULT_PAYLOAD_HEADER_SIZE +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pdu = (isns_pdu_mult_payload_t *)kmem_zalloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* done with in_pdu, free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Missing sequence ID %d from isns query "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if conbined_pdu_size is still zero, then we never
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processed the first pdu
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Did not receive first pdu.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save off the old combined pdu */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * alloc a new pdu big enough to also hold the new
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pdu payload
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pdu = (isns_pdu_mult_payload_t *)kmem_zalloc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * copy the old pdu into the new allocated pdu buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and append on the new pdu payload that we just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte combined_pdu->payload_len += in_pdu->payload_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free in_pdu and old_combined_pdu */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(old_combined_pdu, old_combined_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check to see if this is the LAST pdu.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if it is, we can process it and move on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise continue to wait for the next pdu
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flags & ISNS_FLAG_LAST_PDU) == ISNS_FLAG_LAST_PDU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_isns_dev_attr_query_one_node(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Obtain the list of target type storage nodes first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte out_pdu_size = isns_create_dev_attr_qry_one_pg_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte target_node_name, source_node_name, &xid, &out_pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Log a message and return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done with the out PDU - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(so, &in_pdu, &in_pdu_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exceed maximum receive count. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rsp_status = isns_process_dev_attr_qry_target_nodes_pdu(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (isns_resp_t *)in_pdu->payload, (size_t)in_pdu->payload_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_server_addr->a_addr.i_insize == sizeof (struct in_addr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sa_rsvr.s_in4.sin_port = htons(isns_server_addr->a_port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create socket */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sa_rsvr.s_in6.sin6_port = htons(isns_server_addr->a_port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create socket */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte so = iscsi_net->socket(AF_INET6, SOCK_STREAM, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (isns_server_addr->a_addr.i_insize == sizeof (struct in_addr)) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct sockaddr_in) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct sockaddr_in6), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flag value 2 indicates both cantsend and cantrecv */
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning (void) iscsi_net->getsockname(so, (struct sockaddr *)&t_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialization of the message header. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_rcv_pdu(void *socket, isns_pdu_t **pdu, size_t *pdu_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t bytes_received, total_bytes_received = 0, payload_len = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Receive the header first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pdu_hdr = (isns_pdu_t *)kmem_zalloc(ISNSP_HEADER_SIZE, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset((char *)&iovec[0], 0, sizeof (iovec_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialization of the message header. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Poll and receive the packets. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = iscsi_net->recvmsg(socket, &msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not yet. Increase poll count and try again. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OK data received. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bytes_received == 0 || bytes_received != ISNSP_HEADER_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(isns_rcv_pdu_probe1, int, payload_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify the received payload len is within limit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Proceed to receive additional data. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_pdu_data = kmem_zalloc(payload_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset((char *)&iovec[0], 0, sizeof (iovec_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialization of the message header. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Poll and receive the rest of the PDU. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = iscsi_net->recvmsg(socket, &msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not yet. Increase poll count and try again. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OK data received. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (bytes_received == 0 || bytes_received != payload_len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*pdu) = (isns_pdu_t *)kmem_zalloc((*pdu_size), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(tmp_pdu_data, &((*pdu)->payload), payload_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isns_create_dev_attr_reg_pdu - isns client registration pdu
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China boolean_t rval = B_FALSE;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_addr_t local_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create DevAttrReg Message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enable the replace bit so that we can update
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * existing registration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_DEV_ATTR_REG, flags, &pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Message Key Attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EID attribute - Section 6.2.1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is required for re-registrations or Replace
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bit is ignored - Section 5.6.5.1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_EID_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* EID attribute - Section 6.2.1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_EID_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ENTITY Protocol - Section 6.2.2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ENTITY_PROTOCOL_ATTR_ID, 4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Name - Section 6.4.1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Alias - Section 6.4.3 Optional */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_ALIAS_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Node Type - Section 6.4.2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NODE_TYPE_ATTR_ID, 4,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (instance_listening_so != NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China rval = find_listening_addr(&local_addr, instance_listening_so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (rval == B_FALSE) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China kmem_free(pdu, pdu_size);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *out_pdu = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China mutex_exit(&esi_scn_thr_mutex);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China kmem_free(pdu, pdu_size);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *out_pdu = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China mutex_exit(&esi_scn_thr_mutex);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_port = local_addr.a_port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Portal IP Address - Section 6.5.2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_PORTAL_IP_ADDR_ATTR_ID, 16,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China &(local_addr.a_addr.i_addr.in4),
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_addr.a_addr.i_insize) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Portal Port - Section 6.5.3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_PORTAL_PORT_ATTR_ID, 4, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SCN Port - Section 6.3.7 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_SCN_PORT_ATTR_ID, 4, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ESI Port - Section 6.3.5 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ESI_PORT_ATTR_ID, 4, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isns_create_dev_dereg_pdu - Create an iSNS PDU for deregistration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create DevDeReg Message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_DEV_DEREG, flags, &pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Entity Identifier */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_EID_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * isns_create_dev_attr_target_nodes_pdu - get all accessible targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Querys for a list of all accessible target nodes for this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initiator. Requests all required login information (name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ip, port, tpgt).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create DevAttrQry Message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_DEV_ATTR_QRY, flags, &pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Message Key Attribute
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Node Type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Query target nodes only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_ISCSI_NODE_TYPE_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DELIMITER_ATTR_ID, 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG iSCSI Name - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal IP Address - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_PORTAL_IP_ADDR_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal Port - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_PORTAL_PORT_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal Group Tag - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_TAG_ATTR_ID, 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t pdu_size, source_node_name_len, target_node_name_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte source_node_name_len = strlen((char *)source_node_name) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte target_node_name_len = strlen((char *)target_node_name) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create DevAttrQry message scoped to target_node_name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_DEV_ATTR_QRY, flags, &pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte source_node_name_len, source_node_name, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Message key attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Node Name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DELIMITER_ATTR_ID, 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG iSCSI Name - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal IP Address - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_PORTAL_IP_ADDR_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal Port - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_PG_PORTAL_PORT_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* PG Portal Group Tag - Zero length TLV */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_TAG_ATTR_ID, 0, 0, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create SCNReg Message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_SCN_REG, flags, &pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Message attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Operating attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_SCN_BITMAP_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Microsoft seems to not differentiate between init and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target. Hence, it makes no difference to turn on/off
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* RFC 4171 section 6.1 - NULLs included in the length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create SCNReg Message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_SCN_DEREG, flags, &pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Source attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Message attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_ISCSI_NAME_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No operating attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t swapped_status_code = htonl(rsp_status_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create ESIRsp Message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_ESI_RSP, flags, &pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Status Code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((esi_pdu->payload_len) < ISNSP_MAX_PAYLOAD_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(esi_pdu->payload, payload_ptr, ISNSP_MAX_PAYLOAD_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t swapped_status_code = htonl(rsp_status_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create SCNRsp Message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_size = isns_create_pdu_header(ISNS_SCN_RSP, flags, &pdu_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Status Code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((scn_pdu->payload_len) < ISNSP_MAX_PAYLOAD_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(scn_pdu->payload, payload_ptr, ISNSP_MAX_PAYLOAD_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Delimiter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_add_attr(pdu_p, pdu_size, ISNS_DELIMITER_ATTR_ID, 0, 0, 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_process_dev_attr_reg_rsp(isns_pdu_t *resp_pdu_p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (resp_pdu_p->func_id != ISNS_DEV_ATTR_REG_RSP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this happens the iSNS server may have a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response's status code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(resp_p->status) != ISNS_RSP_SUCCESSFUL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_process_dev_attr_dereg_rsp(isns_pdu_t *resp_pdu_p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this happens the iSNS server may have a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response's status code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(resp_p->status) != ISNS_RSP_SUCCESSFUL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this happens the iSNS server may have a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response's status code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(resp_p->status) != ISNS_RSP_SUCCESSFUL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_process_scn_dereg_rsp(isns_pdu_t *resp_pdu_p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this happens the iSNS server may have a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check response's status code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(resp_p->status) != ISNS_RSP_SUCCESSFUL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_addr_t *isns_server_addr, uint16_t payload_funcId,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t done_b, found_delimiter_b, target_node_type_b;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this happens the iSNS server may have a problem. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(resp_p->status) != ISNS_RSP_SUCCESSFUL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If payload is smaller than the length of even 1 attribute
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * there is something wrong with the PDU.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Expected DevAttrQryRsp message format:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Status Code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Node Type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG iSCSI Name [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Portal IP Address [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Portal Port [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Tag [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG iSCSI Name [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Portal IP Address [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Portal Port [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PG Tag [Optional]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find out the number of entries retrieved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ntohl(attr_tlv_p->attr_id) == ISNS_DELIMITER_ATTR_ID) {
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China if (ntohl(attr_tlv_p->attr_len) > 0) {
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * Count only those iSCSI node that have a
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * non-NULL PGT value as valid Entity.
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * Per rfc4171 section 3.4 - If the PGT value
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * registered for a specified Portal and iSCSI
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * Node is NULL, or if no PGT value is
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * registered, then the Portal does not provide
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * access to that iSCSI Node in the Entity.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg_sz += (num_of_pgs - 1) * sizeof (isns_portal_group_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DTRACE_PROBE1(isns_process_dev_attr_qry_target_nodes_pdu_pg_size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Once we passed this point, if for any reason we need to return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * because of a failure, we need to free the memory allocated for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the pg_list and nullify it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pg_list = (isns_portal_group_list_t *)kmem_zalloc(pg_sz, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Assign the isns_server information to all portal groups */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&isns_server_addr->a_addr, &pg->isns_server_ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pg = &((*pg_list)->pg_list[(*pg_list)->pg_out_cnt]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Section 6.3.1 - The Portal IP Address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is a 16-byte field that may contain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an IPv4 or IPv6 address. When this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * field contains an IPv4 address, it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is stored as an IPv4-mapped IPv6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STRING_AALR "address attribute length received "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STRING_FISE16 "from iSNS server, Expected = 16, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Received = %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Section 6.3.1 and RFC 2373 state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that an IPv4 address will be denoted
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by the 10 top bytes as all zero
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * followed by either 2 bytes of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0x0000 or 0xFFFF The 0x0000 states
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that the address is is IPv6 capable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and 0xFFFF states its not capable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct in6_addr);
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China if (ntohl(attr_tlv_p->attr_len) > 0) {
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * Only the iSCSI node that has a
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China * non-NULL PGT value is an valid
d3e3772eab14af9b62d61b6d55b6d20457c3075byi zhang - Sun Microsystems - Beijing China (*pg_list)->pg_out_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* There's nothing particular to process for ESI. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_process_scn(isns_pdu_t *scn_pdu_p, uint8_t *lhba_handle)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*scn_callback_to_use)(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the lhba_handle to use for the call back */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scn_callback_to_use = scn_callback_lookup(lhba_handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte src_attr = (uint8_t *)kmem_zalloc(ISCSI_MAX_NAME_LEN, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Section 5.6.5.8 states an SCN can have more than one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * source attribute. Process all attributes until we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * each process all the data or encounter the delimiter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISNS_ISCSI_NAME_ATTR_ID - attribute name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The attribute length must be 4-byte aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Section 5.1.3, RFC 4171.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This SCN is bad. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this was the Destination Attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate new callback structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dispatch the callback to process the SCN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip Destination Attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISNS_ISCSI_SCN_BITMAP_ATTR_ID - change type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Determine the type of action to take for this SCN.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISNS_DELIMITER_ATTR_ID - end of the payload of a message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte total_payload_len += ntohl(attr_tlv_p->attr_len) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((total_payload_len >= scn_pdu_p->payload_len) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No more Attributes to process */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The rest of the data in the PDU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is less than the size of a valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSNS TLV. This next attribute
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * probably spans across the PDU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * boundary. For now, do not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * process it further.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Advance to the next Attribute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_create_pdu_header(uint16_t func_id, uint16_t flags, isns_pdu_t **pdu)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It should be ok to assume ISNSP_MAX_PDU_SIZE is large enough
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * since we are creating our own PDU which is fully under our control.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pdu = (isns_pdu_t *)kmem_zalloc(pdu_size, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*pdu)->version = htons((uint16_t)ISNSP_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*pdu)->flags = htons((uint16_t)(flags | ISNS_FLAG_CLIENT));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The attribute length must be 4-byte aligned. Section 5.1.3. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte normalized_attr_len = (attr_len % 4) == 0 ? (attr_len) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if we are going to exceed the maximum PDU length. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((payload_len + attr_tlv_len) > max_pdu_size) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_tlv = (isns_tlv_t *)kmem_zalloc(attr_tlv_len, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (attr_numeric_data == sizeof (in6_addr_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (attr_numeric_data == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Do nothing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convert the network byte ordered payload length to host byte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ordered for local address calculation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convert the host byte ordered payload length back to network
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * byte ordered - it's now ready to be sent on the wire.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_service_esi_scn(iscsi_thread_t *thread, void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Done using the argument - free it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Blocking call */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Terminate the thread if instructed to do so. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bytes_received = isns_rcv_pdu(connecting_so, &in_pdu,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ignore all traffics other than
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ESI and SCN.
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing Chinafind_listening_addr(iscsi_addr_t *local_addr, void *listening_so)
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China struct sockaddr_in soa4;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China struct sockaddr_in6 soa6;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China } local_conn_prop = { 0 };
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China struct sockaddr_in6 t_addr;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China socklen_t t_addrlen;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr == NULL || listening_so == NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China bzero(&t_addr, sizeof (struct sockaddr_in6));
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China t_addrlen = sizeof (struct sockaddr_in6);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (void) iscsi_net->getsockname(listening_so, (struct sockaddr *)&t_addr,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (t_addrlen > sizeof (local_conn_prop)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China bcopy(&t_addr, &local_conn_prop, t_addrlen);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_conn_prop.soa4.sin_family == AF_INET) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_addr->a_addr.i_addr.in4.s_addr =
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_conn_prop.soa4.sin_addr.s_addr;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_addr->a_addr.i_insize = sizeof (in_addr_t);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China } else if (local_conn_prop.soa4.sin_family == AF_INET6) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China /* Currently, IPv6 is not supported */
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_addr->a_port = ntohs(local_conn_prop.soa4.sin_port);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_TRUE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (listening_so == NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr != NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *local_addr = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *listening_so = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Determine the local IP address.
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr != NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China so = isns_open(isns_server_addr);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (so == NULL) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->getsockname(so,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (struct sockaddr *)&t_addr, &t_addrlen);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (t_addrlen > sizeof (local_conn_prop)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->close(so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China bcopy(&t_addr, &local_conn_prop, t_addrlen);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China t_addrlen = sizeof (struct sockaddr_in6);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_conn_prop.soa4.sin_family == AF_INET) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (iscsi_addr_t *)kmem_zalloc(sizeof (iscsi_addr_t),
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (*local_addr)->a_addr.i_addr.in4.s_addr =
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China local_conn_prop.soa4.sin_addr.s_addr;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (*local_addr)->a_addr.i_insize = sizeof (in_addr_t);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China } else if (local_conn_prop.soa4.sin_family == AF_INET6) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China /* Currently, IPv6 is not supported */
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->close(so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China return (B_FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Determine the local IP address. (End)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use INADDR_ANY to accept connections from any of the connected
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte serv_addr.s_in4.sin_addr.s_addr = htonl(INADDR_ANY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use port number 0 to allow the system to assign a unique unused
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr != NULL && (*local_addr != NULL)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China kmem_free((*local_addr), sizeof (iscsi_addr_t));
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *local_addr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct sockaddr), 0, 0) < 0) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr != NULL && (*local_addr != NULL)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China kmem_free((*local_addr), sizeof (iscsi_addr_t));
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China *local_addr = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (local_addr != NULL && (*local_addr != NULL)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (void) iscsi_net->getsockname(so, (struct sockaddr *)&t_addr,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (t_addrlen <= sizeof (local_conn_prop)) {
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China bcopy(&t_addr, &local_conn_prop, t_addrlen);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (*local_addr)->a_port =
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China ntohs(local_conn_prop.soa4.sin_port);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (*local_addr)->a_port = ISNS_DEFAULT_ESI_SCN_PORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte(*scn_callback_lookup(uint8_t *lhba_handle))(void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When we support multiple HBA instance we will use lhba_handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to look up the associated SCN callback. For now, we only support
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one HBA instance therefore we always return the same SCN callback.
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China boolean_t unblock_esi_scn_thr_b = B_FALSE;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_addr_t local_addr;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China if (esi_scn_thr_to_shutdown == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Instruct the ESI/SCN to shut itself down. */
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (find_listening_addr(&local_addr,
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China instance_listening_so) == B_TRUE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open a connection to the local address and send
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a dummy header to unblock the accept call so that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the ESI/SCN thread has a chance to terminate
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China connecting_so = isns_open(&local_addr);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China esi_scn_thr_to_shutdown = B_FALSE;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China esi_scn_thr_to_shutdown = B_FALSE;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China mutex_exit(&esi_scn_thr_mutex);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China (void) iscsi_thread_stop(esi_scn_thr_id);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_thread_destroy(esi_scn_thr_id);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China mutex_enter(&esi_scn_thr_mutex);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China esi_scn_thr_id = NULL;
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China * Shutdown and close the listening socket.
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->shutdown(instance_listening_so, 2);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China iscsi_net->close(instance_listening_so);
6362598e17a32c2de4dd1a508a5489f200a2397cbing zhao - Sun Microsystems - Beijing China instance_listening_so = NULL;