/**
 * Dispatch admin operation requests to the real handler
 * @param cb
 * @param evt
 * 
 * @return uns32
 */
uns32 avnd_evt_avd_admin_op_req_evh(AVND_CB *cb, AVND_EVT *evt)
{
	uns32 rc = NCSCC_RC_FAILURE;
	AVSV_D2N_ADMIN_OP_REQ_MSG_INFO *info = &evt->info.avd->msg_info.d2n_admin_op_req_info;

	TRACE_ENTER2("%u", info->class_id);

	switch (info->class_id) {
	case AVSV_SA_AMF_NODE:
		rc = avnd_evt_node_admin_op_req(cb, evt);
		break;
	case AVSV_SA_AMF_COMP:
		rc = avnd_evt_comp_admin_op_req(cb, evt);
		break;
	case AVSV_SA_AMF_SU:
		rc = avnd_evt_su_admin_op_req(cb, evt);
		break;
	default:
		LOG_NO("%s: unsupported adm op for class %u", __FUNCTION__, info->class_id);
		break;
	}

	TRACE_LEAVE();
	return rc;
}
Exemple #2
0
/****************************************************************************
 * Name          : eds_proc_unsubscribe_msg
 *
 * Description   : This is the function which is called when eds receives a
 *                 EDSV_EDA_UNSUBSCRIBE message.
 *
 * Arguments     : msg  - Message that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_unsubscribe_msg(EDS_CB *cb, EDSV_EDS_EVT *evt)
{
	uint32_t rc = NCSCC_RC_SUCCESS;
	uint32_t async_rc = NCSCC_RC_SUCCESS;
	EDSV_EDA_UNSUBSCRIBE_PARAM *unsubscribe_param;
	EDS_CKPT_DATA ckpt;
	TRACE_ENTER2("agent dest: %" PRIx64, evt->fr_dest);

	unsubscribe_param = &(evt->info.msg.info.api_info.param.unsubscribe);
	/* Remove subscription from our lists */
	rc = eds_remove_subscription(cb,
				     unsubscribe_param->reg_id,
				     unsubscribe_param->chan_id,
				     unsubscribe_param->chan_open_id, unsubscribe_param->sub_id);
	if (rc == NCSCC_RC_SUCCESS) {
		/* Send an async checkpoint update to STANDBY EDS */
		if (cb->ha_state == SA_AMF_HA_ACTIVE) {
			memset(&ckpt, 0, sizeof(ckpt));
			m_EDSV_FILL_ASYNC_UPDATE_UNSUBSCRIBE(ckpt, unsubscribe_param)
			async_rc = send_async_update(cb, &ckpt, NCS_MBCSV_ACT_ADD);
			if (async_rc != NCSCC_RC_SUCCESS)
				TRACE("Async Update send failed for unsubscribe");
		}
	} else
		rc = NCSCC_RC_FAILURE;

	TRACE_LEAVE();
	return rc;
}
void ntfsv_dealloc_notification(ntfsv_send_not_req_t *param)
{
	TRACE_ENTER2("ntfsv_send_not_req_t ptr = %p " "notificationType = %#x", param, (int)param->notificationType);
	switch (param->notificationType) {
	case SA_NTF_TYPE_ALARM:
		ntfsv_free_alarm(&param->notification.alarm, true);
		break;
	case SA_NTF_TYPE_OBJECT_CREATE_DELETE:
		ntfsv_free_obj_create_del(&param->notification.objectCreateDelete, true);
		break;
	case SA_NTF_TYPE_ATTRIBUTE_CHANGE:
		ntfsv_free_attribute_change(&param->notification.attributeChange, true);
		break;
	case SA_NTF_TYPE_STATE_CHANGE:
		ntfsv_free_state_change(&param->notification.stateChange, true);
		break;
	case SA_NTF_TYPE_SECURITY_ALARM:
		ntfsv_free_security_alarm(&param->notification.securityAlarm, true);
		break;
	default:
		TRACE("notificationType not valid");
	}
	TRACE_1("free v_data.p_base %p", param->variable_data.p_base);
	free(param->variable_data.p_base);
	param->variable_data.p_base = NULL;
	param->variable_data.size = 0;
	TRACE_LEAVE();
}
void client_added_res_lib(SaAisErrorT error, unsigned int clientId, MDS_DEST mdsDest, MDS_SYNC_SND_CTXT *mdsCtxt)
{
	uns32 rc;
	ntfsv_msg_t msg;
	ntfsv_ckpt_msg_t ckpt;
	TRACE_ENTER2("clientId: %u, rv: %u", clientId, error);
	msg.type = NTFSV_NTFA_API_RESP_MSG;
	msg.info.api_resp_info.type = NTFSV_INITIALIZE_RSP;
	msg.info.api_resp_info.rc = error;
	msg.info.api_resp_info.param.init_rsp.client_id = clientId;
	rc = ntfs_mds_msg_send(ntfs_cb, &msg, &mdsDest, mdsCtxt, MDS_SEND_PRIORITY_HIGH);
	if (rc != NCSCC_RC_SUCCESS) {
		TRACE_LEAVE2("ntfs_mds_msg_send FAILED rc = %u", (unsigned int)rc);
		return;
	}

	if (error == SA_AIS_OK) {
		memset(&ckpt, 0, sizeof(ckpt));
		ckpt.header.ckpt_rec_type = NTFS_CKPT_INITIALIZE_REC;
		ckpt.header.num_ckpt_records = 1;
		ckpt.header.data_len = 1;
		ckpt.ckpt_rec.reg_rec.client_id = clientId;
		ckpt.ckpt_rec.reg_rec.mds_dest = mdsDest;
		update_standby(&ckpt, NCS_MBCSV_ACT_ADD);
	}
	TRACE_LEAVE();
}
Exemple #5
0
/****************************************************************************
 * Name          : amf_quiesced_state_handler
 *
 * Description   : This function is called upon receving an Quiesced state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the LGS control block. 
 *
 * Return Values : None
 *
 * Notes         : None
 *****************************************************************************/
