/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "iscsi.h"
#include "nvfile.h"
#include "persistent.h"
/*
* MAX_KEY_SIZE needs to be the same size of the ISCSI_MAX_NAME_LEN
* plus space for a ',' and a string form of tpgt (5 bytes).
*/
/*
* Name identifiers for the various types of data
*/
/*
* Local Global Variables
*/
/*
* Local Function Prototypes
*/
static void persistent_static_addr_upgrade_to_v2();
/*
* persistent_init_disc_addr_oids - Oid is stored with discovery address
* however oids are not persisted and the discovery address oids need to
* be regenerated during initialization.
*/
static void persistent_init_disc_addr_oids()
{
entry_t e;
/*
* Using two loops here as as addresses are updated and readded we get
* into an infinite loop while doing persistent_disc_addr_next if we
* update the entry as we go. The first loop will get the number of
* addresses that need to be updated and the second will update that
* many addresses.
*/
addr_count++;
}
for (i = 0; i < addr_count; i++) {
curr_count = 0;
/* Use curr_count to skip previously updated addresses */
while (persistent_disc_addr_next(&void_p, &e) ==
B_TRUE && i < curr_count) {
curr_count++;
}
if (persistent_disc_addr_set(&e) == B_FALSE) {
break;
}
}
}
/*
* persistent_init_static_addr_oids - Oid is stored with static address
* however oids are not persisted and the static address oids need to
* be regenerated during initialization.
*/
static void persistent_init_static_addr_oids()
{
entry_t e;
char *target_name;
/*
* Solaris 10 Update 1/2 initially had a database
* that didn't support the multiple static-config
* entries to the same target. The below call
* will check if the database is still of that
* old structure and upgrade it. It will leave
* the old records incase a down grade of the
* software is required.
*/
/*
* Using two loops here as as addresses are updated and readded we get
* into an infinite loop while doing persistent_disc_addr_next if we
* update the entry as we go. The first loop will get the number of
* addresses that need to be updated and the second will update that
* many addresses.
*/
B_TRUE) {
addr_count++;
}
for (i = 0; i < addr_count; i++) {
curr_count = 0;
/* Use curr_count to skip previously updated addresses */
while ((persistent_static_addr_next(
(i < curr_count)) {
curr_count++;
}
/* Skip the target whose address size length is 0 */
if (e.e_insize == 0) {
continue;
}
break;
}
}
}
/*
* persistent_static_addr_upgrade_to_v2 - checks to see if the
* STATIC_ADDR2_ID exists in the persistent store tree. If not
* found then it converts the STATIC_ADDR_ID data into the
* STATIC_ADDR2_ID format and saves the branch.
*/
static void
{
entry_t e;
char *target_name;
char *c_end;
/*
* Check is version 2 of STATIC_ADDR list exists.
*/
/*
* We need to upgrade any existing
* STATIC_ADDR data to version 2. Loop
* thru all old entries and set new version
* values.
*/
target_name, (void *)&e, sizeof (e)) == B_TRUE) {
/* Convert STATIC_ADDR to STATIC_ADDR2 */
continue;
}
*c_end = '\0';
/* Skip the target whose address size length is 0 */
if (e.e_insize == 0) {
continue;
}
/* Add updated record */
(void) persistent_static_addr_set(target_name, &e);
}
}
}
/*
* persistent_init -- initialize use of the persistent store
*/
void
{
nvf_init();
}
/*
* persistent_load -- load the persistent store
*/
{
}
return (rval);
}
/*
* persistent_fini -- finish using the persistent store
*/
void
persistent_fini(void)
{
nvf_fini();
}
/*
* +--------------------------------------------------------------------+
* | Discovery Method Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_disc_meth_set -- enable a specific discovery method
*/
{
}
/*
* persistent_disc_meth_get -- return the status of all discovery methods as
* found in the persistent store
*/
persistent_disc_meth_get(void)
{
}
return (methods);
}
/*
* persistent_disc_meth_clear -- disable a specific discovery method
*/
{
}
/*
* persistent_disc_meth_common - common function used to set or clear the
* status of a discovery method in the persistent store.
*/
static boolean_t
{
(uint32_t *)&discovery_types);
if (do_clear) {
discovery_types &= ~method;
} else {
}
return (rval);
}
/*
* +--------------------------------------------------------------------+
* +--------------------------------------------------------------------+
*/
/*
* persistent_initiator_name_set -- sets the node's initiator name
*/
persistent_initiator_name_set(char *p)
{
return (nvf_node_name_set(NODE_NAME_ID, p));
}
/*
* persistent_initiator_name_get -- returns the node's initiator name
*/
{
}
/*
* +--------------------------------------------------------------------+
* +--------------------------------------------------------------------+
*/
/*
* persistent_alias_name_set -- sets the node's initiator name alias
*/
persistent_alias_name_set(char *p)
{
return (nvf_node_name_set(NODE_ALIAS_ID, p));
}
/*
* persistent_initiator_name_get -- returns the node's initiator name alias
*/
{
}
/*
* +--------------------------------------------------------------------+
* | Static Target Address Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_static_addr_set -- store hostname, IP address, and port
* information for a specific target.
*/
{
char *key;
char *ip_str;
} else {
}
return (B_FALSE);
}
sizeof (entry_t));
return (rval);
}
/*
* persistent_static_addr_next -- get the next target's hostname, IP address,
* and port information.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first static target element.
*
* This function assumes the associated static address lock is held.
*
* Returns B_TRUE when data is valid. B_FALSE returned when data is
* not available (end of configured targets has been reached).
*
*/
{
(void *)e, sizeof (*e));
/* extract target_name */
return (B_FALSE);
}
*c_end = '\0';
/* copy target name */
return (rval);
}
/*
* persistent_static_addr_clear -- remove the next hostname, IP address, and
* port information for a specific target from the configured static targets.
*/
{
entry_t e;
char *key;
char *target_name;
char *ip_str;
/* Find the entry based on oid then record the name and tpgt */
while (persistent_static_addr_next(
break;
}
}
/* If we found a match clear the entry */
} else {
}
return (B_FALSE);
}
}
return (rval);
}
/*
* persistent_static_addr_lock -- lock access to static targets. This
* ensures static targets are unchanged while the lock is held. The
* lock should be grabbed while walking through the static targets.
*/
void
{
}
/*
* persistent_static_addr_unlock -- unlock access to the configured of static
* targets.
*/
void
{
}
/*
* +--------------------------------------------------------------------+
* | ISNS Server Address Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_addr_set -- store entry address information
*/
{
/*
* Create name from given discovery address - SendTargets discovery
* nodes do not have an associated node name. A name is manufactured
* from the IP address given.
*/
} else {
}
(void *)e, sizeof (entry_t));
return (rval);
}
/*
* persistent_disc_addr_next -- get the next iSCSI discovery node's address
* and port information.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first discovery address element.
*
* This function assumes the associated disccovery address lock is held.
*
* Returns B_TRUE when data is valid. B_FALSE returned when data is
* not available (end of configured discovery addresses has been reached).
*
*/
{
(void *)e, sizeof (*e)));
}
/*
* persistent_disc_addr_clear -- remove IP address and port information from
* the configured SendTargets discovery nodes.
*/
{
/*
* Create name from given discovery address - SendTargets discovery
* nodes do not have an associated node name. A name is manufactured
* from the IP address given.
*/
} else {
}
return (rval);
}
/*
* persistent_disc_addr_lock -- lock access to the SendTargets discovery
* addresses. This ensures discovery addresses are unchanged while the lock
* is held. The lock should be grabbed while walking through the discovery
* addresses
*/
void
{
}
/*
* persistent_disc_addr_unlock -- unlock access to discovery addresses.
*/
void
{
}
/*
* +--------------------------------------------------------------------+
* | Discovery Address Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_disc_addr_set -- store IP address, and port information for
* for an iSCSI discovery node that provides target information via a
* SendTargets response.
*/
{
/*
* Create name from given discovery address - SendTargets discovery
* nodes do not have an associated node name. A name is manufactured
* from the IP address given.
*/
} else {
}
(void *)e, sizeof (entry_t));
return (rval);
}
/*
* persistent_disc_addr_next -- get the next iSCSI discovery node's address
* and port information.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first discovery address element.
*
* This function assumes the associated disccovery address lock is held.
*
* Returns B_TRUE when data is valid. B_FALSE returned when data is
* not available (end of configured discovery addresses has been reached).
*
*/
{
(void *)e, sizeof (*e)));
}
/*
* persistent_disc_addr_clear -- remove IP address and port information from
* the configured SendTargets discovery nodes.
*/
{
/*
* Create name from given discovery address - SendTargets discovery
* nodes do not have an associated node name. A name is manufactured
* from the IP address given.
*/
} else {
}
return (rval);
}
/*
* persistent_disc_addr_lock -- lock access to the SendTargets discovery
* addresses. This ensures discovery addresses are unchanged while the lock
* is held. The lock should be grabbed while walking through the discovery
* addresses
*/
void
{
}
/*
* persistent_disc_addr_unlock -- unlock access to discovery addresses.
*/
void
{
}
/*
* +--------------------------------------------------------------------+
* | Login Parameter Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_param_set -- store login parameters for a specific target
*/
{
(void *)param, sizeof (persistent_param_t));
return (rval);
}
/*
* persistent_param_get -- obtain login parameters for a specific target
*/
{
}
/*
* persistent_param_next -- get the next target's login parameters.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first target's login parameters.
*
* This function assumes the associated login parameter lock is held.
*
* Returns B_TRUE when data in *param is valid. B_FALSE returned when no
* more data is available (end of configured target login parameters).
*/
{
}
/*
* persistent_param_clear -- remove login parameters for a specific target
*/
{
}
/*
* persistent_param_lock -- lock access to login parameters. This
* ensures the login parameters will be unchanged while the lock is held.
* The lock should be grabbed while walking through the login parameters.
*/
void
persistent_param_lock(void)
{
}
/*
* persistent_param_unlock -- unlock access to login parameters.
*/
void
persistent_param_unlock(void)
{
}
/*
* +--------------------------------------------------------------------+
* | Session Config Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_set_config_session -- store configured sessions
* for a specific target
*/
{
int size;
/*
* Make ics_out match ics_in. Since when someone gets
* this information the in value becomes the out.
*/
/* calculate size */
return (rval);
}
/*
* persistent_get_config_session -- obtain configured sessions
* for a specific target
*/
{
int in;
int size;
/* record caller buffer size */
/* Get base config_sess information */
/* reset the in size */
return (status);
}
/*
* persistent_get_tunable_param -- obtain tunable parameters
* for a specific target
*/
{
(void *)tpsg, sizeof (persistent_tunable_param_t)));
}
/*
* persistent_set_tunable_param -- store tunable parameters
* for a specific target
*/
{
(void *)tpss, sizeof (persistent_tunable_param_t));
return (rval);
}
/*
* +--------------------------------------------------------------------+
* | CHAP Parameter Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_chap_set -- store CHAP parameters for a specific target
*/
{
(void *)chap, sizeof (iscsi_chap_props_t));
return (rval);
}
/*
* persistent_chap_get -- obtain CHAP parameters for a specific target
*/
{
}
/*
* persistent_chap_next -- copy the next target's chap parameters.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first target's login parameters.
*
* This function assumes the associated chap parameter lock is held.
*
* Returns B_TRUE when data in *param is valid. B_FALSE returned when no
* more data is available.
*/
{
}
/*
* persistent_chap_clear -- remove CHAP parameters for a specific target
*/
{
return (rval);
}
/*
* persistent_chap_lock -- lock access to chap parameters. This
* ensures the chap parameters will be unchanged while the lock is held.
* The lock should be grabbed while walking through the chap parameters.
*/
void
persistent_chap_lock(void)
{
}
/*
* persistent_chap_unlock -- unlock access to chap parameters.
*/
void
persistent_chap_unlock(void)
{
}
/*
* +--------------------------------------------------------------------+
* | RADIUS Configuration Interfaces |
* +--------------------------------------------------------------------+
*/
/*
* persistent_radius_set -- stores the RADIUS configuration info
*/
{
sizeof (iscsi_radius_props_t)));
}
/*
* persistent_radius_get -- obtain the RADIUS configuration info
*/
{
return (nvf_node_data_get(RADIUS_PARAMS_ID,
}
/*
* +--------------------------------------------------------------------+
* | Authentication Configuration Interface |
* +--------------------------------------------------------------------+
*/
/*
* persistent_auth_set -- stores the bidirectional authentication settings
* for a specific target
*/
{
(void *)auth, sizeof (iscsi_auth_props_t));
return (rval);
}
/*
* persistent_auth_get -- gets the bidirectional authentication settings
* for a specific target
*/
{
}
/*
* persistent_auth_next -- get the next target's bidirectional authentication
* parameters.
*
* The first time this function is called, the argument (void **v)
* should be a pointer to a value of NULL which causes this function to obtain
* the first target's login parameters.
*
* This function assumes the associated bidirectional authentication lock is
* held.
*
* Returns B_TRUE when data in *param is valid. B_FALSE returned when no
* more data is available.
*/
{
}
/*
* persistent_auth_clear -- remove bidirectional authentication parameters for
* a specific target
*/
{
return (rval);
}
/*
* persistent_auth_lock -- lock access to bidirectional authentication
* parameters. This ensures the authentication parameters will be unchanged
* while the lock is held. The lock should be grabbed while walking through
* the authentication parameters.
*/
void
persistent_auth_lock(void)
{
}
/*
* persistent_auth_unlock -- unlock access to bidirectional authentication
* parameters.
*/
void
persistent_auth_unlock(void)
{
}
/*
* +--------------------------------------------------------------------+
* | Debug Functions |
* +--------------------------------------------------------------------+
*/
/*
* persistent_dump_data -- dump contents of persistent store
*/
void
persistent_dump_data(void)
{
char *name;
char *bitbuf;
void *v;
char *addr_buf;
char *param_name;
}
}
if (methods != iSCSIDiscoveryMethodUnknown) {
"\003SendTarget\002iSNS\001SLP\000Static",
bitbuf, BITBUF_LEN));
}
KM_SLEEP);
} else {
}
}
v = NULL;
" <------ Static Target Discovery Addresses ------>\n");
} else {
}
}
v = NULL;
" <------ SendTargets Discovery Addresses ------>\n");
} else {
}
}
v = NULL;
" <------ ISNS Server Discovery Addresses ------>\n");
} else {
}
}
v = NULL;
"\015DDIG\014HDIG\013SEGLEN\012OUT_R2T\011"
"DATAPDU\010MAXCONN\007BURST\006R2T\005"
"IMMDATA\004FIRSTBURST\003LEVEL\002T2WAIT"
param_id++) {
if (param_name == NULL) {
param_name = "Param_Not_Found";
}
switch (param_id) {
data_sequence_in_order == B_TRUE) ?
"True" : "False");
break;
initial_r2t == B_TRUE) ?
"True" : "False");
break;
data_pdu_in_order == B_TRUE) ?
"True" : "False");
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
default:
break;
}
}
}
}
v = NULL;
}
v = NULL;
}
}