libiscsit.c revision bf604c6405d5cbc4e94e3d0ecc9e6e074ed4ea67
843e19887f64dde75055cf8842fc4db2171eff45johnlev * CDDL HEADER START
843e19887f64dde75055cf8842fc4db2171eff45johnlev * The contents of this file are subject to the terms of the
843e19887f64dde75055cf8842fc4db2171eff45johnlev * Common Development and Distribution License (the "License").
843e19887f64dde75055cf8842fc4db2171eff45johnlev * You may not use this file except in compliance with the License.
843e19887f64dde75055cf8842fc4db2171eff45johnlev * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
843e19887f64dde75055cf8842fc4db2171eff45johnlev * See the License for the specific language governing permissions
843e19887f64dde75055cf8842fc4db2171eff45johnlev * and limitations under the License.
843e19887f64dde75055cf8842fc4db2171eff45johnlev * When distributing Covered Code, include this CDDL HEADER in each
843e19887f64dde75055cf8842fc4db2171eff45johnlev * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
843e19887f64dde75055cf8842fc4db2171eff45johnlev * If applicable, add the following below this CDDL HEADER, with the
843e19887f64dde75055cf8842fc4db2171eff45johnlev * fields enclosed by brackets "[]" replaced with your own identifying
843e19887f64dde75055cf8842fc4db2171eff45johnlev * information: Portions Copyright [yyyy] [name of copyright owner]
843e19887f64dde75055cf8842fc4db2171eff45johnlev * CDDL HEADER END
327151705b7439cb7ab35c370f682cac7ef9523aCathy Zhou * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
843e19887f64dde75055cf8842fc4db2171eff45johnlev * Use is subject to license terms.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz/* From iscsitgtd */
843e19887f64dde75055cf8842fc4db2171eff45johnlev/* this should be defined someplace central... */
843e19887f64dde75055cf8842fc4db2171eff45johnlev/* max length of a base64 encoded secret */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* Default RADIUS server port */
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * The kernel reserves target portal group tag value 1 as the default.
843e19887f64dde75055cf8842fc4db2171eff45johnlev/* helper for property list validation */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* helper function declarations */
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhouit_iqn_generate(char *iqn_buf, int iqn_buf_len, char *opt_iqn_suffix);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng/* consider making validate funcs public */
da14cebe459d3275048785f25bd869cb09b5307fEric Chengit_validate_configprops(nvlist_t *nvl, nvlist_t *errs);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengit_validate_tgtprops(nvlist_t *nvl, nvlist_t *errs);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengit_validate_iniprops(nvlist_t *nvl, nvlist_t *errs);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Function: it_config_load()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Allocate and create an it_config_t structure representing the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * current iSCSI configuration. This structure is compiled using
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * the 'provider' data returned by stmfGetProviderData(). If there
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * is no provider data associated with iscsit, the it_config_t
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * structure will be set to a default configuration.
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Parameters:
a776d98e5f349dbb7f5a47eca48f50e6117adcb7Robert Mustacchi * cfg A C representation of the current iSCSI configuration
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Return Values:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ENOMEM Could not allocate resources
843e19887f64dde75055cf8842fc4db2171eff45johnlev * EINVAL Invalid parameter
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ret = stmfGetProviderDataProt(ISCSIT_MODNAME, &cfg_nv,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * If not initialized yet, return empty it_config_t
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Else, convert nvlist to struct
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Function: it_config_commit()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Informs the iscsit service that the configuration has changed and
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * commits the new configuration to persistent store by calling
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * stmfSetProviderData. This function can be called multiple times
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * during a configuration sequence if necessary.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * cfg A C representation of the current iSCSI configuration
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Return Values:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ENOMEM Could not allocate resources
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * EINVAL Invalid it_config_t structure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * TBD ioctl() failed
eae72b5b807baa9116e64502cbb278edf15f3146Sebastien Roy * TBD could not save config to STMF
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret == 0) {
843e19887f64dde75055cf8842fc4db2171eff45johnlev * Send the changes to the kernel first, for now. Kernel
843e19887f64dde75055cf8842fc4db2171eff45johnlev * will be the final sanity check before config is saved
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * persistently.
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * XXX - this leaves open the simultaneous-change hole
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * that STMF was trying to solve, but is a better sanity
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * check. Final decision on save order/config generation
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * number TBD.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if ((ioctl(iscsit_fd, ISCSIT_IOC_SET_CONFIG, &iop)) != 0) {
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy * Before saving the config persistently, remove any
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy * PROP_OLD_TARGET_NAME entries. This is only interesting to
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy * the active service.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * stmfGetProviderDataProt() checks to ensure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * that the config data hasn't changed since we fetched it.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * The kernel now has a version we need to save persistently.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * CLI will 'do the right thing' and warn the user if it
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * gets STMF_ERROR_PROV_DATA_STALE. We'll try once to revert
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * the kernel to the persistently saved data, but ultimately,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * it's up to the administrator to validate things are as they
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * want them to be.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ret = stmfSetProviderDataProt(ISCSIT_MODNAME, cfgnv,
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou if (st == 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Function: it_config_setprop()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Validate the provided property list and set the global properties
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * for iSCSI Target. If errlist is not NULL, returns detailed
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * errors for each property that failed. The format for errorlist
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * is key = property, value = error string.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * cfg The current iSCSI configuration obtained from
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * it_config_load()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * proplist nvlist_t containing properties for this target.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * errlist (optional) nvlist_t of errors encountered when
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * validating the properties.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Return Values:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * EINVAL Invalid property
da14cebe459d3275048785f25bd869cb09b5307fEric Chengit_config_setprop(it_config_t *cfg, nvlist_t *proplist, nvlist_t **errlist)
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * copy the existing properties, merge, then validate
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * the merged properties before committing them.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ret = nvlist_dup(cfg->config_global_properties, &cprops, 0);
843e19887f64dde75055cf8842fc4db2171eff45johnlev /* base64 encode the radius secret, if it's changed */
843e19887f64dde75055cf8842fc4db2171eff45johnlev (void) nvlist_lookup_string(proplist, PROP_RADIUS_SECRET, &val);
843e19887f64dde75055cf8842fc4db2171eff45johnlev ret = it_val_pass(PROP_RADIUS_SECRET, val, *errlist);
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret == 0) {
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret == 0) {
843e19887f64dde75055cf8842fc4db2171eff45johnlev /* replace the value in the nvlist */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* see if we need to remove the radius server setting */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) nvlist_lookup_string(cprops, PROP_RADIUS_SERVER, &val);
843e19887f64dde75055cf8842fc4db2171eff45johnlev /* and/or remove the alias */
843e19887f64dde75055cf8842fc4db2171eff45johnlev (void) nvlist_lookup_string(cprops, PROP_ALIAS, &val);
d62bc4badc1c1f1549c961cfb8b420e650e1272byz if (ret == 0) {
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret != 0) {
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Update iSNS server list, if exists in provided property list.
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou ret = nvlist_lookup_string_array(proplist, PROP_ISNS_SERVER,
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou /* special case: if "none", remove all defined */
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou ISNS_DEFAULT_SERVER_PORT, &newisnslist, &newcount);
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou (void) nvlist_remove_all(cprops, PROP_ISNS_SERVER);
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Replace the array in the nvlist to ensure
843e19887f64dde75055cf8842fc4db2171eff45johnlev * duplicates are properly removed & port numbers
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * are added.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng for (i = 0; i < newcount; i++) {
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou /* not an error */
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou /* replace the global properties list */
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Function: it_config_free()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Free any resources associated with the it_config_t structure.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * cfg A C representation of the current iSCSI configuration
843e19887f64dde75055cf8842fc4db2171eff45johnlev * Function: it_tgt_create()
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Allocate and create an it_tgt_t structure representing a new iSCSI
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * target node. If tgt_name is NULL, then a unique target node name will
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * be generated automatically. Otherwise, the value of tgt_name will be
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * used as the target node name. The new it_tgt_t structure is added to
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * the target list (cfg_tgt_list) in the configuration structure, and the
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * new target will not be instantiated until the modified configuration
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * is committed by calling it_config_commit().
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Parameters:
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * cfg The current iSCSI configuration obtained from
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * it_config_load()
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * tgt Pointer to an iSCSI target structure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tgt_name The target node name for the target to be created.
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * The name must be in either IQN or EUI format. If
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * this value is NULL, a node name will be generated
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * automatically in IQN format.
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * Return Values:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * ENOMEM Could not allocated resources
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * EINVAL Invalid parameter
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * EFAULT Invalid iSCSI name specified
d62bc4badc1c1f1549c961cfb8b420e650e1272byzit_tgt_create(it_config_t *cfg, it_tgt_t **tgt, char *tgt_name)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* generate a name */
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret != 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* validate the passed-in name */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* make sure this name isn't already on the list */
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou (void) strlcpy(ptr->tgt_name, namep, sizeof (ptr->tgt_name));
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * Function: it_tgt_setprop()
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Validate the provided property list and set the properties for
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavai * the specified target. If errlist is not NULL, returns detailed
843e19887f64dde75055cf8842fc4db2171eff45johnlev * errors for each property that failed. The format for errorlist
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * is key = property, value = error string.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * cfg The current iSCSI configuration obtained from
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * it_config_load()
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * tgt Pointer to an iSCSI target structure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * proplist nvlist_t containing properties for this target.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * errlist (optional) nvlist_t of errors encountered when
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * validating the properties.
843e19887f64dde75055cf8842fc4db2171eff45johnlev * Return Values:
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * 0 Success
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * EINVAL Invalid property
4eaa471005973e11a6110b69fe990530b3b95a38Rishi Srivatsavaiit_tgt_setprop(it_config_t *cfg, it_tgt_t *tgt, nvlist_t *proplist,
843e19887f64dde75055cf8842fc4db2171eff45johnlev * copy the existing properties, merge, then validate
843e19887f64dde75055cf8842fc4db2171eff45johnlev * the merged properties before committing them.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ret = nvlist_dup(tgt->tgt_properties, &tprops, 0);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* unset chap username or alias if requested */
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey (void) nvlist_lookup_string(proplist, PROP_TARGET_CHAP_USER, &val);
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey if (val && (strcasecmp(val, "none") == 0)) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) nvlist_remove_all(tprops, PROP_TARGET_CHAP_USER);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) nvlist_lookup_string(proplist, PROP_ALIAS, &val);
843e19887f64dde75055cf8842fc4db2171eff45johnlev /* base64 encode the CHAP secret, if it's changed */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) nvlist_lookup_string(proplist, PROP_TARGET_CHAP_SECRET, &val);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng ret = it_val_pass(PROP_TARGET_CHAP_SECRET, val, *errlist);
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy /* replace the value in the nvlist */
843e19887f64dde75055cf8842fc4db2171eff45johnlev if (ret != 0) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Function: it_tgt_delete()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Delete target represented by 'tgt', where 'tgt' is an existing
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * it_tgt_structure within the configuration 'cfg'. The target removal
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * will not take effect until the modified configuration is committed
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * by calling it_config_commit().
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * cfg The current iSCSI configuration obtained from
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * it_config_load()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tgt Pointer to an iSCSI target structure
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * force Set the target to offline before removing it from
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * the config. If not specified, the operation will
327151705b7439cb7ab35c370f682cac7ef9523aCathy Zhou * fail if the target is determined to be online.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Return Values:
2b24ab6b3865caeede9eeb9db6b83e1d89dcd1eaSebastien Roy * EBUSY Target is online
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskeyit_tgt_delete(it_config_t *cfg, it_tgt_t *tgt, boolean_t force)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (strcmp(tgt->tgt_name, ptgt->tgt_name) == 0) {
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * check to see if this target is offline. If it is not,
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * and the 'force' flag is TRUE, tell STMF to offline it
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou * before removing from the configuration.
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou ret = stmfDevidFromIscsiName(ptgt->tgt_name, &devid);
1cb875ae88fb9463b368e725c2444776595895cbCathy Zhou /* can't happen? */
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey ret = stmfGetTargetProperties(&devid, &props);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * only other return is STMF_ERROR_NOT_FOUND, which
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * means we don't have to offline it.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng /* first one on the list */
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey ptgt->tgt_next = NULL; /* Only free this target */
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Function: it_tgt_free()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Frees an it_tgt_t structure. If tgt_next is not NULL, frees
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * all structures in the list.
d62bc4badc1c1f1549c961cfb8b420e650e1272byz * Function: it_tpgt_create()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Allocate and create an it_tpgt_t structure representing a new iSCSI
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * target portal group tag. The new it_tpgt_t structure is added to the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * target tpgt list (tgt_tpgt_list) in the it_tgt_t structure. The new
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * target portal group tag will not be instantiated until the modified
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * configuration is committed by calling it_config_commit().
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Parameters:
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * cfg The current iSCSI configuration obtained from
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * it_config_load()
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tgt Pointer to the iSCSI target structure associated
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * with the target portal group tag
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tpgt Pointer to a target portal group tag structure
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tpg_name The name of the TPG to be associated with this TPGT
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tpgt_tag 16-bit numerical identifier for this TPGT. If
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tpgt_tag is '0', this function will choose the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * tag number. If tpgt_tag is >0, and the requested
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * tag is determined to be in use, another value
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * will be chosen.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Return Values:
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * ENOMEM Could not allocate resources
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * EINVAL Invalid parameter
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * EEXIST Specified tag name is already used.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * E2BIG No available tag numbers
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyerit_tpgt_create(it_config_t *cfg, it_tgt_t *tgt, it_tpgt_t **tpgt,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) memset(&(tagid_used[0]), 0, sizeof (tagid_used));
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Make sure this name and/or tag isn't already on the list
4ac67f0276a8313b5cefec38af347b94b7bfb526Anurag S. Maskey * At the same time, capture all tag ids in use for this target
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * About tag numbering -- since tag numbers are used by
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * the iSCSI protocol, we should be careful about reusing
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * them too quickly. Start with a value greater than the
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * highest one currently defined. If current == MAXTAG,
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * just find an unused tag.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (strcmp(tpg_name, cfgt->tpgt_tpg_name) == 0) {
return (E2BIG);
tagid++;
if (!ptr) {
return (ENOMEM);
while (ptr) {
if (!ptr) {
if (prev) {
char *portal_ip_port)
int ret;
return (EINVAL);
while (ptr) {
if (ptr) {
return (EEXIST);
if (!ptr) {
return (ENOMEM);
if (ret != 0) {
return (ret);
return (EINVAL);
while (ptr) {
if (!ptr) {
while (tgt) {
while (tpgt) {
if (!force) {
return (EBUSY);
if (prev) {
char *portal_ip_port)
return (EINVAL);
== NULL) {
return (EINVAL);
while (ctpg) {
return (EEXIST);
if (!ptr) {
return (ENOMEM);
sizeof (struct sockaddr_storage));
while (ptr) {
if (!ptr) {
if (prev) {
return (EINVAL);
return (EFAULT);
while (ptr) {
if (ptr) {
return (EEXIST);
if (!ptr) {
return (ENOMEM);
int ret;
return (EINVAL);
if (errlist) {
if (ret == 0) {
if (ret == 0) {
if (ret == 0) {
if (ret == 0) {
if (ret != 0) {
if (iprops) {
return (ret);
while (ptr) {
if (!ptr) {
if (prev) {
int errcnt = 0;
char *name;
char *val;
if (!nvl) {
if (!name) {
errcnt++;
if (!val) {
errcnt++;
errcnt++;
if (!val) {
errcnt++;
errcnt++;
errcnt++;
if (errcnt) {
return (EINVAL);
int errcnt = 0;
char *name;
char *val;
char *rad_server;
if (!nvl) {
if (!name) {
if (!val) {
errcnt++;
if (!val) {
errcnt++;
errcnt++;
errcnt++;
while (acount > 0) {
errcnt++;
acount--;
if (!val) {
errcnt++;
if (!val) {
errcnt++;
errcnt++;
errcnt++;
if (update_rad_server) {
if (auth) {
errcnt++;
errcnt++;
if (errcnt) {
return (EINVAL);
int errcnt = 0;
char *name;
char *val;
if (!nvl) {
if (!name) {
errcnt++;
if (!val) {
errcnt++;
errcnt++;
if (errcnt) {
return (EINVAL);
int ret;
if (opt_iqn_suffix) {
return (EINVAL);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_TRUE);