/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "isns_server.h"
#include "isns_msgq.h"
#include "isns_htab.h"
#include "isns_dd.h"
#include "isns_cache.h"
#include "isns_obj.h"
#include "isns_pdu.h"
#include "isns_dseng.h"
#include "isns_scn.h"
#include "isns_utils.h"
/*
* extern global variables
*/
extern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
extern msg_queue_t *sys_q;
extern msg_queue_t *scn_q;
extern int cache_flag;
/*
* extern functions.
*/
/*
* global variables
*/
/*
* local variables
*/
/*
* local functions.
*/
static int
void *p1,
void *p2
)
{
int ec = 0;
switch (tag) {
case ISNS_DD_NAME_ATTR_ID:
break;
case ISNS_DD_FEATURES_ATTR_ID:
break;
case ISNS_DD_SET_NAME_ATTR_ID:
break;
break;
default:
ASSERT(0);
break;
}
switch (tag) {
case ISNS_DD_NAME_ATTR_ID:
case ISNS_DD_SET_NAME_ATTR_ID:
/* check if the name is in use */
if (uid != 0) {
}
return (ec);
}
} else {
/* memory exhausted */
return (ISNS_RSP_INTERNAL_ERROR);
}
}
break;
case ISNS_DD_FEATURES_ATTR_ID:
} else {
return (ec);
}
break;
}
/* cache has been updated, set the flag */
/* update data store */
}
return (ec);
}
static isns_obj_t *
)
{
} else if (uid != 0) {
}
break;
default:
ASSERT(0);
break;
}
return (obj);
}
static isns_obj_t *
)
{
if (assign_attr(
&name) != 0) {
}
}
return (obj);
}
static int
int flag
)
{
int ec = 0;
int i = 0;
*m_type = 0;
*m_id = 0;
i ++;
}
i ++;
}
/* a member id or member name is required */
if (i == 0) {
if (flag != 0) {
/* add member */
return (ISNS_RSP_INVALID_REGIS);
} else {
/* remove member (isnsp msg request only) */
return (0);
}
}
if (flag != 0) {
/* add member */
/* object does not exist, create one */
} else {
if (ec != 0) {
}
}
} else {
/* don't create it if uid is specified */
}
} else {
/* remove member */
}
}
}
return (ec);
}
static int
)
{
int ec = 0;
if (m_id != 0) {
} else {
return (ISNS_RSP_INVALID_REGIS);
}
if (tmp_id == 0) {
/* object does not exist, create one */
} else {
/* no memory */
}
}
return (ec);
}
static int
int ddd_flag
)
{
int ec = 0;
uint32_t i, j, k = 0;
if (op == '-') {
goto update_matrix_done;
}
/* enlarge the matrix on x axis */
} else {
}
}
i = 0;
while (i < matrix->y) {
break;
} else if (x_info == 0 && k == 0) {
/* the first available slot */
k = i;
}
i ++;
}
if (i == matrix->y) {
if (op == '-') {
goto update_matrix_done;
} else if (k == 0) {
} else {
i = k;
}
}
/*
* enlarge the matrix.
*/
if (new_x == 0) {
}
if (new_y == 0) {
}
if (tmp_matrix != NULL) {
j = 0;
while (j < matrix->y) {
if (x_info != 0) {
}
j ++;
}
matrix->x = tmp_matrix->x;
matrix->y = tmp_matrix->y;
matrix->m = tmp_matrix->m;
} else {
goto update_matrix_done;
}
}
if (op == '+') {
if (ddd_flag != 0) {
}
} else {
}
} else if (op == '-') {
if (ddd_flag != 0) {
i = 1;
while (i < matrix->y) {
if (x_info != 0 &&
break;
}
i ++;
}
if (i == matrix->y) {
}
}
} else {
}
}
return (ec);
}
/*ARGSUSED*/
static int
)
{
}
static int
)
{
}
static int
bmp_t **p,
uint32_t *n,
int ddd_flag
)
{
int ec = 0;
int i, j;
if (p != NULL) {
*p = NULL;
*n = 0;
}
i = 0;
while (i < matrix->y) {
if (p != NULL) {
/* dup it for caller */
*n = matrix->x;
if (*p != NULL) {
*n * sizeof (bmp_t));
} else {
}
}
/* clean it */
break;
}
i ++;
}
/* Test the membership for each node which is a */
/* member in the dd that is being deleted. */
FOR_EACH_MEMBER(*p, *n, i, {
j = get_dd_id(i, 0);
if (j == 0) {
/* put it to the default dd */
primary = GET_PRIMARY(i);
second = GET_SECOND(i);
}
});
}
return (ec);
}
static int
bmp_t **p,
uint32_t *n
)
{
int ec = 0;
int i;
*n = 0;
*p = NULL;
i = 0;
while (i < matrix->y) {
/* dup it for caller */
*n = matrix->x;
if (*p != NULL) {
*n * sizeof (bmp_t));
} else {
*n = 0;
}
break;
}
i ++;
}
return (ec);
}
static int
bmp_t **p,
uint32_t *n
)
{
}
static int
)
{
}
int
bmp_t **p,
uint32_t *n
)
{
}
int
bmp_t **p,
uint32_t *n
)
{
}
/*ARGSUSED*/
static int
void *p1,
void *p2
)
{
}
static int
)
{
if (dds_id == 0) {
return (0);
}
}
int
)
{
int active = 0;
int i;
if (dd_id == 0) {
return (active);
}
if (primary < dds_matrix->x) {
i = 0;
while (i < dds_matrix->y) {
if (x_info != 0 &&
if (get_dds_status(x_info) != 0) {
active = 1;
break;
}
}
i ++;
}
}
return (active);
}
int
bmp_t **p,
uint32_t *n
)
{
int ec = 0;
int i, j;
/* clear it */
*p = NULL;
*n = 0;
/* get the source object uid */
/* no such object */
if (uid == 0) {
return (ec);
}
i = 0;
while (i < dd_matrix->y) {
if (is_dd_active(x_info) != 0 &&
if (*p == NULL) {
*p = tmp_p;
*n = tmp_n;
} else {
if (*n >= tmp_n) {
} else {
short_p = *p;
short_n = *n;
*p = tmp_p;
*n = tmp_n;
}
j = 0;
while (j < short_n) {
(*p)[j] |= short_p[j];
j ++;
}
}
}
}
i ++;
}
}
primary ++;
if (*p != NULL) {
*n = primary;
} else {
*n = 0;
}
}
if (*p != NULL) {
}
return (ec);
}
int
void *p1,
void *p2
)
{
int ec = 0;
int i = 1;
while (i < MAX_LOOKUP_CTRL &&
i ++;
}
while (ec == 0 &&
i < MAX_LOOKUP_CTRL &&
case ISNS_ISCSI_NAME_ATTR_ID:
} else {
/* memory exhausted */
}
break;
break;
} else {
/* memory exhausted */
}
break;
} else {
/* memory exhausted */
}
break;
break;
} else {
/* memory exhausted */
}
break;
case ISNS_PORTAL_PORT_ATTR_ID:
case ISNS_ESI_PORT_ATTR_ID:
} else {
}
break;
default:
ASSERT(0);
break;
}
i ++;
}
return (ec);
}
static matrix_t *
uint32_t x,
uint32_t y
)
{
matrix->x = x;
matrix->y = y;
}
}
return (matrix);
}
int
struct cache *c
)
{
matrix_t *x;
/*
* allocate an array of pointer for dd and dd-set matrix.
*/
if (c->x == NULL) {
return (1);
}
/*
* create dd matrix.
*/
if (x != NULL) {
x->c = c;
c->x[0] = x;
} else {
return (1);
}
/*
* Mark the first array on the y axis for Default DD.
*/
bmp = MATRIX_X_UNIT(x, 0);
/*
* create dd set matrix.
*/
if (x != NULL) {
x->c = c;
c->x[1] = x;
} else {
return (1);
}
/*
* Mark the first array on the y axis for Default DD-set.
*/
bmp = MATRIX_X_UNIT(x, 0);
/*
* Add Default DD as a member of Default DD-set.
*/
return (0);
}
static uint32_t
)
{
int i = 0;
while (i < matrix->y) {
}
}
i ++;
}
}
return (dd_id);
}
)
{
int i = 0;
while (i < matrix->y) {
break;
}
i ++;
}
}
return (dd_id);
}
)
{
}
)
{
}
static int
isns_obj_t **ds_p,
)
{
int ec = 0;
} else {
}
} else {
/* no memory */
}
return (ec);
}
int
isns_tlv_t *op,
)
{
int ec = 0;
case ISNS_DD_ID_ATTR_ID:
}
break;
case ISNS_DD_NAME_ATTR_ID:
}
break;
break;
break;
case ISNS_DD_FEATURES_ATTR_ID:
}
break;
default:
break;
}
}
if (ec == 0) {
}
return (ec);
}
int
isns_tlv_t *op,
)
{
int ec = 0;
case ISNS_DD_SET_ID_ATTR_ID:
}
break;
case ISNS_DD_SET_NAME_ATTR_ID:
}
break;
}
break;
case ISNS_DD_ID_ATTR_ID:
break;
default:
break;
}
}
if (ec == 0) {
}
return (ec);
}
int
isns_obj_t **dd_p,
)
{
/* need to include the null terminator */
/* and be on 4 bytes aligned */
}
}
int
isns_obj_t **dds_p,
)
{
/* need to include the null terminator */
/* and be on 4 bytes aligned */
}
}
static int
)
{
int ec = 0;
if (uid == 0) {
}
return (ec);
}
int
)
{
/*
* We do now allow changing the default DD and DD-set name.
*/
if (uid == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
}
int
)
{
/*
* We do now allow changing the default DD and DD-set name.
*/
if (uid == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
}
static int
)
{
int ec = 0;
if (uid == 0) {
}
return (ec);
}
int
)
{
}
int
)
{
}
int
)
{
int ec = 0;
/*
* We do now allow placing any node to the default DD explicitly.
*/
if (dd_id == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
if (ec == 0) {
'+', /* add member */
m_id);
}
if (ec == 0) {
/* add the membership to data store */
}
/* trigger a management scn */
}
}
return (ec);
}
int
)
{
int ec = 0;
/*
* We do now allow changing the membership of the default DD
* and DD-set.
*/
if (dds_id == ISNS_DEFAULT_DD_SET_ID ||
m_id == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
if (ec == 0) {
'+', /* add member */
m_id);
}
if (ec == 0) {
/* add the membership to data store */
}
/* trigger a management scn */
}
}
return (ec);
}
int
)
{
int ec = 0;
/*
* We do now allow removing the member from default DD explicitly.
*/
if (dd_id == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
if (ec == 0) {
'-', /* remove member */
m_id);
if (ec == 0) {
/* update data store */
/* remove it from data store */
ec = write_data(
}
/* trigger a management scn */
}
/* remove it from object container if */
/* it is not a registered object */
if (ec == 0) {
}
}
}
return (ec);
}
int
)
{
int ec = 0;
/*
* We do now allow removing the member from default DD-set.
*/
if (dds_id == ISNS_DEFAULT_DD_SET_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
if (m_id != 0) {
'-', /* remove member */
m_id);
if (ec == 0) {
}
/* update data store */
/* remove it from data store */
ec = write_data(
} else {
}
}
/* trigger a management scn */
if (ec == 0 &&
}
}
}
return (ec);
}
static int
)
{
int ec = 0;
int i;
return (ec);
}
i = 0;
if (x_info != 0 &&
/* clean the membership */
/* update data store */
/* remove it from data store */
ec = write_data(
} else {
}
}
}
i ++;
}
return (ec);
}
int
)
{
bmp_t *p;
uint32_t n;
int ec;
/*
* We do now allow removing the default DD.
*/
if (dd_id == ISNS_DEFAULT_DD_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
/* de-register the object at first */
/* clear it from all of dd-set */
/* clear its member bitmap */
(void) clear_dd_matrix(dd_id, &p, &n);
/* deregister the member nodes which are not-registered node */
/* and have no longer membership in other DD(s). */
if (p != NULL) {
FOR_EACH_MEMBER(p, n, uid, {
(void) dereg_assoc(&lc);
});
free(p);
}
return (ec);
}
int
)
{
int ec;
/*
* We do now allow removing the default DD-set.
*/
if (dds_id == ISNS_DEFAULT_DD_SET_ID) {
return (ISNS_RSP_OPTION_NOT_UNDERSTOOD);
}
(void) clear_dds_matrix(dds_id);
return (ec);
}
int
void *p,
)
{
obj = (isns_obj_t *)p;
return (0);
}
}
int
)
{
int ec = 0;
/* Ensure the Default DD is registered. */
(void) cache_lock_write();
if (is_obj_there(&lc) == 0) {
if (ec == 0) {
if (ec != 0) {
goto verify_done;
}
} else {
goto verify_done;
}
}
/* Ensure the Default DD-set is registered. */
if (is_obj_there(&lc) == 0) {
if (ec == 0) {
if (ec != 0) {
}
}
}
return (ec);
}