/** * This function handles local sync done event * * @param[in] data - event data * * @return 0 when successful, otherwise ERROR */ int mlag_l3_interface_peer_local_sync_done(uint8_t *data) { int err = 0; UNUSED_PARAM(data); struct sync_event_data ev; struct mlag_master_election_status master_election_current_status; MLAG_LOG(MLAG_LOG_NOTICE, "send MLAG_L3_SYNC_FINISH_EVENT to master logic\n"); err = mlag_master_election_get_status(&master_election_current_status); MLAG_BAIL_ERROR_MSG(err, "Failed to get status from master election in handling of local sync done event, err=%d\n", err); /* Send MLAG_L3_SYNC_FINISH_EVENT to Master Logic */ ev.peer_id = master_election_current_status.my_peer_id; ev.state = 1; err = mlag_dispatcher_message_send(MLAG_L3_SYNC_FINISH_EVENT, &ev, sizeof(ev), MASTER_PEER_ID, PEER_MANAGER); MLAG_BAIL_ERROR_MSG(err, "Failed in sending MLAG_L3_SYNC_FINISH_EVENT, err=%d\n", err); bail: return err; }
/* * Used for sending messages * with implementation of counting mechanism * * @param[in] opcode - message opcode * @param[in] payload - pointer to message data * @param[in] payload_len - message data length * @param[in] dest_peer_id - mlag id of dest peer * @param[in] orig - message originator * * @return 0 if operation completes successfully. */ static int lacp_manager_message_send(enum mlag_events opcode, void* payload, uint32_t payload_len, uint8_t dest_peer_id, enum message_originator orig) { int err = 0; struct mlag_master_election_status me_status; err = mlag_dispatcher_message_send(opcode, payload, payload_len, dest_peer_id, orig); MLAG_BAIL_CHECK_NO_MSG(err); err = mlag_master_election_get_status(&me_status); MLAG_BAIL_ERROR_MSG(err, "Failed getting ME status\n"); /* Counters */ if ((dest_peer_id != me_status.my_peer_id) || ((orig == PEER_MANAGER) && (current_role == SLAVE))) { /* increment IPL counter */ lacp_db_counters_inc(LM_CNT_PROTOCOL_TX); } bail: return err; }
/** * This function handles peer start event * * @param[in] data - event data * * @return 0 when successful, otherwise ERROR */ int mlag_l3_interface_peer_peer_start(struct peer_state_change_data *data) { int err = 0; struct sync_event_data ev; MLAG_LOG(MLAG_LOG_NOTICE, "Sending MLAG_L3_SYNC_START_EVENT to master logic\n"); is_peer_start = 1; /* Send MLAG_SYNC_START_EVENT event to Master Logic */ ev.peer_id = data->mlag_id; ev.state = 0; err = mlag_dispatcher_message_send(MLAG_L3_SYNC_START_EVENT, &ev, sizeof(ev), MASTER_PEER_ID, PEER_MANAGER); MLAG_BAIL_ERROR_MSG(err, "Failed in sending MLAG_L3_SYNC_START_EVENT, err=%d\n", err); bail: return err; }
/** * This function handles vlan local state change event * * @param[in] data - event data * * @return 0 when successful, otherwise ERROR */ int mlag_l3_interface_peer_vlan_local_state_change( struct vlan_state_change_event_data *data) { int err = 0; int ev_len = 0; struct mlag_master_election_status master_election_current_status; int i; ASSERT(data); if (!is_started) { MLAG_LOG(MLAG_LOG_NOTICE, "Vlan local state change event accepted before start of module\n"); goto bail; } if (!is_master_sync_done) { MLAG_LOG(MLAG_LOG_NOTICE, "Vlan local state change event accepted before master sync done\n"); goto bail; } MLAG_LOG(MLAG_LOG_INFO, "Vlan local state change event: number vlans %d\n", data->vlans_arr_cnt); if ((!data->vlans_arr_cnt) || (data->vlans_arr_cnt >= VLAN_N_VID)) { err = -EINVAL; MLAG_BAIL_ERROR_MSG(EINVAL, "Invalid vlans array_counter %d", data->vlans_arr_cnt); } for (i=0; i < data->vlans_arr_cnt; i++) { if (!(((data->vlan_data[i].vlan_id > 0) && (data->vlan_data[i].vlan_id < VLAN_N_VID)) && ((data->vlan_data[i].vlan_state == VLAN_DOWN) || (data->vlan_data[i].vlan_state == VLAN_UP)))) { MLAG_BAIL_ERROR_MSG(EINVAL, "Invalid vlan parameters: vlan id=%d, vlan state=%s", data->vlan_data[i].vlan_id, (data->vlan_data[i].vlan_state == VLAN_UP) ? "up" : "down"); } } mlag_l3_interface_inc_cnt(VLAN_LOCAL_STATE_EVENTS_RCVD); /* Send MLAG_L3_INTERFACE_VLAN_LOCAL_STATE_CHANGE_FROM_PEER_EVENT * to Master Logic */ err = mlag_master_election_get_status(&master_election_current_status); MLAG_BAIL_ERROR_MSG(err, "Failed to get status from master election in handling of vlan local state change event, err=%d\n", err); ev_len = sizeof(struct vlan_state_change_base_event_data) + sizeof(data->vlan_data[0]) * data->vlans_arr_cnt; data->peer_id = master_election_current_status.my_peer_id; err = mlag_dispatcher_message_send( MLAG_L3_INTERFACE_VLAN_LOCAL_STATE_CHANGE_FROM_PEER_EVENT, data, ev_len, MASTER_PEER_ID, PEER_MANAGER); MLAG_BAIL_ERROR_MSG(err, "Failed in sending MLAG_L3_INTERFACE_VLAN_LOCAL_STATE_CHANGE_FROM_PEER_EVENT, err=%d\n", err); bail: return err; }