Print this page
re #8726 rb4027 Autogenerated iSCSI initiator IQN should use com.nexenta instead of com.sun
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 /*
  26  * ISCSID --
  27  *
  28  * Discovery of targets and access to the persistent storage starts here.
  29  */
  30 
  31 #include <sys/thread.h>
  32 #include <sys/types.h>
  33 #include <sys/proc.h>             /* declares:    p0 */
  34 #include <sys/cmn_err.h>
  35 #include <sys/scsi/adapters/iscsi_if.h>
  36 #include <netinet/in.h>
  37 #include "iscsi_targetparam.h"
  38 #include "isns_client.h"
  39 #include "isns_protocol.h"
  40 #include "persistent.h"
  41 #include "iscsi.h"
  42 #include <sys/ethernet.h>


1959                     pg_list->pg_list[i].isns_server_ip.i_insize,
1960                     &pg_list->pg_list[i].isns_server_ip.i_addr,
1961                     pg_list->pg_list[i].isns_server_port,
1962                     &addr_dsc.sin);
1963                 iscsid_addr_to_sockaddr(
1964                     pg_list->pg_list[i].insize,
1965                     &pg_list->pg_list[i].pg_ip_addr,
1966                     pg_list->pg_list[i].pg_port,
1967                     &addr_tgt.sin);
1968 
1969                 (void) iscsid_add(ihp, iSCSIDiscoveryMethodISNS, &addr_dsc.sin,
1970                     (char *)pg_list->pg_list[i].pg_iscsi_name,
1971                     pg_list->pg_list[i].pg_tag, &addr_tgt.sin);
1972         }
1973 }
1974 
1975 /*
1976  * set_initiator_name - set default initiator name and alias.
1977  *
1978  * This sets the default initiator name and alias.  The
1979  * initiator name is composed of sun's reverse domain name
1980  * and registration followed and a unique classifier.  This
1981  * classifier is the mac address of the first NIC in the
1982  * host and a timestamp to make sure the classifier is
1983  * unique if the NIC is moved between hosts.  The alias
1984  * is just the hostname.
1985  */
1986 void
1987 iscsid_set_default_initiator_node_settings(iscsi_hba_t *ihp, boolean_t minimal)
1988 {
1989         int                 i;
1990         time_t              x;
1991         struct ether_addr   eaddr;
1992         char                val[10];
1993         iscsi_chap_props_t  *chap = NULL;
1994 
1995         /* Set default initiator-node name */
1996         if (iscsiboot_prop && iscsiboot_prop->boot_init.ini_name != NULL) {
1997                 (void) strncpy((char *)ihp->hba_name,
1998                     (const char *)iscsiboot_prop->boot_init.ini_name,
1999                     ISCSI_MAX_NAME_LEN);
2000         } else {
2001                 (void) snprintf((char *)ihp->hba_name,
2002                     ISCSI_MAX_NAME_LEN,
2003                     "iqn.1986-03.com.sun:01:");
2004 
2005                 (void) localetheraddr(NULL, &eaddr);
2006                 for (i = 0; i <  ETHERADDRL; i++) {
2007                         (void) snprintf(val, sizeof (val), "%02x",
2008                             eaddr.ether_addr_octet[i]);
2009                         (void) strncat((char *)ihp->hba_name, val,
2010                             ISCSI_MAX_NAME_LEN);
2011                 }
2012 
2013                 /* Set default initiator-node alias */
2014                 x = ddi_get_time();
2015                 (void) snprintf(val, sizeof (val), ".%lx", x);
2016                 (void) strncat((char *)ihp->hba_name, val, ISCSI_MAX_NAME_LEN);
2017 
2018                 if (ihp->hba_alias[0] == '\0') {
2019                         (void) strncpy((char *)ihp->hba_alias,
2020                             utsname.nodename, ISCSI_MAX_NAME_LEN);
2021                         ihp->hba_alias_length = strlen((char *)ihp->hba_alias);
2022                         if (minimal == B_FALSE) {
2023                                 (void) persistent_alias_name_set(


   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   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 /*
  23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  25  */
  26 
  27 /*
  28  * ISCSID --
  29  *
  30  * Discovery of targets and access to the persistent storage starts here.
  31  */
  32 
  33 #include <sys/thread.h>
  34 #include <sys/types.h>
  35 #include <sys/proc.h>             /* declares:    p0 */
  36 #include <sys/cmn_err.h>
  37 #include <sys/scsi/adapters/iscsi_if.h>
  38 #include <netinet/in.h>
  39 #include "iscsi_targetparam.h"
  40 #include "isns_client.h"
  41 #include "isns_protocol.h"
  42 #include "persistent.h"
  43 #include "iscsi.h"
  44 #include <sys/ethernet.h>


1961                     pg_list->pg_list[i].isns_server_ip.i_insize,
1962                     &pg_list->pg_list[i].isns_server_ip.i_addr,
1963                     pg_list->pg_list[i].isns_server_port,
1964                     &addr_dsc.sin);
1965                 iscsid_addr_to_sockaddr(
1966                     pg_list->pg_list[i].insize,
1967                     &pg_list->pg_list[i].pg_ip_addr,
1968                     pg_list->pg_list[i].pg_port,
1969                     &addr_tgt.sin);
1970 
1971                 (void) iscsid_add(ihp, iSCSIDiscoveryMethodISNS, &addr_dsc.sin,
1972                     (char *)pg_list->pg_list[i].pg_iscsi_name,
1973                     pg_list->pg_list[i].pg_tag, &addr_tgt.sin);
1974         }
1975 }
1976 
1977 /*
1978  * set_initiator_name - set default initiator name and alias.
1979  *
1980  * This sets the default initiator name and alias.  The
1981  * initiator name is composed of vendor's reverse domain name
1982  * and registration date followed by a unique classifier.
1983  * This classifier is the mac address of the first NIC in the
1984  * host and a timestamp to make sure the classifier is
1985  * unique if the NIC is moved between hosts.  The alias
1986  * is just the hostname.
1987  */
1988 void
1989 iscsid_set_default_initiator_node_settings(iscsi_hba_t *ihp, boolean_t minimal)
1990 {
1991         int                 i;
1992         time_t              x;
1993         struct ether_addr   eaddr;
1994         char                val[10];
1995         iscsi_chap_props_t  *chap = NULL;
1996 
1997         /* Set default initiator-node name */
1998         if (iscsiboot_prop && iscsiboot_prop->boot_init.ini_name != NULL) {
1999                 (void) strncpy((char *)ihp->hba_name,
2000                     (const char *)iscsiboot_prop->boot_init.ini_name,
2001                     ISCSI_MAX_NAME_LEN);
2002         } else {
2003                 (void) snprintf((char *)ihp->hba_name, ISCSI_MAX_NAME_LEN,
2004                     "iqn.2005-07.com.nexenta:01:");

2005 
2006                 (void) localetheraddr(NULL, &eaddr);
2007                 for (i = 0; i <  ETHERADDRL; i++) {
2008                         (void) snprintf(val, sizeof (val), "%02x",
2009                             eaddr.ether_addr_octet[i]);
2010                         (void) strncat((char *)ihp->hba_name, val,
2011                             ISCSI_MAX_NAME_LEN);
2012                 }
2013 
2014                 /* Set default initiator-node alias */
2015                 x = ddi_get_time();
2016                 (void) snprintf(val, sizeof (val), ".%lx", x);
2017                 (void) strncat((char *)ihp->hba_name, val, ISCSI_MAX_NAME_LEN);
2018 
2019                 if (ihp->hba_alias[0] == '\0') {
2020                         (void) strncpy((char *)ihp->hba_alias,
2021                             utsname.nodename, ISCSI_MAX_NAME_LEN);
2022                         ihp->hba_alias_length = strlen((char *)ihp->hba_alias);
2023                         if (minimal == B_FALSE) {
2024                                 (void) persistent_alias_name_set(