static SaAisErrorT amf_quiesced_state_handler(lgs_cb_t *cb, SaInvocationT invocation)
{
	V_DEST_RL mds_role;
	SaAisErrorT rc = SA_AIS_OK;

	TRACE_ENTER2("HA AMF QUIESCED STATE request");
	close_all_files();

	/* Give up our IMM OI implementer role */
	immutilWrapperProfile.errorsAreFatal = 0;
	(void)immutil_saImmOiImplementerClear(cb->immOiHandle);
	immutilWrapperProfile.errorsAreFatal = 1;

	/*
	 ** Change the MDS VDSET role to Quiesced. Wait for MDS callback with type
	 ** MDS_CALLBACK_QUIESCED_ACK. Then change MBCSv role. Don't change
	 ** cb->ha_state now.
	 */

	mds_role = cb->mds_role;
	cb->mds_role = V_DEST_RL_QUIESCED;
	if ((rc = lgs_mds_change_role(cb)) != NCSCC_RC_SUCCESS) {
		LOG_ER("lgs_mds_change_role FAILED");
		rc = SA_AIS_ERR_FAILED_OPERATION;
		cb->mds_role = mds_role;
		goto done;
	}

	cb->amf_invocation_id = invocation;
	cb->is_quiesced_set = true;
done:
	return rc;
}
/****************************************************************************
 * Name          : amf_standby_state_handler
 *
 * Description   : This function is called upon receving an standby state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the NTFS control block. 
 *
 * Return Values : None
 *
 * Notes         : None
 *****************************************************************************/
static SaAisErrorT amf_standby_state_handler(SaInvocationT invocation)
{
	TRACE_ENTER2("HA STANDBY request");
	ntfs_cb->mds_role = V_DEST_RL_STANDBY;
	TRACE_LEAVE();
	return SA_AIS_OK;
}
/****************************************************************************
  Name          : avnd_su_curr_info_del
 
  Description   : This routine deletes the dynamic info associated with this 
                  SU. This includes deleting the dynamic info for all it's 
                  components. If the SU is marked failed, the error 
                  escalation parameters are retained.
 
  Arguments     : cb - ptr to the AvND control block
                  su - ptr to the su
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : SIs associated with this SU are not deleted.
******************************************************************************/
uns32 avnd_su_curr_info_del(AVND_CB *cb, AVND_SU *su)
{
	AVND_COMP *comp = 0;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("'%s'", su->name.value);

	/* reset err-esc param & oper state (if su is healthy) */
	if (!m_AVND_SU_IS_FAILED(su)) {
		su->su_err_esc_level = AVND_ERR_ESC_LEVEL_0;
		su->comp_restart_cnt = 0;
		su->su_restart_cnt = 0;
		m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_CONFIG);
		/* stop su_err_esc_tmr TBD Later */

		/* disable the oper state (if pi su) */
		if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
			m_AVND_SU_OPER_STATE_SET(su, SA_AMF_OPERATIONAL_DISABLED);
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_OPER_STATE);
		}
	}

	/* scan & delete the current info store in each component */
	for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
	     comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
		rc = avnd_comp_curr_info_del(cb, comp);
		if (NCSCC_RC_SUCCESS != rc)
			goto done;
	}

 done:
	TRACE_LEAVE2("%u", rc);
	return rc;
}
static uns32 avnd_node_oper_req(AVND_CB *cb, AVSV_PARAM_INFO *param)
{
	uns32 rc = NCSCC_RC_FAILURE;

	TRACE_ENTER2("'%s'", param->name.value);

	switch (param->act) {
	case AVSV_OBJ_OPR_MOD:
		switch (param->attr_id) {
		case saAmfNodeSuFailoverProb_ID:
			assert(sizeof(SaTimeT) == param->value_len);
			cb->su_failover_prob = m_NCS_OS_NTOHLL_P(param->value);
			break;
		case saAmfNodeSuFailoverMax_ID:
			assert(sizeof(uns32) == param->value_len);
			cb->su_failover_max = m_NCS_OS_NTOHL(*(uns32 *)(param->value));
			break;
		default:
			LOG_NO("%s: Unsupported attribute %u", __FUNCTION__, param->attr_id);
			goto done;
		}
		break;
		
	default:
		LOG_NO("%s: Unsupported action %u", __FUNCTION__, param->act);
		goto done;
	}

	rc = NCSCC_RC_SUCCESS;

done:
	TRACE_LEAVE();
	return rc;
}
/****************************************************************************\
 * Function: avnd_dequeue_async_update_msgs
 *
 * Purpose:  De-queue async update messages.
 *
 * Input: cb - AVND CB pointer.
 *        pr_or_fr - TRUE - If we have to process the message.
 *                   FALSE - If we have to FREE the message.
 *
 * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * NOTES:
 *
 * 
\**************************************************************************/
uns32 avnd_dequeue_async_update_msgs(AVND_CB *cb, NCS_BOOL pr_or_fr)
{
	uns32 status = NCSCC_RC_SUCCESS;
	AVND_ASYNC_UPDT_MSG_QUEUE *updt_msg;

	TRACE_ENTER2("%u",pr_or_fr);

	/*
	 * This is a FIFO queue. Remove first message first entered in the 
	 * queue and then process it.
	 */
	while (NULL != (updt_msg = cb->async_updt_msgs.async_updt_queue)) {
		cb->async_updt_msgs.async_updt_queue = updt_msg->next;

		/*
		 * Process de-queued message.
		 */
		if (pr_or_fr)
			status = avnd_dec_ckpt_data_func_list[updt_msg->dec.i_reo_type] (cb, &updt_msg->dec);

		free(updt_msg);
	}

	/* All messages are dequeued. Set tail to NULL */
	cb->async_updt_msgs.tail = NULL;

	TRACE_LEAVE();
	return status;
}
static SaAisErrorT cluster_ccb_completed_cb(CcbUtilOperationData_t *opdata)
{
	SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;

	TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value);

	switch (opdata->operationType) {
	case CCBUTIL_CREATE:
		LOG_ER("SaAmfCluster objects cannot be created");
		goto done;
		break;
	case CCBUTIL_MODIFY:
		rc = ccb_completed_modify_hdlr(opdata);
		break;
	case CCBUTIL_DELETE:
		LOG_ER("SaAmfCluster objects cannot be deleted");
		goto done;
		break;
	default:
		assert(0);
		break;
	}

 done:
	return rc;
}
/****************************************************************************
  Name          : avnd_mds_red_send
 
  Description   : This routine sends the mds message to specified AvD.
 
  Arguments     : cb       - ptr to the AvND control block
                  msg      - ptr to the message
                  dest     - ptr to the MDS destination
                  adest    - ptr to the MDS adest(anchor) 
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : This funtion as of now is only used to send the ACK-NACK msg
                  to AvD. This funtion is introduced to overcome the problem
                  of MDS dropping a msg when the role has changed but MDS in 
                  AvND has not updated its tables about the role change.
                  Due to this problem MDS will try to send the msg to old
                  active which may not be there in the system and hence the
                  msg will be dropped.
                  With this funtion we are sending msg to the new active AvD
                  directly, without looking for its MDS role as seen by AvND. 
******************************************************************************/
uns32 avnd_mds_red_send(AVND_CB *cb, AVND_MSG *msg, MDS_DEST *dest, MDS_DEST *adest)
{
	NCSMDS_INFO mds_info;
	MDS_SEND_INFO *send_info = &mds_info.info.svc_send;
	MDS_SENDTYPE_RED_INFO *send = &send_info->info.red;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Msg type '%u'", msg->type);

	/* populate the mds params */
	memset(&mds_info, 0, sizeof(NCSMDS_INFO));

	mds_info.i_mds_hdl = cb->mds_hdl;
	mds_info.i_svc_id = NCSMDS_SVC_ID_AVND;
	mds_info.i_op = MDS_SEND;

	send_info->i_msg = (NCSCONTEXT)msg;
	send_info->i_priority = MDS_SEND_PRIORITY_MEDIUM;

	/* this is be used only for ACK NACK for AVD */
	if (msg->type != AVND_MSG_AVD)
		assert(0);

	send_info->i_to_svc = NCSMDS_SVC_ID_AVD;
	send_info->i_sendtype = MDS_SENDTYPE_RED;
	send->i_to_vdest = *dest;
	send->i_to_anc = *adest;	/* assumption-:ADEST is same as anchor */

	/* send the message */
	rc = ncsmds_api(&mds_info);
	if (NCSCC_RC_SUCCESS != rc)
		LOG_CR("AVND MDS send failed: Msg type = %u, vdest = %llu, anchor = %llu",msg->type,send->i_to_vdest,send->i_to_anc);

	TRACE_LEAVE2("rc '%u'", rc);
	return rc;
}
Exemple #12
0
/****************************************************************************
 * Name          : amf_active_state_handler
 *
 * Description   : This function is called upon receving an active state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the SMFD control block. 
 *
 * Return Values : None
 *
 * Notes         : None 
 *****************************************************************************/
