Update of /cvsroot/linuxisns/isnsNT/isnsserver/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv21359/src Modified Files: iSNSList.c iSNSUtil.c iSNSdb.c iSNSdereg.c iSNSesi.c iSNSparse.c iSNSquery.c iSNSreg.c iSNSresponse.c Log Message: Fix up Portal object and rework ESI processing Index: iSNSUtil.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSUtil.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** iSNSUtil.c 13 Dec 2006 23:53:01 -0000 1.10 --- iSNSUtil.c 14 Dec 2006 23:04:28 -0000 1.11 *************** *** 758,762 **** { ISNS_LIST_NODE *pnode; - ENTITY_LIST_ENTRY *lentry; /* Assumes a IPv4 Address */ --- 758,761 ---- *************** *** 776,784 **** pnode = NULL; ! while ((pnode = GetNextNode(&p_portal->entity_list, pnode))) ! { ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! printf("ENTITY : %s (%u)\n", lentry->eid.id, lentry->entity_index); ! } printf("GROUP : %#x\n", p_portal->group); printf("ESI INTERVAL : %u\n", p_portal->esi_interval); --- 775,779 ---- pnode = NULL; ! printf("ENTITY : %s\n", p_portal->entity_id.id); printf("GROUP : %#x\n", p_portal->group); printf("ESI INTERVAL : %u\n", p_portal->esi_interval); Index: iSNSquery.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSquery.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iSNSquery.c 13 Dec 2006 19:45:57 -0000 1.8 --- iSNSquery.c 14 Dec 2006 23:04:28 -0000 1.9 *************** *** 80,84 **** extern SOIP_Dd_Member *ddmem; /* [100]; */ - extern ISNS_LIST esi_list; extern ISNS_LIST scn_list; extern ISNS_LIST scn_callback_list; --- 80,83 ---- *************** *** 251,255 **** int iFCPNodeKeyFlag; int foundFlag; - ISNS_LIST_NODE *lnode; ISNS_Key *key; ISNS_Attr *attr; /* query attr, response attr */ --- 250,253 ---- *************** *** 401,424 **** /* Fetch entity from hash */ ! lnode = NULL; ! while ((lnode = GetNextNode(&p_portal->entity_list, lnode))) { - ENTITY_LIST_ENTRY *lentry; - - lentry = (ENTITY_LIST_ENTRY *) GetNodeData(lnode); - if (ISNS_NO_ERR != - SNSdbFetchEntity (lentry->eid.id, &p_entity, &entry)) - { return (ISNS_INVALID_QUERY_ERR); ! } ! rval = Check_Permission (src_attr, ENTITY_ID_KEY, p_entity); ! if (rval == SUCCESS) ! { foundFlag = TRUE; ISNSdbProcessEntityOpAttr (p_rspmsg, (ISNS_Attr **)attr_indx, p_entity); - } } - } else if (iFCPNodeKeyFlag != -1) --- 399,414 ---- /* Fetch entity from hash */ ! if (ISNS_NO_ERR != ! SNSdbFetchEntity (p_portal->entity_id.id, &p_entity, &entry)) { return (ISNS_INVALID_QUERY_ERR); ! } ! rval = Check_Permission (src_attr, ENTITY_ID_KEY, p_entity); ! if (rval == SUCCESS) ! { foundFlag = TRUE; ISNSdbProcessEntityOpAttr (p_rspmsg, (ISNS_Attr **)attr_indx, p_entity); } } else if (iFCPNodeKeyFlag != -1) *************** *** 1305,1309 **** SOIP_Entity *p_entity; SOIP_Portal *p_portal; - SOIP_Entity_Key db_entity_id; SOIP_DB_Portal db_portal; int entityKeyFlag; --- 1295,1298 ---- *************** *** 1315,1319 **** int foundFlag; ISNS_LIST_NODE *pnode; - ISNS_LIST_NODE *pnode2; int rval; --- 1304,1307 ---- *************** *** 1491,1507 **** p_portal = &entry2.data.portal; - pnode2 = NULL; - while ((pnode2 = GetNextNode(&p_portal->entity_list, pnode2))) { - ENTITY_LIST_ENTRY *lentry; - - lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode2); - /* Fetch entity from hash */ - memset (&db_entity_id, 0, sizeof (db_entity_id)); - strncpy (db_entity_id.id, lentry->eid.id, sizeof(db_entity_id.id) ); ISNS_Key read_key; read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,db_entity_id.id); rval = ISNSdbRead(&read_key,&entry); if (rval != SUCCESS) --- 1479,1487 ---- p_portal = &entry2.data.portal; { /* Fetch entity from hash */ ISNS_Key read_key; read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,p_portal->entity_id.id); rval = ISNSdbRead(&read_key,&entry); if (rval != SUCCESS) *************** *** 1585,1589 **** SOIP_ISCSI_Node_Id db_node_name; ISNS_LIST_NODE *pnode; - ISNS_LIST_NODE *pnode2; int rval; --- 1565,1568 ---- *************** *** 1785,1816 **** p_portal = &entry.data.portal; - pnode2 = NULL; - while ((pnode2 = GetNextNode(&p_portal->entity_list, pnode2))) { ! ENTITY_LIST_ENTRY *lentry; ! ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode2); ! ! /* Fetch ENTITY */ ! ISNS_Key read_key; ! read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,lentry->eid.id); ! rval = ISNSdbRead(&read_key,&entry); ! if (rval != SUCCESS) return rval; ! p_entity = &entry.data.entity; ! ! /* Check to make sure this is an iSCSI Entity */ ! if (p_entity->eid_type != ENTITY_TYPE_ISCSI) ! { ! printf ("***ERROR: Expected an iSCSI Entity.\n"); ! return (ERROR); ! } ! /* Scan the entity's iSCSI List */ ! pnode=NULL; ! while ((pnode=GetNextNode(&p_entity->iscsi_node_list, pnode))) ! { /* Fetch the iSCSI Node */ ISNS_Key read_key; --- 1764,1782 ---- p_portal = &entry.data.portal; { ! /* Fetch ENTITY */ ! ISNS_Key read_key; ! read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,p_portal->entity_id.id); ! rval = ISNSdbRead(&read_key,&entry); ! if (rval != SUCCESS) return rval; ! p_entity = &entry.data.entity; ! /* Scan the entity's iSCSI List */ ! pnode=NULL; ! while ((pnode=GetNextNode(&p_entity->iscsi_node_list, pnode))) ! { /* Fetch the iSCSI Node */ ISNS_Key read_key; *************** *** 1830,1834 **** foundFlag = TRUE; } ! } } } --- 1796,1800 ---- foundFlag = TRUE; } ! } } } *************** *** 2932,2936 **** int ii; ISNS_Attr *q_attr; - ISNS_LIST_NODE *pnode; for (ii = 0; ii < MAX_PARSE_ATTRS && attr_indx[ii]; ii++) --- 2898,2901 ---- *************** *** 2940,2953 **** { case ISNS_ENTITY_ID: ! pnode = NULL; ! while ((pnode = GetNextNode(&p_portal->entity_list, pnode))) ! { ! ENTITY_LIST_ENTRY *lentry; ! ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! ISNSAppendAttr ( p_msg, ISNS_ENTITY_ID, ! PAD4 (strlen (lentry->eid.id)), ! lentry->eid.id, 0 ); ! } break; case ISNS_PORTAL_PORT: --- 2905,2911 ---- { case ISNS_ENTITY_ID: ! ISNSAppendAttr ( p_msg, ISNS_ENTITY_ID, ! PAD4 (strlen (p_portal->entity_id.id)), ! p_portal->entity_id.id, 0 ); break; case ISNS_PORTAL_PORT: *************** *** 2984,2996 **** break; case ISNS_ENTITY_IDX: ! pnode = NULL; ! while ((pnode = GetNextNode(&p_portal->entity_list, pnode))) ! { ! ENTITY_LIST_ENTRY *lentry; ! ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! ISNSAppendAttr ( p_msg, ISNS_ENTITY_IDX, ISNS_ENTITY_IDX_SIZE, ! NULL, lentry->entity_index ); ! } break; case ISNS_PORTAL_IDX: --- 2942,2947 ---- break; case ISNS_ENTITY_IDX: ! ISNSAppendAttr ( p_msg, ISNS_ENTITY_IDX, ISNS_ENTITY_IDX_SIZE, ! NULL, p_portal->entity_index ); break; case ISNS_PORTAL_IDX: *************** *** 3593,3612 **** if (src_attr->tag) { - ISNS_LIST_NODE *pnode; SOIP_Portal *p_portal; p_portal = ptr; ! pnode = NULL; ! while ((pnode = GetNextNode(&p_portal->entity_list, pnode))) ! { ! ENTITY_LIST_ENTRY *lentry; ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! if (ISNS_NO_ERR != ! Get_Active_DD_List_From_ENTITY_Node (lentry->eid.id, NULL, ! dlist_node, 0)) ! { ! return (ERROR); ! } ! } if (FALSE == Check_Overlap_DD (dlist_src, dlist_node)) --- 3544,3552 ---- if (src_attr->tag) { SOIP_Portal *p_portal; p_portal = ptr; ! Get_Active_DD_List_From_ENTITY_Node (p_portal->entity_id.id, NULL, ! dlist_node, 0); if (FALSE == Check_Overlap_DD (dlist_src, dlist_node)) Index: iSNSList.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSList.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** iSNSList.c 13 Dec 2006 19:45:57 -0000 1.8 --- iSNSList.c 14 Dec 2006 23:04:27 -0000 1.9 *************** *** 60,71 **** break; } - case PORTAL_ENTITY_LIST: - { - SOIP_Portal *p_entry; - p_entry = record; - plist = &p_entry->entity_list; - plist->p_entry = p_entry; - break; - } case DDS_DD_LIST: { --- 60,63 ---- *************** *** 132,143 **** break; } - case ESI_LIST: - { - ISNS_LIST *p_entry; - p_entry = record; - plist = p_entry; - plist->p_entry = p_entry; - break; - } case SCN_CALLBACK_LIST: { --- 124,127 ---- *************** *** 294,302 **** key.val.list.key.portal.ip_port = p_portal->ip_port; } - else if (plist->list_id == ESI_LIST) - { - p_list = plist->p_entry; - strcpy (key.val.list.key.node_name.v,"esi_list"); - } else if (plist->list_id == SCN_LIST) { --- 278,281 ---- *************** *** 468,476 **** memcpy(&entry.data.list.key.portal,pdata,data_size); } - else if (plist->list_id == ESI_LIST) - { - strcpy (key.val.list.key.node_name.v,"esi_list"); - memcpy(&entry.data.list.key.node_name.v,pdata,data_size); - } else if (plist->list_id == SCN_LIST) { --- 447,450 ---- *************** *** 700,714 **** memcpy(node->data,&entry.data.list.key.portal,node->data_size); } - else if (plist->list_id == ESI_LIST) - { - p_list = (ISNS_LIST *)plist->p_entry; - strcpy (key.val.list.key.node_name.v,"esi_list"); - rval = ISNSdbRead(&key,&entry); - if (rval != SUCCESS) - return NULL; - node->data_size = sizeof(SOIP_ESI); - node->data = (char *)ISNSAllocBuffer(node->data_size+1); - memcpy(node->data,&entry.data.list.key.entity_id.id,node->data_size); - } else if (plist->list_id == SCN_LIST) { --- 674,677 ---- Index: iSNSresponse.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSresponse.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** iSNSresponse.c 12 Dec 2006 21:38:29 -0000 1.4 --- iSNSresponse.c 14 Dec 2006 23:04:28 -0000 1.5 *************** *** 71,75 **** SOIP_Dd_Member *ddmem; /* [100]; */ - ISNS_LIST esi_list; ISNS_LIST scn_list; ISNS_LIST scn_callback_list; --- 71,74 ---- Index: iSNSesi.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSesi.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** iSNSesi.c 13 Dec 2006 23:53:01 -0000 1.5 --- iSNSesi.c 14 Dec 2006 23:04:28 -0000 1.6 *************** *** 71,76 **** SOIP_Dd_Member *ddmem; /* [100]; */ - ISNS_LIST esi_list; - ISNS_Msg *p_scn_msg_buffer; ISNS_Msg *p_scn_all_msg_buffer; --- 71,74 ---- *************** *** 86,100 **** static int esi_xid = 1; int rval; - int more_esi_portals; SOIP_Portal *p_portal; - SOIP_Entity *p_entity; SOIP_DB_Portal db_portal; - ISNS_LIST_NODE *pnode2; - ISNS_LIST_NODE *pnode; - ISNS_LIST_NODE *p_esi_node; - SOIP_Esi_Entry *p_esi_entry; ISNS_Msg_Descp *p_md; ! SOIP_Entity_Key db_entity_id = {{0}}; ! ENTITY_LIST_ENTRY *lentry; DEBUG_0 (isns_esi_debug &1, ISNS_SendESI); --- 84,92 ---- static int esi_xid = 1; int rval; SOIP_Portal *p_portal; SOIP_DB_Portal db_portal; ISNS_Msg_Descp *p_md; ! time_t mytime; ! ISNS_Key read_key = { 0 }; DEBUG_0 (isns_esi_debug &1, ISNS_SendESI); *************** *** 108,130 **** } ! if ( IsEmptyList(&esi_list) ) ! { ! /* Nothing to do */ ! return (ISNS_NO_ERR); ! } ! DEBUG_0 (isns_esi_debug &1, process esi_list); ! /* Go through the ESI Table */ ! p_esi_node = GetNextNode( &esi_list, NULL ); ! while ( p_esi_node ) { ! DEBUG_0 (isns_esi_debug &1, GetNodeData); ! /* Get Node Data */ ! p_esi_entry = (SOIP_Esi_Entry *)GetNodeData(p_esi_node); - ISNS_Key read_key; - read_key.tag = PORTAL_ID_KEY; - memcpy(&read_key.val,p_esi_entry,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 100,111 ---- } ! DEBUG_0 (isns_esi_debug &1, process each portal record); ! read_key.tag = PORTAL_ID_KEY; ! while ( SNSdbGetNextOfKey (&read_key) == SUCCESS ) { ! DEBUG_0 (isns_esi_debug &1, Next Portal Record found); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 133,171 **** p_portal = (SOIP_Portal *)&entry2.data; ! /* Is ESI? */ if ( p_portal->esi_interval == 0 ) { ! p_esi_node = GetNextNode(&esi_list, p_esi_node); continue; } - - /* Send a msg to the client & update the counter */ - memset (&p_md->msg, 0, sizeof (ISNS_Msg)); - p_md->msg.hdr.type = ISNS_ESI; ! /* TODO: FIX FIX */ ! /* Don't assume first entity */ ! pnode2 = GetNextNode( &p_portal->entity_list, NULL); ! lentry = (ENTITY_LIST_ENTRY *)GetNodeData(pnode2); ! ISNSAppendKey (&p_md->msg, ISNS_ENTITY_ID, ! PAD4 (strlen (lentry->eid.id)), lentry->eid.id, 0); ! rval = ERROR; ! p_portal->esi_timer -= sns_heartbeat_interval; ! if ( p_portal->esiSent < 3 ) { ! if ( p_portal->esi_timer > 0 ) ! { ! ISNS_Key key; ! key.tag = PORTAL_ID_KEY; ! memcpy(&key.val,p_esi_entry,sizeof(SOIP_DB_Portal)); ! rval = ISNSdbWrite(&key,entry2); ! p_esi_node = GetNextNode( &esi_list, p_esi_node ); ! continue; ! } ! DEBUG_1 (isns_esi_debug & 2, (Sending ESI to Entity %s), lentry->eid.id); ISNSAppendKey ( &p_md->msg, ISNS_PORTAL_IP, ISNS_IP_SIZE, --- 114,151 ---- p_portal = (SOIP_Portal *)&entry2.data; ! /* check to see if an interval is set > 0 */ if ( p_portal->esi_interval == 0 ) { ! DEBUG_0 (isns_esi_debug &1, esi_interval not set); continue; } ! /* check to see if timer interval expired */ ! time ( &mytime ); ! if (p_portal->esi_timer > 0 && (p_portal->esi_timer + p_portal->esi_interval) > mytime) ! { ! DEBUG_0 (isns_esi_debug &1, esi_timer plus interval not reached yet); ! DEBUG_1 (isns_esi_debug &1, esi_timer:%ld,p_portal->esi_timer); ! DEBUG_1 (isns_esi_debug &1, esi_interval:%i,p_portal->esi_interval); ! DEBUG_1 (isns_esi_debug &1, mytime:%ld,mytime); ! continue; ! } ! p_portal->esi_timer = mytime; ! p_portal->esiSent++; ! rval = ISNSdbWrite(&read_key,entry2); ! DEBUG_1 (isns_esi_debug &1, esi_timer Timer Expired esiSend:%i,p_portal->esiSent); ! ! if ( p_portal->esiSent < 4 ) { ! DEBUG_1 (isns_esi_debug & 2, (Sending ESI to Entity %s), p_portal->entity_id.id); ! /* Send a msg to the client & update the counter */ ! memset (&p_md->msg, 0, sizeof (ISNS_Msg)); ! p_md->msg.hdr.type = ISNS_ESI; ! ISNSAppendKey (&p_md->msg, ISNS_ENTITY_ID, ! PAD4 (strlen (p_portal->entity_id.id)), p_portal->entity_id.id, 0); ISNSAppendKey ( &p_md->msg, ISNS_PORTAL_IP, ISNS_IP_SIZE, *************** *** 178,205 **** sizeof (p_md->cb.sock.addr.sin_addr.s_addr)); - p_portal->esiSent++; - p_portal->esi_timer = p_portal->esi_interval; - - ISNS_Key key; - key.tag = PORTAL_ID_KEY; - memcpy(&key.val,p_esi_entry,sizeof(SOIP_DB_Portal)); - rval = ISNSdbWrite(&key,entry2); - /* Determine how to send */ - - /* Fetch the Portal */ - memset ( &db_portal, 0, sizeof (db_portal)); - memcpy ( db_portal.ip_addr.v, p_portal->ip_addr.v, ISNS_IP_SIZE); - db_portal.ip_port = p_portal->ip_port; - - ISNS_Key read_key; - read_key.tag = PORTAL_ID_KEY; - memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); - rval = ISNSdbRead(&read_key,&entry2); - if (rval != SUCCESS) - return rval; - - p_portal = (SOIP_Portal *)&entry2.data; - if ( p_portal->esi_port ) { --- 158,162 ---- *************** *** 215,231 **** } ! DEBUG_1 (isns_esi_debug & 2, (Sending ESI to Entity %s), lentry->eid.id); rval = ISNSSendMsg ( p_md ); } ! if ( rval != SUCCESS ) { ! ! /* TODO: FIX FIX */ ! /* Don't assume first entity */ ! pnode2 = GetNextNode( &p_portal->entity_list, NULL); ! lentry = (ENTITY_LIST_ENTRY *)GetNodeData(pnode2); ! ! strncpy (db_entity_id.id, lentry->eid.id, sizeof(db_entity_id.id) ); /* remove portal */ --- 172,184 ---- } ! DEBUG_1 (isns_esi_debug & 2, (Call ISNSSendMsg to Send ESI to Entity %s), p_portal->entity_id.id); rval = ISNSSendMsg ( p_md ); } ! else { ! DEBUG_0 (isns_esi_debug &1,esi timed out - remove portal record); ! DEBUG_1 (isns_esi_debug &1,portal ip_addr:%s,inet_ntoa(*(struct in_addr *)(p_portal->ip_addr.v+12)) ); ! DEBUG_1 (isns_esi_debug &1,port:%i,p_portal->ip_port); /* remove portal */ *************** *** 234,288 **** db_portal.ip_port=p_portal->ip_port; - p_esi_node=GetNextNode(&esi_list, p_esi_node); SNSRemovePortalEntry ((char *)&db_portal, NULL, NULL); - - /* Fetch Entity */ - ISNS_Key read_key; - read_key.tag = ENTITY_ID_KEY; - strcpy(read_key.val.entity_id.id,db_entity_id.id); - rval = ISNSdbRead(&read_key,&entry); - if (rval != SUCCESS) - return rval; - - p_entity = &entry.data.entity; - - /* Anymore Portals w/ ESI */ - more_esi_portals = FALSE; - pnode = NULL; - while ( (pnode = GetNextNode(&p_entity->iportal_list, pnode)) ) - { - /* Fetch Portal */ - ISNS_Key read_key; - read_key.tag = PORTAL_ID_KEY; - memcpy(&read_key.val,GetNodeData(pnode),sizeof(SOIP_DB_Portal)); - rval = ISNSdbRead(&read_key,&entry2); - if (rval != SUCCESS) - return rval; - - p_portal = (SOIP_Portal *)&entry2.data; - - if (p_portal->esi_interval != 0) - { - more_esi_portals = TRUE; - break; - } - } - - if ( !more_esi_portals ) - { - /* TODO: FIX FIX */ - /* Don't assume first entity */ - pnode2 = GetNextNode( &p_portal->entity_list, NULL); - lentry = (ENTITY_LIST_ENTRY *)GetNodeData(pnode2); - - /* remove entity */ - ISNSdbRemoveAttrEntityEntry (lentry->eid.id, NULL, NULL); - } } - else - { - p_esi_node = GetNextNode(&esi_list, p_esi_node); - } - } --- 187,192 ---- *************** *** 301,305 **** time_t mytime; SOIP_DB_Portal db_portal; - SOIP_Entity_Key db_entity_id = {{0}}; int i; int len; --- 205,208 ---- *************** *** 307,310 **** --- 210,214 ---- char *key_indx[SNS_MAX_ATTRS]; int rval; + ISNS_Key update_key; DEBUG_0 (isns_esi_debug &1, ISNS_ProcessESI); *************** *** 319,345 **** p_attr = (ISNS_Attr *)(key_indx[ i ]); ! /* Fetch Entity */ ! /* The first Attr should be entity */ ! if (SNSdbFetchEntity ((char *)&p_attr->val, &p_entity, &entry)) ! return ( ERROR ); /* Update the time stamp */ ! { ! len = sizeof (mytime); ! time ( &mytime ); ! p_entity->timestamp.t_pad = 0; ! p_entity->timestamp.t_time = mytime; ! /* printf( "Time in seconds since UTC 1/1/70:\t%ld\n", mytime ); */ ! /* printf( "UNIX time and date:\t\t\t%s", ctime( &mytime ) ); */ ! } /* Store Entry */ - strncpy(db_entity_id.id, (char *)&p_attr->val, sizeof(db_entity_id.id) ); - - ISNS_Key key; - key.tag = ENTITY_ID_KEY; - strcpy(key.val.entity_id.id,db_entity_id.id); ISNSdbWrite(&key,entry); /* Fetch the portal IP */ i = ISNSFindTag (0, ISNS_PORTAL_IP, key_indx); --- 223,248 ---- p_attr = (ISNS_Attr *)(key_indx[ i ]); ! ISNS_Key key; ! key.tag = ENTITY_ID_KEY; ! strcpy(key.val.entity_id.id,p_attr->val.entity_id.id); ! rval = ISNSdbRead(&key,&entry); ! if (rval != SUCCESS) ! return (ERROR); ! ! p_entity = &entry.data.entity; /* Update the time stamp */ ! len = sizeof (mytime); ! time ( &mytime ); ! p_entity->timestamp.t_pad = 0; ! p_entity->timestamp.t_time = mytime; ! DEBUG_1 (isns_esi_debug &1,(Time in seconds since UTC 1/1/70: %ld),mytime); ! DEBUG_1 (isns_esi_debug &1,(UNIX time and date: %s),ctime(&mytime) ); /* Store Entry */ ISNSdbWrite(&key,entry); + memset(&db_portal,0,sizeof(SOIP_DB_Portal)); + /* Fetch the portal IP */ i = ISNSFindTag (0, ISNS_PORTAL_IP, key_indx); *************** *** 350,354 **** } p_attr = (ISNS_Attr *)(key_indx[i]); - memcpy(db_portal.ip_addr.v, p_attr->val.ip_addr.v, ISNS_IP_SIZE); --- 253,256 ---- *************** *** 360,370 **** } p_attr = (ISNS_Attr *)(key_indx[i]); - db_portal.ip_port=p_attr->val.ip_port; ! ISNS_Key read_key; ! read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); ! rval = ISNSdbRead(&read_key,&entry); if (rval != SUCCESS) return rval; --- 262,270 ---- } p_attr = (ISNS_Attr *)(key_indx[i]); db_portal.ip_port=p_attr->val.ip_port; ! update_key.tag = PORTAL_ID_KEY; ! memcpy(&update_key.val,&db_portal,sizeof(SOIP_DB_Portal)); ! rval = ISNSdbRead(&update_key,&entry); if (rval != SUCCESS) return rval; *************** *** 374,380 **** p_portal->esiSent = 0; ! key.tag = PORTAL_ID_KEY; ! memcpy(&key.val,&db_portal,sizeof(SOIP_DB_Portal)); ! ISNSdbWrite(&key,entry); return ( ISNS_NO_ERR ); --- 274,279 ---- p_portal->esiSent = 0; ! /* Store Portal */ ! rval = ISNSdbWrite(&update_key,entry); return ( ISNS_NO_ERR ); Index: iSNSparse.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSparse.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** iSNSparse.c 13 Dec 2006 23:53:01 -0000 1.11 --- iSNSparse.c 14 Dec 2006 23:04:28 -0000 1.12 *************** *** 165,169 **** if (len != ISNS_IP_SIZE && len != 0) rval = FALSE; ! DEBUG_3 (sns_parse_debug &1,%sTag:%i (%s),src,tag,isnsTagText(tag)); break; --- 165,170 ---- if (len != ISNS_IP_SIZE && len != 0) rval = FALSE; ! DEBUG_4 (sns_parse_debug &1,%sTag:%i (%s) %s,src,tag,isnsTagText(tag), ! inet_ntoa(*(struct in_addr *)(ptr+12)) ); break; Index: iSNSdereg.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSdereg.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** iSNSdereg.c 13 Dec 2006 19:45:57 -0000 1.12 --- iSNSdereg.c 14 Dec 2006 23:04:28 -0000 1.13 *************** *** 81,85 **** extern uint32_t *dlist_node; /*[MAX_DD_PER_LIST];*/ - extern ISNS_LIST esi_list; extern ISNS_LIST scn_list; extern ISNS_LIST scn_callback_list; --- 81,84 ---- *************** *** 1246,1263 **** SOIP_Portal *p_portal; SOIP_Entity *p_entity; - SOIP_Entity_Key db_entity_id; int rval; ISNS_LIST_NODE *pnode; ISNS_LIST_NODE *pnode2; PORTAL_LIST_ENTRY portalListEntry; - ENTITY_LIST_ENTRY *p_lentry; char *p_iscsi_name; ! ISNS_Key delete_key; DEBUG_0 (isns_dereg_debug & 1, (Deregistering Portal)); - ISNS_Key read_key; read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&portal_key,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) --- 1245,1259 ---- SOIP_Portal *p_portal; SOIP_Entity *p_entity; int rval; ISNS_LIST_NODE *pnode; ISNS_LIST_NODE *pnode2; PORTAL_LIST_ENTRY portalListEntry; char *p_iscsi_name; ! ISNS_Key read_key; DEBUG_0 (isns_dereg_debug & 1, (Deregistering Portal)); read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,portal_key,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); if (rval != SUCCESS) *************** *** 1273,1301 **** */ ! /* Send detailed SCN */ ! pnode = NULL; ! while ( (pnode = GetNextNode( &p_portal->entity_list, pnode)) ) ! { ! p_lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! if ( SNSdbFetchEntity ((char *)p_lentry->eid.id, &p_entity, &entry) ) ! return ( ERROR ); ! ! if ( p_entity->eid_type != ENTITY_TYPE_ISCSI ) ! continue; ! ! pnode2 = NULL; ! while ( (pnode2 = GetNextNode( &p_entity->iscsi_node_list, pnode2)) ) ! { ! p_iscsi_name = (char *) GetNodeData( pnode2 ); ! send_scn_object_change_to_all( ISNS_ISCSI_NODE_ID, PAD4(strlen(p_iscsi_name)), p_iscsi_name, ! ISNS_SCN_OBJ_UPDATED); ! } ! } RemoveCert (&p_portal->ptr_cert); ! delete_key.tag = PORTAL_ID_KEY; ! memcpy(&delete_key.val,&portal_key,sizeof(SOIP_DB_Portal)); ! if ( ISNSdbDelete(&delete_key) != SUCCESS) { printf ("***ERROR: Portal DEREG Failed.\n"); --- 1269,1277 ---- */ ! DEBUG_0 (isns_dereg_debug &1,(Remove Cert)); RemoveCert (&p_portal->ptr_cert); ! if (ISNSdbDelete(&read_key) != SUCCESS) { printf ("***ERROR: Portal DEREG Failed.\n"); *************** *** 1303,1307 **** } - iSNS_stats.num_portals--; ISNS_Key remove_key; remove_key.tag = PORTAL_IDX_KEY; --- 1279,1282 ---- *************** *** 1310,1348 **** ISNSdbDelete(&remove_key); ! pnode2 = NULL; ! while ((pnode2 = GetNextNode(&p_portal->entity_list, pnode2))) ! { ! ENTITY_LIST_ENTRY *lentry; ! ! lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode2); ! /* Fetch Entity Entry */ ! memset (&db_entity_id, 0, sizeof (db_entity_id)); ! strncpy ((char *) db_entity_id.id, (char *) lentry->eid.id, sizeof(db_entity_id.id) ); ! ISNS_Key read_key; ! read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,db_entity_id.id); ! rval = ISNSdbRead(&read_key,&entry4); ! if (rval != SUCCESS) ! return rval; ! p_entity = &entry4.data.entity; ! /* Remove Portals */ ! memcpy(&portalListEntry.portal_ip_port, portal_key, sizeof(portalListEntry.portal_ip_port)); ! portalListEntry.portal_idx = p_portal->portal_index; ! pnode = NULL; ! if ((pnode=FindNode(&p_entity->iportal_list, (char *)&portalListEntry, sizeof (portalListEntry)))) ! { RemoveNode(&p_entity->iportal_list, pnode); ! } ! ISNS_Key key; ! key.tag = ENTITY_ID_KEY; ! strcpy(key.val.entity_id.id,db_entity_id.id); ! rval = ISNSdbWrite(&key,entry4); } return (rval); } --- 1285,1320 ---- ISNSdbDelete(&remove_key); ! iSNS_stats.num_portals--; ! read_key.tag = ENTITY_ID_KEY; ! strcpy(read_key.val.entity_id.id,p_portal->entity_id.id); ! rval = ISNSdbRead(&read_key,&entry4); ! if (rval != SUCCESS) ! return rval; ! p_entity = &entry4.data.entity; ! /* Remove Portals */ ! memcpy(&portalListEntry.portal_ip_port, portal_key, sizeof(portalListEntry.portal_ip_port)); ! portalListEntry.portal_idx = p_portal->portal_index; ! pnode = NULL; ! if ((pnode=FindNode(&p_entity->iportal_list, (char *)&portalListEntry, sizeof (portalListEntry)))) ! { RemoveNode(&p_entity->iportal_list, pnode); ! } ! rval = ISNSdbWrite(&read_key,entry4); ! ! /* Send detailed SCN */ ! pnode2 = NULL; ! while ( (pnode2 = GetNextNode( &p_entity->iscsi_node_list, pnode2)) ) ! { ! p_iscsi_name = (char *) GetNodeData( pnode2 ); ! send_scn_object_change_to_all( ISNS_ISCSI_NODE_ID, PAD4(strlen(p_iscsi_name)), p_iscsi_name, ! ISNS_SCN_OBJ_UPDATED); } + return (rval); } *************** *** 1736,1763 **** ********************************************************************/ int - ISNSRemoveESIEntry(IP_Address *p_ip, uint32_t port, char *p_eid) - { - SOIP_Esi_Entry new_entry; - ISNS_LIST_NODE *pnode; - - memset(&new_entry, 0, sizeof(new_entry)); - memcpy(new_entry.ip_addr.v, p_ip->v, IP_ADDR_SIZE); - new_entry.ip_port=port; - - if ( p_eid ) - strncpy(new_entry.eid.id, p_eid, sizeof(new_entry.eid.id) ); - - if (NULL==(pnode=FindNode(&esi_list, (char *)&new_entry, sizeof(new_entry)))) - { - return (ERROR); - } - - RemoveNode(&esi_list, pnode); - return (SUCCESS); - } - - /******************************************************************** - ********************************************************************/ - int ISNSRemoveSCNEntry(uint32_t type, char *nodename) { --- 1708,1711 ---- Index: iSNSreg.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSreg.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** iSNSreg.c 13 Dec 2006 23:53:01 -0000 1.12 --- iSNSreg.c 14 Dec 2006 23:04:28 -0000 1.13 *************** *** 76,80 **** extern uint32_t *dlist_node; /*[MAX_DD_PER_LIST];*/ - extern ISNS_LIST esi_list; extern ISNS_LIST scn_list; extern ISNS_LIST scn_callback_list; --- 76,79 ---- *************** *** 252,257 **** ISNS_LIST_NODE *pnode2; PORTAL_LIST_ENTRY newPortalEntry; - ENTITY_LIST_ENTRY newPortalEntityEntry; - ENTITY_LIST_ENTRY *p_lentry; char *p_iscsi_name; ISNS_Key read_key; --- 251,254 ---- *************** *** 378,383 **** DEBUG_1 (isns_reg_debug &1,(read portal:%s),db_portal.ip_addr.v); read_key.tag = PORTAL_ID_KEY; ! memcpy(read_key.val.ip_addr.v,db_portal.ip_addr.v,ISNS_PORTAL_IP_SIZE); ! read_key.val.ip_port = db_portal.ip_port; rval = ISNSdbRead(&read_key,&entry2); --- 375,379 ---- DEBUG_1 (isns_reg_debug &1,(read portal:%s),db_portal.ip_addr.v); read_key.tag = PORTAL_ID_KEY; ! memcpy(&read_key.val,&db_portal,sizeof(SOIP_DB_Portal)); rval = ISNSdbRead(&read_key,&entry2); *************** *** 386,390 **** if ( (rval == SUCCESS) && (p_md->msg.hdr.flags & ISNS_FLAG_REPLACE_REG) ) { ! DEBUG_0 (isns_reg_debug & 1, "Deregistering Portal.\n"); SNSRemovePortalEntry ((char *)&db_portal, NULL, NULL); rval = ERROR; --- 382,386 ---- if ( (rval == SUCCESS) && (p_md->msg.hdr.flags & ISNS_FLAG_REPLACE_REG) ) { ! DEBUG_0 (isns_reg_debug & 1,Deregistering Portal); SNSRemovePortalEntry ((char *)&db_portal, NULL, NULL); rval = ERROR; *************** *** 424,428 **** rval = ISNSdbWrite(&idx_key,entry3); - InitList(PORTAL_ENTITY_LIST, p_portal); /* Update Entity's portal Bitmap */ eidKeyIndex = ISNSFindTag (0, ISNS_ENTITY_ID, key_indx); --- 420,423 ---- *************** *** 431,442 **** { attr = ISNSFindKeyInResponseMsg (ISNS_ENTITY_ID, p_rspmsg); - - if (attr == NULL) - { - DEBUG_0 (isns_reg_debug & 1, (Entity Key not found)); - DeleteList(&p_portal->entity_list); - - return (ISNS_INVALID_REG_ERR); - } } else --- 426,429 ---- *************** *** 448,453 **** do { - strncpy(db_entity_id.id, (char *)&attr->val, sizeof(db_entity_id.id)); DEBUG_0 (isns_reg_debug &1,Fetch entity); read_key.tag = ENTITY_ID_KEY; strcpy(read_key.val.entity_id.id,db_entity_id.id); --- 435,441 ---- do { DEBUG_0 (isns_reg_debug &1,Fetch entity); + strncpy(db_entity_id.id, (char *)&attr->val, sizeof(db_entity_id.id)); + ISNS_Key read_key; read_key.tag = ENTITY_ID_KEY; strcpy(read_key.val.entity_id.id,db_entity_id.id); *************** *** 456,464 **** if ( rval != SUCCESS) { ! DEBUG_0 (isns_reg_debug & 1, (Fetching Entity)); ! ! if (newPortalRegFlag) ! DeleteList(&p_portal->entity_list); ! return (ISNS_INVALID_REG_ERR); } --- 444,449 ---- if ( rval != SUCCESS) { ! DEBUG_0 (isns_reg_debug & 1, Error Fetching Entity); ! return (ERROR); } *************** *** 488,502 **** } ! memset(&newPortalEntityEntry, 0, sizeof(newPortalEntityEntry)); ! newPortalEntityEntry.entity_index = p_entity->entity_index; ! strncpy(newPortalEntityEntry.eid.id, p_entity->eid.id, sizeof(newPortalEntityEntry.eid.id)); ! ! pnode = NULL; ! if (!(pnode = FindNode( &p_portal->entity_list, (char *)&newPortalEntityEntry, ! sizeof(newPortalEntityEntry)))) ! { ! AddNode( &p_portal->entity_list, (char *)&newPortalEntityEntry, ! sizeof(newPortalEntityEntry)); ! } if (eidKeyIndex!=-1) --- 473,478 ---- } ! strcpy(p_portal->entity_id.id,p_entity->eid.id); ! p_portal->entity_index = p_entity->entity_index; if (eidKeyIndex!=-1) *************** *** 547,568 **** newPortalEntry.portal_idx = p_portal->portal_index; AddNode(&p_entity->iportal_list, (char *)&newPortalEntry, sizeof(newPortalEntry)); ! ! memset(&newPortalEntityEntry, 0, sizeof(newPortalEntityEntry)); ! newPortalEntityEntry.entity_index = p_entity->entity_index; ! strncpy(newPortalEntityEntry.eid.id, p_entity->eid.id, sizeof(newPortalEntityEntry.eid.id)); ! ! pnode = NULL; ! if (!(pnode = FindNode( &p_portal->entity_list, (char *)&newPortalEntityEntry, ! sizeof(newPortalEntityEntry)))) ! { ! AddNode( &p_portal->entity_list, (char *)&newPortalEntityEntry, ! sizeof(newPortalEntityEntry)); ! } /* Store Entity Entry */ ! strncpy(db_entity_id.id, (char *)&attr->val, sizeof(db_entity_id.id)); ! //ISNS_Key key; ! //key.tag = ENTITY_ID_KEY; ! //strcpy(key.val.entity_id.id,db_entity_id.id); rval = ISNSdbWrite(&read_key,entry); } --- 523,530 ---- newPortalEntry.portal_idx = p_portal->portal_index; AddNode(&p_entity->iportal_list, (char *)&newPortalEntry, sizeof(newPortalEntry)); ! strcpy(p_portal->entity_id.id,p_entity->eid.id); /* Store Entity Entry */ ! //strncpy(db_entity_id.id, (char *)&attr->val, sizeof(db_entity_id.id)); rval = ISNSdbWrite(&read_key,entry); } *************** *** 606,612 **** p_portal->esi_interval, sns_esi_interval); ! if (newPortalRegFlag) ! DeleteList(&p_portal->entity_list); ! return ( ISNS_ESI_TOO_SHORT ); } updateESIflag = TRUE; --- 568,572 ---- p_portal->esi_interval, sns_esi_interval); ! p_portal->esi_interval = sns_esi_interval; } updateESIflag = TRUE; *************** *** 656,690 **** p_portal->esi_sockfd=p_md->cb.sock.sockfd; } - - pnode = NULL; - if (p_portal->esi_interval) - ISNSAddESIEntry(&p_portal->ip_addr, p_portal->ip_port, NULL); - else - ISNSRemoveESIEntry(&p_portal->ip_addr, p_portal->ip_port, NULL); - } - - #if 0 - if (newPortalRegFlag) - { - /* Update the entity */ - strcpy (p_portal->eid.id, p_entity->eid.id); - - /* Store Entity Entry */ } - #endif /* Send Out Detailed SCN */ if (newPortalRegFlag || updateFlag) { ! pnode = NULL; ! while ( (pnode = GetNextNode( &p_portal->entity_list, pnode)) ) ! { ! p_lentry = (ENTITY_LIST_ENTRY *) GetNodeData(pnode); ! if ( SNSdbFetchEntity ((char *)p_lentry->eid.id, &p_entity, &entry) ) return ( ERROR ); - if ( p_entity->eid_type != ENTITY_TYPE_ISCSI ) - continue; - pnode2 = NULL; while ( (pnode2 = GetNextNode( &p_entity->iscsi_node_list, pnode2)) ) --- 616,627 ---- p_portal->esi_sockfd=p_md->cb.sock.sockfd; } } /* Send Out Detailed SCN */ if (newPortalRegFlag || updateFlag) { ! if ( SNSdbFetchEntity ((char *)p_portal->entity_id.id, &p_entity, &entry) ) return ( ERROR ); pnode2 = NULL; while ( (pnode2 = GetNextNode( &p_entity->iscsi_node_list, pnode2)) ) *************** *** 694,698 **** ISNS_SCN_OBJ_UPDATED); } - } } --- 631,634 ---- *************** *** 2896,2922 **** ********************************************************************/ int - ISNSAddESIEntry(IP_Address *p_ip, uint32_t port, char *p_eid) - { - SOIP_Esi_Entry new_entry; - - memset (&new_entry, 0, sizeof(new_entry)); - - memcpy(new_entry.ip_addr.v, p_ip->v, IP_ADDR_SIZE); - new_entry.ip_port=port; - if (p_eid) - strncpy(new_entry.eid.id, p_eid, sizeof(new_entry.eid.id) ); - - if (NULL==FindNode(&esi_list, (char *)&new_entry, sizeof(new_entry))) - { - AddNode(&esi_list, (char *)&new_entry, sizeof(new_entry)); - } - - return (SUCCESS); - } - - - /******************************************************************** - ********************************************************************/ - int ISNSAddSCNEntry( uint32_t type, char *nodename, uint32_t bitmap, int sockfd ) { --- 2832,2835 ---- Index: iSNSdb.c =================================================================== RCS file: /cvsroot/linuxisns/isnsNT/isnsserver/src/iSNSdb.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** iSNSdb.c 8 Dec 2006 20:05:50 -0000 1.17 --- iSNSdb.c 14 Dec 2006 23:04:28 -0000 1.18 *************** *** 83,87 **** SOIP_Dd_Member *ddmem; /* [100]; */ - ISNS_LIST esi_list; ISNS_LIST scn_list; ISNS_LIST scn_callback_list; --- 83,86 ---- *************** *** 204,207 **** --- 203,212 ---- break; case PORTAL_ID_KEY: + { + SOIP_DB_Portal db_portal; + memcpy(&db_portal,&key->val,sizeof(SOIP_DB_Portal)); + DEBUG_2 (isns_db_debug &1,read Portal ip_addr:%s port:%i, + inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); + k.dptr = (char *)&key->val; k.dsize = sizeof(SOIP_DB_Portal); *************** *** 209,219 **** if (d.dptr == NULL) { ! DEBUG_1 (isns_db_debug & 1, (read failed Portal port:%i),key->val.ip_port); return (ISNS_NO_SUCH_ENTRY_ERR); } if (entry->data_type != PORTAL_ID_KEY) return (ISNS_UNKNOWN_ERR); - entry->data.portal.entity_list.p_entry = &entry->data.portal; break; case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: --- 214,225 ---- if (d.dptr == NULL) { ! DEBUG_2 (isns_db_debug &1,read failed Portal ip_addr:%s port:%i, ! inet_ntoa(*(struct in_addr *)(db_portal.ip_addr.v+12)),db_portal.ip_port); return (ISNS_NO_SUCH_ENTRY_ERR); } if (entry->data_type != PORTAL_ID_KEY) return (ISNS_UNKNOWN_ERR); break; + } case ENTITY_IDX_KEY: case ISCSI_IDX_KEY: *************** *** 265,269 **** k.dsize = 4 + LIST_KEY_SIZE; break; - case ESI_LIST: case SCN_LIST: case SCN_CALLBACK_LIST: --- 271,274 ---- *************** *** 406,410 **** k.dsize = 4 + LIST_KEY_SIZE; break; - case ESI_LIST: case SCN_LIST: case SCN_CALLBACK_LIST: --- 411,414 ---- *************** *** 532,536 **** k.dsize = 4 + LIST_KEY_SIZE; break; - case ESI_LIST: case SCN_LIST: case SCN_CALLBACK_LIST: --- 536,539 ---- *************** *** 858,862 **** { DEBUG_0 (isns_db_debug &1, ISNSInitDBTables); - InitList(ESI_LIST, &esi_list); InitList(SCN_LIST, &scn_list ); InitList(SCN_CALLBACK_LIST, &scn_callback_list); --- 861,864 ---- |