fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_msgq.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_htab.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dd.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_pdu.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_dseng.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_scn.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_utils.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extern global variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern msg_queue_t *sys_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern msg_queue_t *scn_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int cache_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extern functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic matrix_t *new_matrix(uint32_t, uint32_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_update_ds_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag = lcp->id[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t which;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte which = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_FEATURES_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte which = ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte which = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte which = ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[which];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = lcp->data[2].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = lcp->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = which;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check if the name is in use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != get_obj_uid(obj)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_NAME_IN_USE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (len > attr->len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *tmp = (uchar_t *)malloc(len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INTERNAL_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)attr->value.ptr, (char *)name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_FEATURES_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag != tag ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui != lcp->data[1].ui) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = lcp->data[1].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cache has been updated, set the flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_CACHE_UPDATED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_UPDATE, obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_obj_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_member_node(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (attr1->tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp.tag = ISNS_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp.len = attr1->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp.value.ptr = attr1->value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(attr, &tmp) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_uid(obj, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic isns_obj_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_member_dd(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t name = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_uid(obj, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.tag = ISNS_DD_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (assign_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &obj->attrs[ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID)],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &name) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_member_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *m_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *m_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr1, *attr2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *m_type = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *m_id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr1 = &assoc->attrs[ATTR_INDEX_ASSOC_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_INDEX_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr2 = &assoc->attrs[ATTR_INDEX_ASSOC_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr1->tag != 0 && attr1->value.ui != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *m_id = attr1->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[i] = UID_ATTR_INDEX[OBJ_ISCSI];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[i] = OP_INTEGER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[i].ui = *m_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr2->tag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[i] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[i] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[i].ptr = attr2->value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (scn_q != NULL || sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[i] = ISNS_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a member id or member name is required */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INVALID_REGIS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove member (isnsp msg request only) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, &tmp_id, cb_clone_attrs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && tmp_id == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr1->tag == 0 || sys_q == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* object does not exist, create one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = make_member_node(*m_id, attr2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = register_assoc(obj, &tmp_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* don't create it if uid is specified */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_NO_SUCH_ENTRY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_NO_SUCH_ASSOCIATION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr1->tag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr1->tag = ISNS_DD_ISCSI_INDEX_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr1->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr1->value.ui = tmp_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (attr2->tag == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr2->tag = ISNS_DD_ISCSI_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr2->len = strlen((char *)lc.data[1].ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr2->len += 4 - (attr2->len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr2->value.ptr = lc.data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *m_type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *m_id = tmp_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dds_member_info(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (m_id != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DD, m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_INVALID_REGIS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_id = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_id == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* object does not exist, create one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = make_member_dd(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = register_object(obj, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uchar_t op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t puid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t m_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ddd_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t new_x = 0, new_y = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *tmp_matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i, j, k = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp, *tmp_bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary = GET_PRIMARY(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second = GET_SECOND(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (primary >= matrix->x) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op == '-') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_NO_SUCH_ASSOCIATION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto update_matrix_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* enlarge the matrix on x axis */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (primary >= matrix->x * 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_x = primary + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_x = matrix->x * 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info == puid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (x_info == 0 && k == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the first available slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op == '-') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_NO_SUCH_ASSOCIATION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto update_matrix_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (k == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_y = matrix->y * 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enlarge the matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new_x != 0 || new_y != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new_x == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_x = matrix->x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new_y == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte new_y = matrix->y;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_matrix = new_matrix(new_x, new_y);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmp_matrix != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, j);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp_bmp = MATRIX_X_UNIT(tmp_matrix, j);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy((void *)tmp_bmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)bmp, SIZEOF_X_UNIT(matrix));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(matrix->m);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->x = tmp_matrix->x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->y = tmp_matrix->y;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->m = tmp_matrix->m;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(tmp_matrix);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto update_matrix_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATRIX_X_INFO(bmp) = puid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op == '+') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TEST_MEMBERSHIP(bmp, primary, second) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_CACHE_UPDATED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddd_flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(MATRIX_X_INFO(bmp) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DEFAULT_DD_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEAR_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_ALREADY_ASSOCIATED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op == '-') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (TEST_MEMBERSHIP(bmp, primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEAR_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_CACHE_UPDATED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddd_flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i == matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(MATRIX_X_INFO(bmp) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DEFAULT_DD_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ERR_NO_SUCH_ASSOCIATION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_matrix_done:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dd_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uchar_t op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dd_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t m_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t m_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(m_type == OBJ_ISCSI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_matrix(matrix, op, dd_id, m_id, 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dds_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uchar_t op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dds_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t m_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *dds_matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_matrix(dds_matrix, op, dds_id, m_id, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclear_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ddd_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info == uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dup it for caller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = matrix->x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (bmp_t *)malloc(*n * sizeof (bmp_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(*p, &bmp[MATRIX_X_HEADER],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n * sizeof (bmp_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(bmp, 0, SIZEOF_X_UNIT(matrix));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ddd_flag != 0 && p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(MATRIX_X_INFO(bmp) == ISNS_DEFAULT_DD_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Test the membership for each node which is a */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* member in the dd that is being deleted. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(*p, *n, i, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = get_dd_id(i, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* put it to the default dd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary = GET_PRIMARY(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte second = GET_SECOND(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info == uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dup it for caller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = matrix->x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (bmp_t *)malloc(*n * sizeof (bmp_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(*p, &bmp[MATRIX_X_HEADER],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n * sizeof (bmp_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclear_dd_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dd_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (clear_matrix(matrix, dd_id, p, n, 1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclear_dds_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dds_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (clear_matrix(matrix, dds_id, NULL, NULL, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dd_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dd_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_matrix(matrix, dd_id, p, n));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dds_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uint32_t dds_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_matrix(matrix, dds_id, p, n));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_get_dds_status(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr = &obj->attrs[
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DDS_ENABLED(attr->value.ui) ? 1 : 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dds_status(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dds_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dds_id == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DDS, dds_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cache_lookup(&lc, NULL, cb_get_dds_status));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteis_dd_active(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int active = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *dds_matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd_id == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (active);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary = GET_PRIMARY(dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte second = GET_SECOND(dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (primary < dds_matrix->x) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < dds_matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(dds_matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (get_dds_status(x_info) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte active = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (active);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_scope(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *n
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *dd_matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *tmp_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tmp_n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *short_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t short_n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the source object uid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.curr_uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.type = OBJ_ISCSI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[0] = ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[0] = OP_STRING;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ptr = node_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.op[1] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = is_obj_there(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no such object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary = GET_PRIMARY(uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte second = GET_SECOND(uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (primary < dd_matrix->x) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < dd_matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(dd_matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && x_info != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_dd_active(x_info) != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ec = get_dd_matrix(x_info,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &tmp_p, &tmp_n)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = tmp_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = tmp_n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*n >= tmp_n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte short_p = tmp_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte short_n = tmp_n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte short_p = *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte short_n = *n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = tmp_p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = tmp_n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (j < short_n) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*p)[j] |= short_p[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(short_p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && *p == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (bmp_t *)calloc(primary, sizeof (bmp_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *n = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*p)[primary - 1] |= (1 << second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_clone_attrs(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < MAX_LOOKUP_CTRL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->op[i] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i < MAX_LOOKUP_CTRL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->id[i] != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (lcp->id[i]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ptr = (uchar_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[i].ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)lcp->data[i].ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ISCSI_NODE_TYPE_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ISCSI(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ISCSI_NODE_TYPE_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_ISCSI_NAME_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ptr = (uchar_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[i].ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)lcp->data[i].ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)attr->value.ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ip = (in6_addr_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[i].ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(lcp->data[i].ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip, attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PG_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PG(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PG_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_IP_ADDR_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ip = (in6_addr_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lcp->data[i].ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(lcp->data[i].ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip, attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* memory exhausted */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_ESI_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(lcp->id[i])];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag != 0 && attr->value.ui != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[i].ui = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic matrix_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenew_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t y
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix = (matrix_t *)malloc(sizeof (matrix_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matrix != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->x = x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->y = y;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix->m = (bmp_t *)calloc(y, SIZEOF_X_UNIT(matrix));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matrix->m == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(matrix);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (matrix);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedd_matrix_init(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct cache *c
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate an array of pointer for dd and dd-set matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->x = (matrix_t **)calloc(2, sizeof (matrix_t *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (c->x == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create dd matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x = new_matrix(8, 64);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->x[0] = x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark the first array on the y axis for Default DD.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(x, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATRIX_X_INFO(bmp) = ISNS_DEFAULT_DD_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create dd set matrix.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x = new_matrix(2, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x->c = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c->x[1] = x;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark the first array on the y axis for Default DD-set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(x, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATRIX_X_INFO(bmp) = ISNS_DEFAULT_DD_SET_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add Default DD as a member of Default DD-set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte primary = GET_PRIMARY(ISNS_DEFAULT_DD_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte second = GET_SECOND(ISNS_DEFAULT_DD_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_ds_id(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t curr_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary = GET_PRIMARY(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second = GET_SECOND(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matrix->x > primary) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid > curr_id &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd_id == 0 || uid < dd_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_common_dd(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t curr_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary1 = GET_PRIMARY(m_id1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second1 = GET_SECOND(m_id1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary2 = GET_PRIMARY(m_id2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second2 = GET_SECOND(m_id2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (matrix->x > primary1 && matrix->x > primary2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (MATRIX_X_INFO(bmp) > curr_id &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary1, second1) != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary2, second2) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dd_id(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t curr_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_ds_id(matrix, m_id, curr_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_dds_id(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t curr_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (get_ds_id(matrix, m_id, curr_id));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_ds_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **ds_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *name_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *uid_attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *status_attr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int id1, id2, id3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (type == OBJ_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id1 = ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id2 = ATTR_INDEX_DD(ISNS_DD_ID_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id3 = ATTR_INDEX_DD(ISNS_DD_FEATURES_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(type == OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id1 = ATTR_INDEX_DDS(ISNS_DD_SET_NAME_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id2 = ATTR_INDEX_DDS(ISNS_DD_SET_ID_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte id3 = ATTR_INDEX_DDS(ISNS_DD_SET_STATUS_ATTR_ID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (name_attr != NULL && name_attr->tag != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assign_attr(&obj->attrs[id1], name_attr) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uid_attr == NULL || uid_attr->value.ui == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assign_attr(&obj->attrs[id2], uid_attr) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (status_attr == NULL || status_attr->value.ui == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assign_attr(&obj->attrs[id3], status_attr) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *ds_p = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_dd_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t op_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **dd_p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t name = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t dd_id = { 0 }, features = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.tag = ISNS_DD_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (op_len > 8 && ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = &op->attr_value[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (op->attr_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id.tag = ISNS_DD_ID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id.value.ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op->attr_len <= 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.len = op->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.value.ptr = (uchar_t *)value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ISCSI_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_FC_PORT_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_PORTAL_INDEX_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_PORTAL_IP_ADDR_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_PORTAL_PORT_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_REGIS_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_FEATURES_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features.tag = ISNS_DD_FEATURES_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features.len = op->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features.value.ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = create_ds_object(OBJ_DD, dd_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &name, &dd_id, &features);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecreate_dds_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_tlv_t *op,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t op_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **dds_p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t name = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t dds_id = { 0 }, code = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.tag = ISNS_DD_SET_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (op_len > 8 && ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = &op->attr_value[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (op->attr_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id.tag = ISNS_DD_ID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id.value.ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_NAME_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len > 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte op->attr_len <= 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.len = op->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name.value.ptr = (uchar_t *)value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_SET_STATUS_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (op->attr_len == 4) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code.tag = ISNS_DD_SET_STATUS_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code.len = op->attr_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code.value.ui = ntohl(*(uint32_t *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (op->attr_len != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_MSG_FORMAT_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ISNS_DD_ID_ATTR_ID:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NEXT_TLV(op, op_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = create_ds_object(OBJ_DDS, dds_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &name, &dds_id, &code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadm_create_dd(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **dd_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t features
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t name_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t uid_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t features_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.tag = ISNS_DD_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (name != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to include the null terminator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and be on 4 bytes aligned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen((char *)name) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.value.ptr = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.tag = ISNS_DD_ID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.value.ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features_attr.tag = ISNS_DD_FEATURES_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features_attr.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features_attr.value.ui = features;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (create_ds_object(OBJ_DD, dd_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &name_attr, &uid_attr, &features_attr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadm_create_dds(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **dds_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t name_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t uid_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t code_attr = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.tag = ISNS_DD_SET_NAME_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (name != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to include the null terminator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and be on 4 bytes aligned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen((char *)name) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name_attr.value.ptr = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.tag = ISNS_DD_SET_ID_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid_attr.value.ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code_attr.tag = ISNS_DD_SET_STATUS_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code_attr.len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code_attr.value.ui = code;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (create_ds_object(OBJ_DDS, dds_p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &name_attr, &uid_attr, &code_attr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_ds_name(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ui = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ptr = name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_rekey(&lc, &uid, cb_update_ds_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dd_name(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow changing the default DD and DD-set name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_ds_name(OBJ_DD, uid, ISNS_DD_NAME_ATTR_ID, len, name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dds_name(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow changing the default DD and DD-set name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_ds_name(OBJ_DDS, uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_SET_NAME_ATTR_ID, len, name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_ds_uint32(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, type, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ui = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_lookup(&lc, &uid, cb_update_ds_attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INVALID_REGIS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dd_features(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t features
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_ds_uint32(OBJ_DD, uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_FEATURES_ATTR_ID, features));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_dds_status(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t enabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_ds_uint32(OBJ_DDS, uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_SET_STATUS_ATTR_ID, enabled));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_dd_member(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id, m_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = get_parent_uid(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow placing any node to the default DD explicitly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd_id == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_member_info(assoc, &m_type, &m_id, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_dd_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '+', /* add member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add the membership to data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_ADD, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a management scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_MEMBER_ADDED, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_dds_member(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id = assoc->attrs[ATTR_INDEX_ASSOC_DD(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_DD_ID_ATTR_ID)].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dds_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id = get_parent_uid(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow changing the membership of the default DD
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and DD-set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dds_id == ISNS_DEFAULT_DD_SET_ID ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_id == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_dds_member_info(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_dds_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '+', /* add member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add the membership to data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(DATA_ADD, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a management scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_MEMBER_ADDED, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_dd_member(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *assoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id = get_parent_uid(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow removing the member from default DD explicitly.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd_id == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_member_info(assoc, &m_type, &m_id, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_dd_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '-', /* remove member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dd_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DATA_DELETE_ASSOC, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a management scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && scn_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_MEMBER_REMOVED, assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from object container if */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it is not a registered object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, m_type, m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = dereg_assoc(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_dds_member(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dds_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *clone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow removing the member from default DD-set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dds_id == ISNS_DEFAULT_DD_SET_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (m_id != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_dds_matrix(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte '-', /* remove member */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_id,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clone = obj_calloc(OBJ_ASSOC_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clone != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_uid((void *)clone, m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_parent_obj(clone, dds_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clone != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DATA_DELETE_ASSOC, clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trigger a management scn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scn_q != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clone != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) make_scn(ISNS_MEMBER_REMOVED, clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_member_wildchar(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t m_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t x_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t primary = GET_PRIMARY(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t second = GET_SECOND(m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *clone;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (primary >= matrix->x) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 && i < matrix->y) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = MATRIX_X_UNIT(matrix, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte x_info = MATRIX_X_INFO(bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (x_info != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TEST_MEMBERSHIP(bmp, primary, second) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean the membership */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CLEAR_MEMBERSHIP(bmp, primary, second);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* update data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sys_q != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clone = obj_calloc(OBJ_ASSOC_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clone != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_obj_uid((void *)clone, m_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) set_parent_obj(clone, x_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = write_data(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DATA_DELETE_ASSOC, clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(clone);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_dd_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dd_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *dds_matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow removing the default DD.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dd_id == ISNS_DEFAULT_DD_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DD, dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* de-register the object at first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = dereg_object(&lc, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear it from all of dd-set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dds_matrix = cache_get_matrix(OBJ_DDS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) remove_member_wildchar(dds_matrix, dd_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clear its member bitmap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) clear_dd_matrix(dd_id, &p, &n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deregister the member nodes which are not-registered node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and have no longer membership in other DD(s). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_ISCSI, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_MEMBER(p, n, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) dereg_assoc(&lc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_dds_object(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dds_id
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do now allow removing the default DD-set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dds_id == ISNS_DEFAULT_DD_SET_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) clear_dds_matrix(dds_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DDS, dds_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = dereg_object(&lc, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_ddd(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const uchar_t op
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix_t *matrix;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj->type != OBJ_ISCSI) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matrix = cache_get_matrix(OBJ_DD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (update_matrix(matrix, op, ISNS_DEFAULT_DD_ID, uid, 0));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteverify_ddd(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t features;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t code;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Ensure the Default DD is registered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = ISNS_DEFAULT_DD_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DD, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_obj_there(&lc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = (uchar_t *)DEFAULT_DD_NAME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte features = DEFAULT_DD_FEATURES;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = adm_create_dd(&obj, name, uid, features);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = register_object(obj, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto verify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto verify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Ensure the Default DD-set is registered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = ISNS_DEFAULT_DD_SET_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_DDS, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_obj_there(&lc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = (uchar_t *)DEFAULT_DD_SET_NAME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte code = DEFAULT_DD_SET_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = adm_create_dds(&obj, name, uid, code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = register_object(obj, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteverify_done:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_unlock_sync(ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}