static SaAisErrorT amf_active_state_handler(smfd_cb_t * cb,
					    SaInvocationT invocation)
{
	SaAisErrorT rc = SA_AIS_OK;
	TRACE_ENTER2("HA ACTIVE request");
	cb->mds_role = V_DEST_RL_ACTIVE;

        //Initialize the OI handle and get the selection object
        if (campaign_oi_init(cb) != NCSCC_RC_SUCCESS) {
                LOG_ER("campaign_oi_init FAIL");
		rc = SA_AIS_ERR_FAILED_OPERATION;
        }

	//Read SMF configuration data and set cb data structure
	if (read_config_and_set_control_block(cb) != NCSCC_RC_SUCCESS) {
		LOG_ER("read_config_and_set_control_block FAIL");
		rc = SA_AIS_ERR_FAILED_OPERATION;
	}

        //Set class implementers, recreate campaign objects and start callbackUtil thread
	if (campaign_oi_activate(cb) != NCSCC_RC_SUCCESS) {
		LOG_ER("amf_active_state_handler oi activate FAIL");
		rc = SA_AIS_ERR_FAILED_OPERATION;
	}

	TRACE_LEAVE();
	return rc;
}
Exemple #13
0
/****************************************************************************
  Name          : ava_hdl_cbk_rec_prc
 
  Description   : This routine invokes the registered callback routine.
 
  Arguments     : cb      - ptr to the AvA control block
                  hdl_rec - ptr to the hdl rec
                  cbk_rec - ptr to the callback record
 
  Return Values : None
 
  Notes         : It may so happen that the callbacks that are dispatched may 
                  finalize on the amf handle. Release AMF handle to the handle
                  manager before dispatching. Else Finalize blocks while 
                  destroying the association with handle manager.
******************************************************************************/
void ava_hdl_cbk_rec_prc(AVSV_AMF_CBK_INFO *info, SaAmfCallbacksT *reg_cbk)
{
	TRACE_ENTER2("CallbackType = %d",info->type);

	/* invoke the corresponding callback */
	switch (info->type) {
	case AVSV_AMF_HC:
		{
			AVSV_AMF_HC_PARAM *hc = &info->param.hc;
			if (reg_cbk->saAmfHealthcheckCallback) {
				hc->comp_name.length = hc->comp_name.length;
				TRACE("Invoking Healthcheck Callback:\
					InvocationId = %llx, Component Name =  %s, Healthcheck Key = %s",
					info->inv, hc->comp_name.value, hc->hc_key.key);
				reg_cbk->saAmfHealthcheckCallback(info->inv, &hc->comp_name, &hc->hc_key);
			}
		}
		break;

	case AVSV_AMF_COMP_TERM:
		{
			AVSV_AMF_COMP_TERM_PARAM *comp_term = &info->param.comp_term;

			if (reg_cbk->saAmfComponentTerminateCallback) {
				comp_term->comp_name.length = comp_term->comp_name.length;
				TRACE("Invoking component's saAmfComponentTerminateCallback: InvocationId = %llx,\
					 component name = %s",info->inv, comp_term->comp_name.value);
				reg_cbk->saAmfComponentTerminateCallback(info->inv, &comp_term->comp_name);
			}
		}
Exemple #14
0
/****************************************************************************
 * Name          : amf_quiescing_state_handler
 *
 * Description   : This function is called upon receving an Quiescing state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the SMFD control block. 
 *
 * Return Values : None
 *
 * Notes         : None
 *****************************************************************************/
static SaAisErrorT amf_quiescing_state_handler(smfd_cb_t * cb,
					       SaInvocationT invocation)
{
	TRACE_ENTER2("HA QUIESCING request");

	return saAmfCSIQuiescingComplete(cb->amf_hdl, invocation, SA_AIS_OK);
}
/**
 * 
 * 
 * @return unsigned int
 */
unsigned int ntfa_startup(void)
{
	unsigned int rc = NCSCC_RC_SUCCESS;
	pthread_mutex_lock(&ntfa_lock);

	TRACE_ENTER2("ntfa_use_count: %u", ntfa_use_count);
	if (ntfa_use_count > 0) {
		/* Already created, just increment the use_count */
		ntfa_use_count++;
		goto done;
	} else {
		if ((rc = ncs_agents_startup()) != NCSCC_RC_SUCCESS) {
			TRACE("ncs_agents_startup FAILED");
			goto done;
		}

		if ((rc = ntfa_create()) != NCSCC_RC_SUCCESS) {
			ncs_agents_shutdown();
			goto done;
		} else
			ntfa_use_count = 1;
	}

 done:
	pthread_mutex_unlock(&ntfa_lock);
	TRACE_LEAVE2("rc: %u, ntfa_use_count: %u", rc, ntfa_use_count);
	return rc;
}
Exemple #16
0
/****************************************************************************
 * Name          : eds_proc_chan_unlink_msg
 *
 * Description   : This is the function which is called when eds receives a
 *                 EDSV_EDA_CHAN_UNLINK message.
 *
 * Arguments     : msg  - Message that was posted to the EDS Mail box.
 *
 * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 *
 * Notes         : None.
 *****************************************************************************/
static uint32_t eds_proc_chan_unlink_msg(EDS_CB *cb, EDSV_EDS_EVT *evt)
{
	uint32_t rc = NCSCC_RC_SUCCESS, rs = NCSCC_RC_SUCCESS, async_rc = NCSCC_RC_SUCCESS;
	EDSV_EDA_CHAN_UNLINK_PARAM *unlink_param;
	EDSV_MSG msg;
	EDS_CKPT_DATA ckpt;
	TRACE_ENTER2("agent dest: %" PRIx64, evt->fr_dest);

	unlink_param = &(evt->info.msg.info.api_info.param.chan_unlink);
	rs = eds_channel_unlink(cb, unlink_param->chan_name.length, unlink_param->chan_name.value);
	if (rs != SA_AIS_OK)
		TRACE("Channel unlink failed for :%" PRIx64, evt->fr_dest);

	/* Send response back */
	m_EDS_EDSV_CHAN_UNLINK_SYNC_MSG_FILL(msg, rs, unlink_param->chan_name)
	    rc = eds_mds_msg_send(cb, &msg, &evt->fr_dest, &evt->mds_ctxt, MDS_SEND_PRIORITY_HIGH);
	if (rc != NCSCC_RC_SUCCESS)
		LOG_ER("MDS send to %" PRIx64 " failed for saEvtChannelUnlink()", evt->fr_dest);

	if (rs == SA_AIS_OK) {	/* Send an Async update to STANDBY EDS peer */
		if (cb->ha_state == SA_AMF_HA_ACTIVE) {
			memset(&ckpt, 0, sizeof(ckpt));
			m_EDSV_FILL_ASYNC_UPDATE_CUNLINK(ckpt, unlink_param->chan_name.value,
							 unlink_param->chan_name.length)
			async_rc = send_async_update(cb, &ckpt, NCS_MBCSV_ACT_ADD);
			if (async_rc != NCSCC_RC_SUCCESS)
				TRACE("Async update send failed for unlink msg");
		}
	}
	TRACE_LEAVE();
	return rc;
}
Exemple #17
0
/****************************************************************************
  Name          : avnd_evt_mds_avd_up
 
  Description   : This routine processes the AvD up event from MDS. It sends 
                  the node-up message to AvD. it also starts AvD supervision
		  we are on a controller and the up event is for our node.
 
  Arguments     : cb  - ptr to the AvND control block
                  evt - ptr to the AvND event
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_evt_mds_avd_up_evh(AVND_CB *cb, AVND_EVT *evt)
{
	TRACE_ENTER2("%llx", evt->info.mds.mds_dest);
	
	/* Validate whether this is a ADEST or VDEST */
	if (m_MDS_DEST_IS_AN_ADEST(evt->info.mds.mds_dest)) {
		NCS_NODE_ID node_id, my_node_id = ncs_get_node_id();
		node_id = m_NCS_NODE_ID_FROM_MDS_DEST(evt->info.mds.mds_dest);

		if ((node_id == my_node_id) && (cb->type == AVSV_AVND_CARD_SYS_CON)) {
			TRACE("Starting hb supervision of local avd");
			avnd_stop_tmr(cb, &cb->hb_duration_tmr);
			avnd_start_tmr(cb, &cb->hb_duration_tmr,
				AVND_TMR_HB_DURATION, cb->hb_duration, 0);
		}
	} else {
		/* Avd is already UP, reboot the node */
		if (m_AVND_CB_IS_AVD_UP(cb)) {
                        opensaf_reboot(avnd_cb->node_info.nodeId, (char *)avnd_cb->node_info.executionEnvironment.value,
                                        "AVD already up");
			goto done;
		}

		m_AVND_CB_AVD_UP_SET(cb);

		/* store the AVD MDS address */
		cb->avd_dest = evt->info.mds.mds_dest;

		avnd_send_node_up_msg();
	}

done:
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
/*****************************************************************************

  PROCEDURE          :    ncs_mbcsv_send_cold_sync_tmr

  DESCRIPTION:

    Sends a cold sync req on the timer expiry.

    The first response to the cold sync cancels the send cold sync
    timer since that says the other side is responding and there is
    no need to continually send cold syncs. 
    The final response to the cold sync cancels the cold sync complt
    timer. 

  ARGUMENTS:       
      peer: Interface to send message to.

  RETURNS:          Nothing.

  NOTES:

*****************************************************************************/
void ncs_mbcsv_send_cold_sync_tmr(PEER_INST *peer, MBCSV_EVT *evt)
{
	uint32_t rc;
	TRACE_ENTER2("cold sync timer expired. send a cold sync request if STANDBY");

	/* Send a cold sync req  and start the send cold sync timer if the role is */
	/* Standby and the RED is enabled                                           */

	if (peer->my_ckpt_inst->my_role == SA_AMF_HA_STANDBY) {
		TRACE("I'm STANDBY, send COLD SYNC request");
		m_MBCSV_SEND_CLIENT_MSG(peer, NCSMBCSV_SEND_COLD_SYNC_REQ, NCS_MBCSV_ACT_DONT_CARE);

		/* Even if the message was not sent, we will try again later */
		/* When we get a cold sync response - this timer will be cancelled */
		ncs_mbcsv_start_timer(peer, NCS_MBCSV_TMR_SEND_COLD_SYNC);

		/* This timer must be started whenever the cold sync is sent */
		ncs_mbcsv_start_timer(peer, NCS_MBCSV_TMR_COLD_SYNC_CMPLT);
	}

	/* Tell the MBCSv clinet about the timer expiration */
	/* It can do smart things - if it cares */
	TRACE("Inform(ERR_INDICATION_CBK) client app about the cold sync timer expiry. client app may act or ignore");
	m_MBCSV_INDICATE_ERROR(peer,
			       peer->my_ckpt_inst->client_hdl,
			       NCS_MBCSV_COLD_SYNC_TMR_EXP, false, peer->version, NULL, rc);

	if (NCSCC_RC_SUCCESS != rc)
		TRACE("err indication processing failed");

	TRACE_LEAVE();
}
Exemple #19
0
/****************************************************************************
  Name          : avnd_di_object_upd_send
 
  Description   : This routine sends update of those objects that reside 
                  on AvD but are maintained on AvND.
 
  Arguments     : cb    - ptr to the AvND control block
                  param - ptr to the params that are to be updated to AvD
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_di_object_upd_send(AVND_CB *cb, AVSV_PARAM_INFO *param)
{
	AVND_MSG msg;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Comp '%s'", param->name.value);

	memset(&msg, 0, sizeof(AVND_MSG));

	/* populate the msg */
	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_DATA_REQUEST_MSG;
		msg.info.avd->msg_info.n2d_data_req.msg_id = ++(cb->snd_msg_id);
		msg.info.avd->msg_info.n2d_data_req.node_id = cb->node_info.nodeId;
		msg.info.avd->msg_info.n2d_data_req.param_info = *param;

		/* send the msg to AvD */
		rc = avnd_di_msg_send(cb, &msg);
		if (NCSCC_RC_SUCCESS == rc)
			msg.info.avd = 0;
	} else
		rc = NCSCC_RC_FAILURE;

	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);
	TRACE_LEAVE2("%u", rc);
	return rc;
}
static avd_cstype_t *cstype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes)
{
	avd_cstype_t *cst;
	SaUint32T values_number;

	TRACE_ENTER2("'%s'", dn->value);

	if ((cst = calloc(1, sizeof(*cst))) == NULL) {
		LOG_ER("calloc failed");
		return NULL;
	}

	memcpy(cst->name.value, dn->value, dn->length);
	cst->name.length = dn->length;
	cst->tree_node.key_info = (uns8 *)&cst->name;

	if ((immutil_getAttrValuesNumber("saAmfCSAttrName", attributes, &values_number) == SA_AIS_OK) &&
	    (values_number > 0)) {
		int i;

		cst->saAmfCSAttrName = calloc((values_number + 1), sizeof(char *));
		for (i = 0; i < values_number; i++)
			cst->saAmfCSAttrName[i] = strdup(immutil_getStringAttr(attributes, "saAmfCSAttrName", i));
	}

	return cst;
}
Exemple #21
0
/****************************************************************************
  Name          : avnd_di_ack_nack_msg_send
 
  Description   : This routine processes the data verify message sent by newly
                  Active AVD.
 
  Arguments     : cb  - ptr to the AvND control block
                  rcv_id - Receive message ID for AVND
                  view_num - Cluster view number
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None.
******************************************************************************/
uns32 avnd_di_ack_nack_msg_send(AVND_CB *cb, uns32 rcv_id, uns32 view_num)
{
	AVND_MSG msg;
	uns32 rc = NCSCC_RC_SUCCESS;
	TRACE_ENTER2("Receive id = %u",rcv_id);

   /*** send the response to AvD ***/
	memset(&msg, 0, sizeof(AVND_MSG));

	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_VERIFY_ACK_NACK_MSG;
		msg.info.avd->msg_info.n2d_ack_nack_info.msg_id = (cb->snd_msg_id + 1);
		msg.info.avd->msg_info.n2d_ack_nack_info.node_id = cb->node_info.nodeId;

		if (rcv_id != cb->rcv_msg_id)
			msg.info.avd->msg_info.n2d_ack_nack_info.ack = FALSE;
		else
			msg.info.avd->msg_info.n2d_ack_nack_info.ack = TRUE;

		TRACE_1("MsgId=%u,ACK=%u",msg.info.avd->msg_info.n2d_ack_nack_info.msg_id,msg.info.avd->msg_info.n2d_ack_nack_info.ack);

		rc = avnd_di_msg_send(cb, &msg);
		if (NCSCC_RC_SUCCESS == rc)
			msg.info.avd = 0;
	} else
		rc = NCSCC_RC_FAILURE;

	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);

	TRACE_LEAVE2("retval=%u",rc);
	return rc;
}
Exemple #22
0
/*****************************************************************************
  Name          :  clms_node_admin_state_change_ntf

  Description   :  This function generate a node exit ntf

  Arguments     :  clms_cb -    Pointer to the CLMS_CB structure
                   node -      Pointer to the CLMS_CLUSTER_NODE  structure

  Return Values :  NCSCC_RC_SUCCESS / NCSCC_RC_FAILURE

  Notes         : 
*****************************************************************************/
void clms_node_admin_state_change_ntf(CLMS_CB * clms_cb, CLMS_CLUSTER_NODE * node, SaUint32T newState)
{
	uint32_t status = NCSCC_RC_FAILURE;
	SaNameT dn;
	SaUint8T add_text[SA_MAX_NAME_LENGTH];

	TRACE_ENTER2("admin state change for node name %s", node->node_name.value);

	saflog(LOG_NOTICE, clmSvcUsrName, "%s Admin State Changed, new state=%s",
		   node->node_name.value, clm_adm_state_name[newState]);

	memset(dn.value, '\0', SA_MAX_NAME_LENGTH);
	dn.length = node->node_name.length;
	(void)memcpy(dn.value, node->node_name.value, dn.length);

	memset(&add_text, '\0', sizeof(add_text));
	sprintf((SaInt8T *)add_text, "CLM node %s Admin State Change", dn.value);

	status = sendStateChangeNotificationClms(clms_cb,
						 dn,
						 add_text,
						 SA_SVC_CLM,
						 SA_CLM_NTFID_NODE_ADMIN_STATE,
						 SA_NTF_MANAGEMENT_OPERATION, SA_CLM_ADMIN_STATE, newState);
	if (status == NCSCC_RC_FAILURE)
		LOG_ER("clms_node_admin_state_change_ntf failed %u",status);

	TRACE_LEAVE();
}
/****************************************************************************\
 * Function: avnd_mbcsv_process_err_ind
 *
 * Purpose:  AVND MBCSV process error indication.
 *
 * Input: arg - MBCSV callback argument pointer.
 *
 * Returns: NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
 *
 * NOTES:
 *
 * 
\**************************************************************************/
static uns32 avnd_mbcsv_process_err_ind(AVND_CB *cb, NCS_MBCSV_CB_ARG *arg)
{

	TRACE_ENTER2("error code is %u",arg->info.error.i_code);

	switch (arg->info.error.i_code) {
	case NCS_MBCSV_COLD_SYNC_TMR_EXP:
		break;

	case NCS_MBCSV_WARM_SYNC_TMR_EXP:
		break;

	case NCS_MBCSV_DATA_RSP_CMPLT_TMR_EXP:
		break;

	case NCS_MBCSV_COLD_SYNC_CMPL_TMR_EXP:
		break;

	case NCS_MBCSV_WARM_SYNC_CMPL_TMR_EXP:
		break;

	case NCS_MBCSV_DATA_RESP_TERMINATED:
		break;

	default:
		LOG_ER("Invalid mbcsv error indication");
		break;
	}

	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
Exemple #24
0
/**
 * Handle a received heart beat message, just reset the duration timer.
 * @param cb
 * @param evt
 * 
 * @return uns32
 */
uns32 avnd_evt_avd_hb_evh(AVND_CB *cb, AVND_EVT *evt)
{
	TRACE_ENTER2("%u", evt->info.avd->msg_info.d2n_hb_info.seq_id);
	avnd_stop_tmr(cb, &cb->hb_duration_tmr);
	avnd_start_tmr(cb, &cb->hb_duration_tmr, AVND_TMR_HB_DURATION, cb->hb_duration, 0);
	return NCSCC_RC_SUCCESS;
}
int syncLoggedConfirm(unsigned int logged, NCS_UBAID *uba)
{
	TRACE_ENTER2("NOT IMPLEMENTED");
	if (0 == ntfsv_enc_32bit_msg(uba, logged))
		return 0;
	TRACE_LEAVE();
	return 1;
}
/******************************************************************************
  Name          : avnd_evt_ava_comp_val_req
 
  Description   : This routine creates a validation req msg and sends to AvD.
 
  Arguments     : cb  - ptr to the AvND control block.
                  evt - ptr to the AvND event.
 
  Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
 
  Notes         : None
******************************************************************************/
uns32 avnd_evt_ava_comp_val_req(AVND_CB *cb, AVND_EVT *evt)
{
	uns32 rc = NCSCC_RC_SUCCESS;
	AVND_DND_MSG_LIST *rec = 0;
	AVND_MSG msg;
	AVSV_AMF_API_INFO *api_info = &evt->info.ava.msg->info.api_info;
	AVSV_AMF_COMP_REG_PARAM *reg = &api_info->param.reg;

	TRACE_ENTER2("%s,Type=%u,Hdl=%llx",
			      reg->comp_name.value, api_info->type, reg->hdl);

	memset(&msg, 0, sizeof(AVND_MSG));

	/* populate the msg */
	if (0 != (msg.info.avd = calloc(1, sizeof(AVSV_DND_MSG)))) {
		msg.type = AVND_MSG_AVD;
		msg.info.avd->msg_type = AVSV_N2D_COMP_VALIDATION_MSG;
		msg.info.avd->msg_info.n2d_comp_valid_info.msg_id = ++(cb->snd_msg_id);
		msg.info.avd->msg_info.n2d_comp_valid_info.node_id = cb->node_info.nodeId;
		msg.info.avd->msg_info.n2d_comp_valid_info.comp_name =
		    evt->info.ava.msg->info.api_info.param.reg.comp_name;

		/* add the record to the AvD msg list */
		if ((0 != (rec = avnd_diq_rec_add(cb, &msg)))) {
			/* These parameters would not be encoded or decoded so, wouldn't be sent to AvD. */
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.hdl = reg->hdl;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.proxy_comp_name = reg->proxy_comp_name;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.mds_dest = api_info->dest;
			rec->msg.info.avd->msg_info.n2d_comp_valid_info.mds_ctxt = evt->mds_ctxt;
			/* send the message */
			rc = avnd_diq_rec_send(cb, rec);

			if ((NCSCC_RC_SUCCESS != rc) && rec) {
				LOG_ER("avnd_diq_rec_send:failed:%s,Type:%u and Hdl%llx",
						    reg->comp_name.value, api_info->type, reg->hdl);
				/* pop & delete */
				m_AVND_DIQ_REC_FIND_POP(cb, rec);
				avnd_diq_rec_del(cb, rec);
			}
		} else {
			rc = NCSCC_RC_FAILURE;
			LOG_ER("avnd_diq_rec_add failed::%s,Type:%u and Hdl%llx",
						reg->comp_name.value, api_info->type, reg->hdl);
		}
	} else
		rc = NCSCC_RC_FAILURE;

	if (NCSCC_RC_FAILURE == rc) {
		LOG_ER("avnd_evt_ava_comp_val_req:%s,Type:%u and Hdl%llx",
						reg->comp_name.value, api_info->type, reg->hdl); 
	}
	/* free the contents of avnd message */
	avnd_msg_content_free(cb, &msg);

	return rc;

}
Exemple #27
0
static uns32 avnd_sg_oper_req(AVND_CB *cb, AVSV_PARAM_INFO *param)
{
	uns32 rc = NCSCC_RC_FAILURE;

	TRACE_ENTER2("'%s'", param->name.value);

	switch (param->act) {
	case AVSV_OBJ_OPR_MOD:	{
		AVND_SU *su;

		su = m_AVND_SUDB_REC_GET(cb->sudb, param->name);
		if (!su) {
			LOG_ER("%s: failed to get %s", __FUNCTION__, param->name.value);
			goto done;
		}

		switch (param->attr_id) {
		case saAmfSGCompRestartProb_ID:
			assert(sizeof(SaTimeT) == param->value_len);
			su->comp_restart_prob = m_NCS_OS_NTOHLL_P(param->value);
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su,
				AVND_CKPT_SU_COMP_RESTART_PROB);
			break;
		case saAmfSGCompRestartMax_ID:
			assert(sizeof(uns32) == param->value_len);
			su->comp_restart_max = m_NCS_OS_NTOHL(*(uns32 *)(param->value));
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_COMP_RESTART_MAX);
			break;
		case saAmfSGSuRestartProb_ID:
			assert(sizeof(SaTimeT) == param->value_len);
			su->su_restart_prob = m_NCS_OS_NTOHLL_P(param->value);
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_RESTART_PROB);
			break;
		case saAmfSGSuRestartMax_ID:
			assert(sizeof(uns32) == param->value_len);
			su->su_restart_max = m_NCS_OS_NTOHL(*(uns32 *)(param->value));
			m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, su, AVND_CKPT_SU_RESTART_MAX);
			break;
		default:
			LOG_NO("%s: Unsupported attribute %u", __FUNCTION__, param->attr_id);
			goto done;
		}
		break;
	}

	default:
		LOG_NO("%s: Unsupported action %u", __FUNCTION__, param->act);
		goto done;
	}

	rc = NCSCC_RC_SUCCESS;

