Ejemplo n.º 1
0
/*
 * Sends release requests
 *
 * @param[in] request - selection request data
 *
 * @return 0 when successful, otherwise ERROR
 */
static int
send_release_message(struct lacp_aggregation_message_data *request)
{
    int err = 0;
    struct mlag_master_election_status me_status;

    err = mlag_master_election_get_status(&me_status);
    MLAG_BAIL_ERROR_MSG(err, "Failed getting ME status\n");

    /* send message to logic */
    request->mlag_id = me_status.my_peer_id;
    request->select = FALSE;

    if ((current_role == SLAVE) && (use_local_lacp_logic == TRUE)) {
        err = send_system_event(MLAG_LACP_SELECTION_EVENT,
                                request, sizeof(*request));
        MLAG_BAIL_ERROR_MSG(err,
                            "Failed in sending MLAG_LACP_SELECTION_EVENT event\n");
    }
    else {
        err = lacp_manager_message_send(MLAG_LACP_SELECTION_EVENT,
                                        request, sizeof(*request),
                                        me_status.master_peer_id,
                                        PEER_MANAGER);
        MLAG_BAIL_ERROR_MSG(err,
                            "Failed sending release request id [%u] port [%lu]\n",
                            request->request_id, request->port_id);
    }

bail:
    return err;
}
Ejemplo n.º 2
0
/**
 *  Sets the local system Id
 *  The LACP module gives the suggested actor parameters according
 *  to mlag protocol state (possible answers are local parameters set in this
 *  function or the remote side parameters)
 *
 *  @param[in] local_sys_id - local system ID
 *
 * @return 0 when successful, otherwise ERROR
 */
int
lacp_manager_system_id_set(unsigned long long local_sys_id)
{
    int err = 0;
    struct peer_lacp_sync_message sync_message;

    MLAG_LOG(MLAG_LOG_NOTICE,
             "LACP system ID set to [%llu] \n", local_sys_id);

    err = lacp_db_local_system_id_set(local_sys_id);
    MLAG_BAIL_ERROR(err);

    if (current_role == MASTER) {
        sync_message.mlag_id = MASTER_PEER_ID;
        sync_message.phase = LACP_SYS_ID_UPDATE;
        sync_message.sys_id = local_sys_id;

        MLAG_LOG(MLAG_LOG_NOTICE,
                 "send LACP sys id update to peer [%u] \n", SLAVE_PEER_ID);

        /* Send sync message with new system id */
        err = lacp_manager_message_send(MLAG_LACP_SYNC_MSG,
                                        &sync_message, sizeof(sync_message),
                                        SLAVE_PEER_ID, MASTER_LOGIC);

        /* Send system id update event to port manager */
        err = send_system_event(MLAG_LACP_SYS_ID_UPDATE_EVENT, NULL, 0);
        MLAG_BAIL_ERROR(err);
    }

bail:
    return err;
}
Ejemplo n.º 3
0
/*
 * This function is sending sync done message to the master, it should not be
 * called on the slave
 *
 * @param[in] mlag_id - This is the mlag ID
 *
 * @return 0 if operation completes successfully.
 */
static int
lacp_send_sync_done(int mlag_id)
{
    int err = 0;
    struct sync_event_data data;

    data.peer_id = mlag_id;
    data.opcode = 0;
    data.sync_type = LACP_PEER_SYNC;
    data.state = 1; /* finish */

    err = send_system_event(MLAG_PEER_SYNC_DONE, &data, sizeof(data));
    MLAG_BAIL_ERROR(err);

    MLAG_LOG(MLAG_LOG_NOTICE, "Successfully sent SYNC_DONE for LACP\n");

bail:
    return err;
}
Ejemplo n.º 4
0
/*
 *  Handle incoming LACP sync data
 *
 * @param[in] lacp_sync - message body
 *
 * @return 0 when successful, otherwise ERROR
 */
