/* * []---- * | modify_admin -- modify one or more of the admin related props * []---- */ static char * modify_admin(tgt_node_t *x) { char *msg = NULL; char *prop; Boolean_t changes_made = False; Boolean_t update_isns = False; admin_table_t *ap; for (ap = admin_prop_list; ap->name; ap++) { if (tgt_find_value_str(x, ap->name, &prop) == True) { if ((prop == NULL) || (strlen(prop) == 0)) break; /* * Do the function call first if it exists which * will allow possible checking to be done first. */ if (ap->func) { msg = (*ap->func)(ap->name, prop); if (msg != NULL) { free(prop); return (msg); } } (void) pthread_rwlock_wrlock(&targ_config_mutex); if (ap->delete_name == NULL) { if (modify_element(ap->name, prop, main_config, MatchName) == False) { xml_rtn_msg(&msg, ERR_NO_MEM); free(prop); (void) pthread_rwlock_unlock( &targ_config_mutex); return (msg); } } else { if (strcmp(prop, XML_VALUE_TRUE) != 0) { xml_rtn_msg(&msg, ERR_SYNTAX_MISSING_OPERAND); free(prop); (void) pthread_rwlock_unlock( &targ_config_mutex); return (msg); } if (delete_element(ap->delete_name, main_config, MatchName) == False) { xml_rtn_msg(&msg, ERR_NO_MEM); free(prop); (void) pthread_rwlock_unlock( &targ_config_mutex); return (msg); } } (void) pthread_rwlock_unlock(&targ_config_mutex); if (0 == strcmp(ap->name, XML_ELEMENT_ISNS_ACCESS) || 0 == strcmp(ap->name, XML_ELEMENT_ISNS_SERV)) { update_isns = True; } free(prop); changes_made = True; } } if (changes_made == True) { /* isns_update updates isns_access & isns server name */ if (update_isns == True) { if (isns_update() != 0) { xml_rtn_msg(&msg, ERR_ISNS_ERROR); return (msg); } } if (mgmt_config_save2scf() == True) { xml_rtn_msg(&msg, ERR_SUCCESS); } else { xml_rtn_msg(&msg, ERR_INTERNAL_ERROR); } } else { xml_rtn_msg(&msg, ERR_SYNTAX_MISSING_OPERAND); } return (msg); }
/* * process_scn() * -Added/Updated object: nop, initiator is verified during connect * * -Removed object: logout_targ if still connected * * RFC 4171 section 5.6.5.9 * destination attribute is always the 1st attribute in the SCN message, * then follows by SCN_BITMAP(35) & Source_Attribute(32) */ static void process_scn(int so, isns_pdu_t *scn) { uint8_t *ptr = scn->payload; isns_tlv_t *tlv; uint16_t cnt = 0; uint32_t got_dest = 0; uint32_t got_source = 0; uint32_t bitmap = 0; uint32_t got_bitmap = 0; char dest[MAXNAMELEN]; char source[MAXNAMELEN]; queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN %u\n", scn->payload_len); if (scn->payload_len < TAG_LEN_SZ) { syslog(LOG_ALERT, "ISNS SCN message error\n"); return; } while (cnt < scn->payload_len) { /* LINTED */ tlv = (isns_tlv_t *)ptr; tlv->attr_id = ntohl(tlv->attr_id); tlv->attr_len = ntohl(tlv->attr_len); queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN %u %u\n", tlv->attr_id, tlv->attr_len); /* * devAttrQry the source attribute, process if node_type * is initiator */ switch (tlv->attr_id) { case ISNS_ISCSI_NAME_ATTR_ID: if (got_dest == 0) { bcopy(tlv->attr_value, dest, tlv->attr_len); queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN dest %s\n", dest); got_dest = 1; } else { bcopy(tlv->attr_value, source, tlv->attr_len); queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN source %s\n", source); got_source = 1; } break; case ISNS_ISCSI_SCN_BITMAP_ATTR_ID: bcopy(tlv->attr_value, &bitmap, tlv->attr_len); bitmap = ntohl(bitmap); queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN bitmap %u\n", bitmap); got_bitmap = 1; break; default: queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN DEFAULT\n"); break; } if (got_source && !got_bitmap) { queue_prt(mgmtq, Q_ISNS_DBG, "process_scn: message out-of-order\n"); return; } if (got_source && got_bitmap) { switch (bitmap) { case ISNS_OBJ_ADDED: case ISNS_OBJ_UPDATED: queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN OBJ ADDED"); (void) isns_update(); break; case ISNS_OBJ_REMOVED: queue_prt(mgmtq, Q_ISNS_DBG, "PROCESS_SCN OBJ REMOVED"); /* logout target */ if (got_dest == 0) { syslog(LOG_ALERT, "ISNS protocol error\n"); continue; } logout_targ(dest); break; default: break; } /* clear got_xxx */ got_source = 0; got_bitmap = 1; } /* next attribute */ cnt += ISNS_ATTR_SZ(tlv->attr_len); ptr += ISNS_ATTR_SZ(tlv->attr_len); } queue_prt(mgmtq, Q_ISNS_DBG, "DONE PROCESS_SCN\n"); }