done:
	TRACE_LEAVE();
	return rc;
}
Exemple #28
0
/****************************************************************************
 * Name          : amf_active_state_handler
 *
 * Description   : This function is called upon receving an active state
 *                 assignment from AMF.
 *
 * Arguments     : invocation - Designates a particular invocation.
 *                 cb         - A pointer to the NTFS control block. 
 *
 * Return Values : None
 *
 * Notes         : None 
 *****************************************************************************/
static SaAisErrorT amf_active_state_handler(SaInvocationT invocation)
{
	SaAisErrorT error = SA_AIS_OK;
	TRACE_ENTER2("HA ACTIVE request");

	ntfs_cb->mds_role = V_DEST_RL_ACTIVE;

	TRACE_LEAVE();
	return error;
}
/****************************************************************************
  Name          : ntfa_hdl_cbk_rec_prc
 
  Description   : This routine invokes the registered callback routine & frees
                  the callback record resources.
 
  Arguments     : cb      - ptr to the NTFA control block
                  msg     - ptr to the callback message
                  reg_cbk - ptr to the registered callbacks
 
  Return Values : Error code
 
  Notes         : None
******************************************************************************/
static SaAisErrorT ntfa_hdl_cbk_rec_prc(ntfa_cb_t *cb, ntfsv_msg_t *msg, ntfa_client_hdl_rec_t *hdl_rec)
{
	SaNtfCallbacksT *reg_cbk = &hdl_rec->reg_cbk;
	ntfsv_cbk_info_t *cbk_info = &msg->info.cbk_info;
	SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
	TRACE_ENTER2("callback type: %d", cbk_info->type);

	/* invoke the corresponding callback */
	switch (cbk_info->type) {
	case NTFSV_NOTIFICATION_CALLBACK:
		{
			if (reg_cbk->saNtfNotificationCallback) {
				SaNtfNotificationsT *notification;
				/* TODO: new notification from decode */
				notification = calloc(1, sizeof(SaNtfNotificationsT));
				if (notification == NULL) {
					rc = SA_AIS_ERR_NO_MEMORY;
					goto done;
				}
/* TODO: put in handle database when decode */
				rc = ntfa_alloc_callback_notification(notification,
								      cbk_info->param.notification_cbk, hdl_rec);
				if (rc != SA_AIS_OK) {
					/* not in handle struct */
					free(notification);
					goto done;
				}
				reg_cbk->saNtfNotificationCallback(cbk_info->subscriptionId, notification);
			}
		}
		break;
	case NTFSV_DISCARDED_CALLBACK:
		{
			if (reg_cbk->saNtfNotificationDiscardedCallback) {
				rc = SA_AIS_OK;
				reg_cbk->saNtfNotificationDiscardedCallback(cbk_info->subscriptionId,
									    cbk_info->param.discarded_cbk.
									    notificationType,
									    cbk_info->param.discarded_cbk.
									    numberDiscarded,
									    cbk_info->param.discarded_cbk.
									    discardedNotificationIdentifiers);
			}
			free(cbk_info->param.discarded_cbk.discardedNotificationIdentifiers);
		}
		break;
	default:
		TRACE("unsupported callback type: %d", cbk_info->type);
		rc = SA_AIS_ERR_LIBRARY;
		break;
	}
 done:
	TRACE_LEAVE();
	return rc;
}
Exemple #30
0
static uint32_t eds_proc_chan_open_async_msg(EDS_CB *cb, EDSV_EDS_EVT *evt)
{
	uint32_t rc = NCSCC_RC_SUCCESS, rs = NCSCC_RC_SUCCESS, async_rc = NCSCC_RC_SUCCESS;
	uint32_t chan_id;
	uint32_t chan_open_id;
	EDSV_MSG msg;
	time_t time_of_day;
	SaTimeT chan_create_time = 0;
	EDSV_EDA_CHAN_OPEN_ASYNC_PARAM *open_async_param;
	EDS_CKPT_DATA ckpt;
	TRACE_ENTER2("agent dest: %" PRIx64, evt->fr_dest);

	open_async_param = &(evt->info.msg.info.api_info.param.chan_open_async);

	/* Set the open  time here */
	m_NCS_OS_GET_TIME_STAMP(time_of_day);

	/* convert time_t to SaTimeT */
	chan_create_time = (SaTimeT)time_of_day *SA_TIME_ONE_SECOND;

	rs = eds_channel_open(cb,
			      open_async_param->reg_id,
			      open_async_param->chan_open_flags,
			      open_async_param->chan_name.length,
			      open_async_param->chan_name.value,
			      evt->fr_dest, &chan_id, &chan_open_id, chan_create_time);

	if (rs != SA_AIS_OK)
		TRACE("ChannelOpenAsync failed for agent destination: %" PRIx64, evt->fr_dest);

	/* Send async response back */
	m_EDS_EDSV_CHAN_OPEN_CB_MSG_FILL(msg, open_async_param->reg_id,
					 open_async_param->inv,
					 open_async_param->chan_name,
					 chan_id, chan_open_id, open_async_param->chan_open_flags, rs)
	rc = eds_mds_msg_send(cb, &msg, &evt->fr_dest, &evt->mds_ctxt, MDS_SEND_PRIORITY_MEDIUM);
	if (rc != NCSCC_RC_SUCCESS)
		LOG_ER("MDS send to %" PRIx64 "failed for saEvtChannelOpenAsync()", evt->fr_dest);

	if (rs == SA_AIS_OK) {
		/* Send an Async update to STANDBY EDS peer */
		if (cb->ha_state == SA_AMF_HA_ACTIVE) {
			memset(&ckpt, 0, sizeof(ckpt));
			m_EDSV_FILL_ASYNC_UPDATE_CHAN(ckpt, open_async_param, chan_id, chan_open_id, evt->fr_dest,
						      chan_create_time)
			async_rc = send_async_update(cb, &ckpt, NCS_MBCSV_ACT_ADD);
			if (async_rc != NCSCC_RC_SUCCESS)
				TRACE("Async Update send failed for chan open (async) msg");
		}
	}

	TRACE_LEAVE();
	return rc;
}