static int
update_lacp_master_attributes(struct peer_lacp_sync_message *lacp_sync)
{
    int err = 0;

    MLAG_LOG(MLAG_LOG_NOTICE,
             "got lacp sync id is [%llu]\n", lacp_sync->sys_id);

    if (current_role == SLAVE) {

    	err = lacp_db_master_system_id_set(lacp_sync->sys_id);
    	MLAG_BAIL_ERROR(err);

    	if (lacp_sync->phase == LACP_SYS_ID_UPDATE) {
    		/* Send system id update event to port manager */
    		err = send_system_event(MLAG_LACP_SYS_ID_UPDATE_EVENT, NULL, 0);
    		MLAG_BAIL_ERROR(err);
    	}
    }

bail:
    return err;
}
Ejemplo n.º 5
0
Tasksettings::Tasksettings(Settingsstore* store, Taskaccessmanager* taskaccessmanager, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Tasksettings)
{
    ui->setupUi(this);
    my_task_uid = -1;//default value to recognize if task uid has been set already...
    storage = store;
    taskaccess = taskaccessmanager;
    taskpriority = new Taskpriority();
    taskpriority->hide();
    taskevent = new Taskevent(taskaccess);
    taskevent->hide();
    QObject::connect(ui->pushButtonBack, SIGNAL(clicked()), this, SLOT(hide_me()));
    QObject::connect(ui->pushButtonRefresh, SIGNAL(clicked()), this, SLOT(refresh_info()));
    QObject::connect(ui->pushButtonClose, SIGNAL(clicked()), this, SLOT(close_task()));
    QObject::connect(ui->pushButtonKill, SIGNAL(clicked()), this, SLOT(kill_task()));
    QObject::connect(ui->pushButtonPriority, SIGNAL(clicked()), this, SLOT(set_task_priority()));
    QObject::connect(ui->pushButtonEvent, SIGNAL(clicked()), this, SLOT(send_system_event()));

    refresh_interval = 1000;
    timer_refresh = new QTimer();
    timer_refresh->setInterval(refresh_interval);
    QObject::connect(timer_refresh, SIGNAL(timeout()), this, SLOT(refresh_stats()));
}
Ejemplo n.º 6
0
/**
 * Handles an incoming msg of aggregator selection
 *
 * @param[in] msg - aggregator selection message
 *
 * @return 0 when successful, otherwise ERROR
 */
int
lacp_manager_aggregator_selection_handle(
    struct lacp_aggregation_message_data *msg)
{
    int err = 0;
    enum aggregate_select_response response;
    int dest_peer, is_free;
    unsigned long long selected_partner_id;
    unsigned int selected_partner_key;
    struct lacp_aggregator_release_message rel_msg;

    if (msg->select == FALSE) {
        /* free request */
        err = lacp_aggregator_free_logic(msg->mlag_id, msg->port_id, &is_free);
        MLAG_BAIL_ERROR_MSG(err, "Failed in lacp aggregator free logic\n");

        if (is_free) {
            /* notify free ID */
            rel_msg.port_id = msg->port_id;
            for (dest_peer = 0; dest_peer < MLAG_MAX_PEERS; dest_peer++) {
                if ((current_role == SLAVE) &&
                    (use_local_lacp_logic == TRUE)) {
                    err = send_system_event(MLAG_LACP_RELEASE_EVENT,
                                            &rel_msg, sizeof(rel_msg));
                    MLAG_BAIL_ERROR_MSG(err,
                                        "Failed in sending lacp system event\n");
                }
                else {
                    err = lacp_manager_message_send(MLAG_LACP_RELEASE_EVENT,
                                                    &rel_msg, sizeof(rel_msg),
                                                    dest_peer, MASTER_LOGIC);
                    if (err != -ENOENT) {
                        MLAG_BAIL_ERROR_MSG(err,
                                            "Failed to send lacp release port [%lu] peer [%d]\n",
                                            rel_msg.port_id, dest_peer);
                    }
                    else {
                        err = 0;
                    }
                }
            }
        }
    }
    else if (msg->is_response == FALSE) {
        err = lacp_aggregator_select_logic(msg->mlag_id, msg->port_id,
                                           msg->partner_id, msg->partner_key,
                                           &response, &selected_partner_id,
                                           &selected_partner_key);
        MLAG_BAIL_ERROR_MSG(err, "Failed in lacp aggregator select logic\n");

        /* Send response to the selection request */
        msg->is_response = TRUE;
        msg->response = response;
        msg->partner_id = selected_partner_id;
        msg->partner_key = selected_partner_key;

        if ((current_role == SLAVE) && (use_local_lacp_logic == TRUE)) {
            err = send_system_event(MLAG_LACP_SELECTION_EVENT,
                                    msg, sizeof(*msg));
            MLAG_BAIL_ERROR_MSG(err,
                                "Failed in sending MLAG_LACP_SELECTION_EVENT event\n");
        }
        else {
            err = lacp_manager_message_send(MLAG_LACP_SELECTION_EVENT, msg,
                                            sizeof(*msg), msg->mlag_id,
                                            MASTER_LOGIC);
            MLAG_BAIL_ERROR_MSG(err, "Failed in selection response sending\n");
        }
    }
    else {
        /* notify on response */
        err = notify_aggregator_selection_response(msg);
        MLAG_BAIL_ERROR(err);
    }

bail:
    return err;
}