From 4c4223edfd46841062340fe449cd97a93dccc498 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Wed, 15 Jul 2020 08:44:54 -0700 Subject: bonding lacp: replace slave string with member - Replace textual string slave with member except APIs. - For APIs, mark the existing APIs as deprecated and introduce new APIs - While introducing sw_bond_interface_dump, add the optional filter by sw_if_index and enhance the testcases to make use of it. Type: improvement Signed-off-by: Steven Luong Change-Id: Ib6626c514e45350308aeeda0decb70f3aba2f63e --- src/plugins/lacp/cli.c | 239 +++++++++++++++++++------------------ src/plugins/lacp/input.c | 112 ++++++++--------- src/plugins/lacp/lacp.api | 4 +- src/plugins/lacp/lacp.c | 234 ++++++++++++++++++------------------ src/plugins/lacp/machine.h | 4 +- src/plugins/lacp/mux_machine.c | 122 +++++++++---------- src/plugins/lacp/mux_machine.h | 6 +- src/plugins/lacp/node.h | 16 +-- src/plugins/lacp/ptx_machine.c | 90 +++++++------- src/plugins/lacp/ptx_machine.h | 30 ++--- src/plugins/lacp/rx_machine.c | 238 ++++++++++++++++++------------------ src/plugins/lacp/rx_machine.h | 6 +- src/plugins/lacp/selection.c | 52 ++++---- src/plugins/lacp/test/test_lacp.py | 82 ++++++------- src/plugins/lacp/tx_machine.c | 24 ++-- src/plugins/lacp/tx_machine.h | 2 +- 16 files changed, 631 insertions(+), 630 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/lacp/cli.c b/src/plugins/lacp/cli.c index fee1be19463..7abc6f0c4ca 100644 --- a/src/plugins/lacp/cli.c +++ b/src/plugins/lacp/cli.c @@ -22,44 +22,44 @@ lacp_dump_ifs (lacp_interface_details_t ** out_lacpifs) { vnet_main_t *vnm = vnet_get_main (); bond_main_t *bm = &bond_main; - slave_if_t *sif; + member_if_t *mif; bond_if_t *bif; vnet_hw_interface_t *hi; lacp_interface_details_t *r_lacpifs = NULL; lacp_interface_details_t *lacpif = NULL; /* *INDENT-OFF* */ - pool_foreach (sif, bm->neighbors, - if (sif->lacp_enabled == 0) + pool_foreach (mif, bm->neighbors, + if (mif->lacp_enabled == 0) continue; vec_add2(r_lacpifs, lacpif, 1); clib_memset (lacpif, 0, sizeof (*lacpif)); - lacpif->sw_if_index = sif->sw_if_index; - hi = vnet_get_hw_interface (vnm, sif->hw_if_index); + lacpif->sw_if_index = mif->sw_if_index; + hi = vnet_get_hw_interface (vnm, mif->hw_if_index); clib_memcpy(lacpif->interface_name, hi->name, MIN (ARRAY_LEN (lacpif->interface_name) - 1, vec_len (hi->name))); - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); hi = vnet_get_hw_interface (vnm, bif->hw_if_index); clib_memcpy(lacpif->bond_interface_name, hi->name, MIN (ARRAY_LEN (lacpif->bond_interface_name) - 1, vec_len (hi->name))); - clib_memcpy (lacpif->actor_system, sif->actor.system, 6); - lacpif->actor_system_priority = sif->actor.system_priority; - lacpif->actor_key = sif->actor.key; - lacpif->actor_port_priority = sif->actor.port_priority; - lacpif->actor_port_number = sif->actor.port_number; - lacpif->actor_state = sif->actor.state; - clib_memcpy (lacpif->partner_system, sif->partner.system, 6); - lacpif->partner_system_priority = sif->partner.system_priority; - lacpif->partner_key = sif->partner.key; - lacpif->partner_port_priority = sif->partner.port_priority; - lacpif->partner_port_number = sif->partner.port_number; - lacpif->partner_state = sif->partner.state; - lacpif->rx_state = sif->rx_state; - lacpif->tx_state = sif->tx_state; - lacpif->ptx_state = sif->ptx_state; - lacpif->mux_state = sif->mux_state; + clib_memcpy (lacpif->actor_system, mif->actor.system, 6); + lacpif->actor_system_priority = mif->actor.system_priority; + lacpif->actor_key = mif->actor.key; + lacpif->actor_port_priority = mif->actor.port_priority; + lacpif->actor_port_number = mif->actor.port_number; + lacpif->actor_state = mif->actor.state; + clib_memcpy (lacpif->partner_system, mif->partner.system, 6); + lacpif->partner_system_priority = mif->partner.system_priority; + lacpif->partner_key = mif->partner.key; + lacpif->partner_port_priority = mif->partner.port_priority; + lacpif->partner_port_number = mif->partner.port_number; + lacpif->partner_state = mif->partner.state; + lacpif->rx_state = mif->rx_state; + lacpif->tx_state = mif->tx_state; + lacpif->ptx_state = mif->ptx_state; + lacpif->mux_state = mif->mux_state; ); /* *INDENT-ON* */ @@ -72,7 +72,7 @@ static void show_lacp (vlib_main_t * vm, u32 * sw_if_indices) { int i; - slave_if_t *sif; + member_if_t *mif; bond_if_t *bif; if (!sw_if_indices) @@ -87,56 +87,56 @@ show_lacp (vlib_main_t * vm, u32 * sw_if_indices) for (i = 0; i < vec_len (sw_if_indices); i++) { - sif = bond_get_slave_by_sw_if_index (sw_if_indices[i]); - if (!sif || (sif->lacp_enabled == 0)) + mif = bond_get_member_by_sw_if_index (sw_if_indices[i]); + if (!mif || (mif->lacp_enabled == 0)) continue; - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); vlib_cli_output (vm, "%-25U %-12d %-16U %3x %3x %3x %3x %3x %3x %3x %3x " "%4x %3x %3x %3x %3x %3x %3x %3x", format_vnet_sw_if_index_name, vnet_get_main (), - sif->sw_if_index, sif->sw_if_index, + mif->sw_if_index, mif->sw_if_index, format_vnet_sw_if_index_name, vnet_get_main (), - bif->sw_if_index, lacp_bit_test (sif->actor.state, 7), - lacp_bit_test (sif->actor.state, 6), - lacp_bit_test (sif->actor.state, 5), - lacp_bit_test (sif->actor.state, 4), - lacp_bit_test (sif->actor.state, 3), - lacp_bit_test (sif->actor.state, 2), - lacp_bit_test (sif->actor.state, 1), - lacp_bit_test (sif->actor.state, 0), - lacp_bit_test (sif->partner.state, 7), - lacp_bit_test (sif->partner.state, 6), - lacp_bit_test (sif->partner.state, 5), - lacp_bit_test (sif->partner.state, 4), - lacp_bit_test (sif->partner.state, 3), - lacp_bit_test (sif->partner.state, 2), - lacp_bit_test (sif->partner.state, 1), - lacp_bit_test (sif->partner.state, 0)); + bif->sw_if_index, lacp_bit_test (mif->actor.state, 7), + lacp_bit_test (mif->actor.state, 6), + lacp_bit_test (mif->actor.state, 5), + lacp_bit_test (mif->actor.state, 4), + lacp_bit_test (mif->actor.state, 3), + lacp_bit_test (mif->actor.state, 2), + lacp_bit_test (mif->actor.state, 1), + lacp_bit_test (mif->actor.state, 0), + lacp_bit_test (mif->partner.state, 7), + lacp_bit_test (mif->partner.state, 6), + lacp_bit_test (mif->partner.state, 5), + lacp_bit_test (mif->partner.state, 4), + lacp_bit_test (mif->partner.state, 3), + lacp_bit_test (mif->partner.state, 2), + lacp_bit_test (mif->partner.state, 1), + lacp_bit_test (mif->partner.state, 0)); vlib_cli_output (vm, " LAG ID: " "[(%04x,%02x-%02x-%02x-%02x-%02x-%02x,%04x,%04x,%04x), " "(%04x,%02x-%02x-%02x-%02x-%02x-%02x,%04x,%04x,%04x)]", - ntohs (sif->actor.system_priority), - sif->actor.system[0], sif->actor.system[1], - sif->actor.system[2], sif->actor.system[3], - sif->actor.system[4], sif->actor.system[5], - ntohs (sif->actor.key), - ntohs (sif->actor.port_priority), - ntohs (sif->actor.port_number), - ntohs (sif->partner.system_priority), - sif->partner.system[0], sif->partner.system[1], - sif->partner.system[2], sif->partner.system[3], - sif->partner.system[4], sif->partner.system[5], - ntohs (sif->partner.key), - ntohs (sif->partner.port_priority), - ntohs (sif->partner.port_number)); + ntohs (mif->actor.system_priority), + mif->actor.system[0], mif->actor.system[1], + mif->actor.system[2], mif->actor.system[3], + mif->actor.system[4], mif->actor.system[5], + ntohs (mif->actor.key), + ntohs (mif->actor.port_priority), + ntohs (mif->actor.port_number), + ntohs (mif->partner.system_priority), + mif->partner.system[0], mif->partner.system[1], + mif->partner.system[2], mif->partner.system[3], + mif->partner.system[4], mif->partner.system[5], + ntohs (mif->partner.key), + ntohs (mif->partner.port_priority), + ntohs (mif->partner.port_number)); vlib_cli_output (vm, " RX-state: %U, TX-state: %U, " "MUX-state: %U, PTX-state: %U", - format_rx_sm_state, sif->rx_state, format_tx_sm_state, - sif->tx_state, format_mux_sm_state, sif->mux_state, - format_ptx_sm_state, sif->ptx_state); + format_rx_sm_state, mif->rx_state, format_tx_sm_state, + mif->tx_state, format_mux_sm_state, mif->mux_state, + format_ptx_sm_state, mif->ptx_state); } } @@ -144,7 +144,7 @@ static void show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices) { lacp_main_t *lm = &lacp_main; - slave_if_t *sif; + member_if_t *mif; lacp_state_struct *state_entry; int i; f64 now; @@ -156,56 +156,56 @@ show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices) now = vlib_time_now (vm); for (i = 0; i < vec_len (sw_if_indices); i++) { - sif = bond_get_slave_by_sw_if_index (sw_if_indices[i]); - if (!sif || (sif->lacp_enabled == 0)) + mif = bond_get_member_by_sw_if_index (sw_if_indices[i]); + if (!mif || (mif->lacp_enabled == 0)) continue; vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name, - vnet_get_main (), sif->sw_if_index); + vnet_get_main (), mif->sw_if_index); vlib_cli_output (vm, " Good LACP PDUs received: %llu", - sif->pdu_received); + mif->pdu_received); vlib_cli_output (vm, " Bad LACP PDUs received: %llu", - sif->bad_pdu_received); - vlib_cli_output (vm, " LACP PDUs sent: %llu", sif->pdu_sent); - if (lacp_timer_is_running (sif->last_lacpdu_recd_time)) + mif->bad_pdu_received); + vlib_cli_output (vm, " LACP PDUs sent: %llu", mif->pdu_sent); + if (lacp_timer_is_running (mif->last_lacpdu_recd_time)) vlib_cli_output (vm, " last LACP PDU received: %10.2f seconds ago", - now - sif->last_lacpdu_recd_time); - if (lacp_timer_is_running (sif->last_lacpdu_sent_time)) + now - mif->last_lacpdu_recd_time); + if (lacp_timer_is_running (mif->last_lacpdu_sent_time)) vlib_cli_output (vm, " last LACP PDU sent: %10.2f seconds ago", - now - sif->last_lacpdu_sent_time); + now - mif->last_lacpdu_sent_time); vlib_cli_output (vm, " Good Marker PDUs received: %llu", - sif->marker_pdu_received); + mif->marker_pdu_received); vlib_cli_output (vm, " Bad Marker PDUs received: %llu", - sif->marker_bad_pdu_received); - if (lacp_timer_is_running (sif->last_marker_pdu_recd_time)) + mif->marker_bad_pdu_received); + if (lacp_timer_is_running (mif->last_marker_pdu_recd_time)) vlib_cli_output (vm, " last Marker PDU received: %10.2f seconds ago", - now - sif->last_marker_pdu_recd_time); - if (lacp_timer_is_running (sif->last_marker_pdu_sent_time)) + now - mif->last_marker_pdu_recd_time); + if (lacp_timer_is_running (mif->last_marker_pdu_sent_time)) vlib_cli_output (vm, " last Marker PDU sent: %10.2f seconds ago", - now - sif->last_marker_pdu_sent_time); - vlib_cli_output (vm, " debug: %d", sif->debug); - vlib_cli_output (vm, " loopback port: %d", sif->loopback_port); - vlib_cli_output (vm, " port_enabled: %d", sif->port_enabled); - vlib_cli_output (vm, " port moved: %d", sif->port_moved); - vlib_cli_output (vm, " ready_n: %d", sif->ready_n); - vlib_cli_output (vm, " ready: %d", sif->ready); + now - mif->last_marker_pdu_sent_time); + vlib_cli_output (vm, " debug: %d", mif->debug); + vlib_cli_output (vm, " loopback port: %d", mif->loopback_port); + vlib_cli_output (vm, " port_enabled: %d", mif->port_enabled); + vlib_cli_output (vm, " port moved: %d", mif->port_moved); + vlib_cli_output (vm, " ready_n: %d", mif->ready_n); + vlib_cli_output (vm, " ready: %d", mif->ready); vlib_cli_output (vm, " Actor"); vlib_cli_output (vm, " system: %U", - format_ethernet_address, sif->actor.system); + format_ethernet_address, mif->actor.system); vlib_cli_output (vm, " system priority: %u", - ntohs (sif->actor.system_priority)); - vlib_cli_output (vm, " key: %u", ntohs (sif->actor.key)); + ntohs (mif->actor.system_priority)); + vlib_cli_output (vm, " key: %u", ntohs (mif->actor.key)); vlib_cli_output (vm, " port priority: %u", - ntohs (sif->actor.port_priority)); + ntohs (mif->actor.port_priority)); vlib_cli_output (vm, " port number: %u", - ntohs (sif->actor.port_number)); - vlib_cli_output (vm, " state: 0x%x", sif->actor.state); + ntohs (mif->actor.port_number)); + vlib_cli_output (vm, " state: 0x%x", mif->actor.state); state_entry = (lacp_state_struct *) & lacp_state_array; while (state_entry->str) { - if (sif->actor.state & (1 << state_entry->bit)) + if (mif->actor.state & (1 << state_entry->bit)) vlib_cli_output (vm, " %s (%d)", state_entry->str, state_entry->bit); state_entry++; @@ -213,48 +213,48 @@ show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices) vlib_cli_output (vm, " Partner"); vlib_cli_output (vm, " system: %U", - format_ethernet_address, sif->partner.system); + format_ethernet_address, mif->partner.system); vlib_cli_output (vm, " system priority: %u", - ntohs (sif->partner.system_priority)); - vlib_cli_output (vm, " key: %u", ntohs (sif->partner.key)); + ntohs (mif->partner.system_priority)); + vlib_cli_output (vm, " key: %u", ntohs (mif->partner.key)); vlib_cli_output (vm, " port priority: %u", - ntohs (sif->partner.port_priority)); + ntohs (mif->partner.port_priority)); vlib_cli_output (vm, " port number: %u", - ntohs (sif->partner.port_number)); - vlib_cli_output (vm, " state: 0x%x", sif->partner.state); + ntohs (mif->partner.port_number)); + vlib_cli_output (vm, " state: 0x%x", mif->partner.state); state_entry = (lacp_state_struct *) & lacp_state_array; while (state_entry->str) { - if (sif->partner.state & (1 << state_entry->bit)) + if (mif->partner.state & (1 << state_entry->bit)) vlib_cli_output (vm, " %s (%d)", state_entry->str, state_entry->bit); state_entry++; } - if (!lacp_timer_is_running (sif->wait_while_timer)) + if (!lacp_timer_is_running (mif->wait_while_timer)) vlib_cli_output (vm, " wait while timer: not running"); else vlib_cli_output (vm, " wait while timer: %10.2f seconds", - sif->wait_while_timer - now); - if (!lacp_timer_is_running (sif->current_while_timer)) + mif->wait_while_timer - now); + if (!lacp_timer_is_running (mif->current_while_timer)) vlib_cli_output (vm, " current while timer: not running"); else vlib_cli_output (vm, " current while timer: %10.2f seconds", - sif->current_while_timer - now); - if (!lacp_timer_is_running (sif->periodic_timer)) + mif->current_while_timer - now); + if (!lacp_timer_is_running (mif->periodic_timer)) vlib_cli_output (vm, " periodic timer: not running"); else vlib_cli_output (vm, " periodic timer: %10.2f seconds", - sif->periodic_timer - now); + mif->periodic_timer - now); vlib_cli_output (vm, " RX-state: %U", format_rx_sm_state, - sif->rx_state); + mif->rx_state); vlib_cli_output (vm, " TX-state: %U", format_tx_sm_state, - sif->tx_state); + mif->tx_state); vlib_cli_output (vm, " MUX-state: %U", format_mux_sm_state, - sif->mux_state); + mif->mux_state); vlib_cli_output (vm, " PTX-state: %U", format_ptx_sm_state, - sif->ptx_state); + mif->ptx_state); vlib_cli_output (vm, "\n"); } } @@ -265,7 +265,7 @@ show_lacp_fn (vlib_main_t * vm, unformat_input_t * input, { bond_main_t *bm = &bond_main; vnet_main_t *vnm = &vnet_main; - slave_if_t *sif; + member_if_t *mif; clib_error_t *error = 0; u8 details = 0; u32 sw_if_index, *sw_if_indices = 0; @@ -275,13 +275,13 @@ show_lacp_fn (vlib_main_t * vm, unformat_input_t * input, if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) { - sif = bond_get_slave_by_sw_if_index (sw_if_index); - if (!sif) + mif = bond_get_member_by_sw_if_index (sw_if_index); + if (!mif) { - error = clib_error_return (0, "interface is not enslaved"); + error = clib_error_return (0, "interface is not a member"); goto done; } - vec_add1 (sw_if_indices, sif->sw_if_index); + vec_add1 (sw_if_indices, mif->sw_if_index); } else if (unformat (input, "details")) details = 1; @@ -295,8 +295,8 @@ show_lacp_fn (vlib_main_t * vm, unformat_input_t * input, if (vec_len (sw_if_indices) == 0) { - pool_foreach (sif, bm->neighbors, - vec_add1 (sw_if_indices, sif->sw_if_index); + pool_foreach (mif, bm->neighbors, + vec_add1 (sw_if_indices, mif->sw_if_index); ); } @@ -329,7 +329,7 @@ debug_lacp_command_fn (vlib_main_t * vm, unformat_input_t * input, u8 onoff = 0; u8 input_found = 0; u32 sw_if_index = ~0; - slave_if_t *sif; + member_if_t *mif; vnet_main_t *vnm = vnet_get_main (); /* Get a line of input. */ @@ -370,10 +370,11 @@ debug_lacp_command_fn (vlib_main_t * vm, unformat_input_t * input, if (sw_if_index != ~0) { - sif = bond_get_slave_by_sw_if_index (sw_if_index); - if (!sif) - return (clib_error_return (0, "Please enslave the interface first")); - sif->debug = onoff; + mif = bond_get_member_by_sw_if_index (sw_if_index); + if (!mif) + return (clib_error_return + (0, "Please add the member interface first")); + mif->debug = onoff; } else lm->debug = onoff; diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c index fd1296afe3e..4a69e0fb02a 100644 --- a/src/plugins/lacp/input.c +++ b/src/plugins/lacp/input.c @@ -19,9 +19,9 @@ #include static int -lacp_packet_scan (vlib_main_t * vm, slave_if_t * sif) +lacp_packet_scan (vlib_main_t * vm, member_if_t * mif) { - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; if (lacpdu->subtype != LACP_SUBTYPE) return LACP_ERROR_UNSUPPORTED; @@ -36,33 +36,33 @@ lacp_packet_scan (vlib_main_t * vm, slave_if_t * sif) (lacpdu->terminator.tlv_length != 0)) return (LACP_ERROR_BAD_TLV); - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PDU_RECEIVED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PDU_RECEIVED, &mif->rx_state); return LACP_ERROR_NONE; } static void -marker_fill_pdu (marker_pdu_t * marker, slave_if_t * sif) +marker_fill_pdu (marker_pdu_t * marker, member_if_t * mif) { - marker_pdu_t *pkt = (marker_pdu_t *) sif->last_marker_pkt; + marker_pdu_t *pkt = (marker_pdu_t *) mif->last_marker_pkt; marker->marker_info = pkt->marker_info; marker->marker_info.tlv_type = MARKER_RESPONSE_INFORMATION; } void -marker_fill_request_pdu (marker_pdu_t * marker, slave_if_t * sif) +marker_fill_request_pdu (marker_pdu_t * marker, member_if_t * mif) { marker->marker_info.tlv_type = MARKER_INFORMATION; - marker->marker_info.requester_port = sif->actor.port_number; - clib_memcpy (marker->marker_info.requester_system, sif->actor.system, 6); - marker->marker_info.requester_transaction_id = sif->marker_tx_id; - sif->marker_tx_id++; + marker->marker_info.requester_port = mif->actor.port_number; + clib_memcpy (marker->marker_info.requester_system, mif->actor.system, 6); + marker->marker_info.requester_transaction_id = mif->marker_tx_id; + mif->marker_tx_id++; } static void -send_ethernet_marker_response_pdu (vlib_main_t * vm, slave_if_t * sif) +send_ethernet_marker_response_pdu (vlib_main_t * vm, member_if_t * mif) { lacp_main_t *lm = &lacp_main; u32 *to_next; @@ -78,18 +78,18 @@ send_ethernet_marker_response_pdu (vlib_main_t * vm, slave_if_t * sif) * into the buffer by the packet template mechanism */ h0 = vlib_packet_template_get_packet - (vm, &lm->marker_packet_templates[sif->packet_template_index], &bi0); + (vm, &lm->marker_packet_templates[mif->packet_template_index], &bi0); if (!h0) return; /* Add the interface's ethernet source address */ - hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index); + hw = vnet_get_sup_hw_interface (vnm, mif->sw_if_index); clib_memcpy (h0->ethernet.src_address, hw->hw_address, vec_len (hw->hw_address)); - marker_fill_pdu (&h0->marker, sif); + marker_fill_pdu (&h0->marker, mif); /* Set the outbound packet length */ b0 = vlib_get_buffer (vm, bi0); @@ -108,14 +108,14 @@ send_ethernet_marker_response_pdu (vlib_main_t * vm, slave_if_t * sif) f->n_vectors = 1; vlib_put_frame_to_node (vm, hw->output_node_index, f); - sif->last_marker_pdu_sent_time = vlib_time_now (vm); - sif->marker_pdu_sent++; + mif->last_marker_pdu_sent_time = vlib_time_now (vm); + mif->marker_pdu_sent++; } static int -handle_marker_protocol (vlib_main_t * vm, slave_if_t * sif) +handle_marker_protocol (vlib_main_t * vm, member_if_t * mif) { - marker_pdu_t *marker = (marker_pdu_t *) sif->last_marker_pkt; + marker_pdu_t *marker = (marker_pdu_t *) mif->last_marker_pkt; /* * According to the spec, no checking on the version number and tlv types. @@ -125,7 +125,7 @@ handle_marker_protocol (vlib_main_t * vm, slave_if_t * sif) (marker->terminator.tlv_length != 0)) return (LACP_ERROR_BAD_TLV); - send_ethernet_marker_response_pdu (vm, sif); + send_ethernet_marker_response_pdu (vm, mif); return LACP_ERROR_NONE; } @@ -137,16 +137,16 @@ lacp_error_t lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0) { bond_main_t *bm = &bond_main; - slave_if_t *sif; + member_if_t *mif; uword nbytes; lacp_error_t e; marker_pdu_t *marker; uword last_packet_signature; bond_if_t *bif; - sif = - bond_get_slave_by_sw_if_index (vnet_buffer (b0)->sw_if_index[VLIB_RX]); - if ((sif == 0) || (sif->mode != BOND_MODE_LACP)) + mif = + bond_get_member_by_sw_if_index (vnet_buffer (b0)->sw_if_index[VLIB_RX]); + if ((mif == 0) || (mif->mode != BOND_MODE_LACP)) { return LACP_ERROR_DISABLED; } @@ -155,20 +155,20 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0) marker = (marker_pdu_t *) (b0->data + b0->current_data); if (marker->subtype == MARKER_SUBTYPE) { - sif->last_marker_pdu_recd_time = vlib_time_now (vm); - if (sif->last_marker_pkt) - _vec_len (sif->last_marker_pkt) = 0; - vec_validate (sif->last_marker_pkt, + mif->last_marker_pdu_recd_time = vlib_time_now (vm); + if (mif->last_marker_pkt) + _vec_len (mif->last_marker_pkt) = 0; + vec_validate (mif->last_marker_pkt, vlib_buffer_length_in_chain (vm, b0) - 1); - nbytes = vlib_buffer_contents (vm, bi0, sif->last_marker_pkt); - ASSERT (nbytes <= vec_len (sif->last_marker_pkt)); + nbytes = vlib_buffer_contents (vm, bi0, mif->last_marker_pkt); + ASSERT (nbytes <= vec_len (mif->last_marker_pkt)); if (nbytes < sizeof (lacp_pdu_t)) { - sif->marker_bad_pdu_received++; + mif->marker_bad_pdu_received++; return LACP_ERROR_TOO_SMALL; } - e = handle_marker_protocol (vm, sif); - sif->marker_pdu_received++; + e = handle_marker_protocol (vm, mif); + mif->marker_pdu_received++; return e; } @@ -177,57 +177,57 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0) * the per-neighbor rx buffer. Reset its apparent length to zero * and reuse it. */ - if (sif->last_rx_pkt) - _vec_len (sif->last_rx_pkt) = 0; + if (mif->last_rx_pkt) + _vec_len (mif->last_rx_pkt) = 0; /* * Make sure the per-neighbor rx buffer is big enough to hold * the data we're about to copy */ - vec_validate (sif->last_rx_pkt, vlib_buffer_length_in_chain (vm, b0) - 1); + vec_validate (mif->last_rx_pkt, vlib_buffer_length_in_chain (vm, b0) - 1); /* * Coalesce / copy the buffer chain into the per-neighbor * rx buffer */ - nbytes = vlib_buffer_contents (vm, bi0, sif->last_rx_pkt); - ASSERT (nbytes <= vec_len (sif->last_rx_pkt)); + nbytes = vlib_buffer_contents (vm, bi0, mif->last_rx_pkt); + ASSERT (nbytes <= vec_len (mif->last_rx_pkt)); - sif->last_lacpdu_recd_time = vlib_time_now (vm); + mif->last_lacpdu_recd_time = vlib_time_now (vm); if (nbytes < sizeof (lacp_pdu_t)) { - sif->bad_pdu_received++; + mif->bad_pdu_received++; return LACP_ERROR_TOO_SMALL; } last_packet_signature = - hash_memory (sif->last_rx_pkt, vec_len (sif->last_rx_pkt), 0xd00b); + hash_memory (mif->last_rx_pkt, vec_len (mif->last_rx_pkt), 0xd00b); - if (sif->last_packet_signature_valid && - (sif->last_packet_signature == last_packet_signature) && - ((sif->actor.state & LACP_STEADY_STATE) == LACP_STEADY_STATE)) + if (mif->last_packet_signature_valid && + (mif->last_packet_signature == last_packet_signature) && + ((mif->actor.state & LACP_STEADY_STATE) == LACP_STEADY_STATE)) { - lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds); + lacp_start_current_while_timer (vm, mif, mif->ttl_in_seconds); e = LACP_ERROR_CACHE_HIT; } else { /* Actually scan the packet */ - e = lacp_packet_scan (vm, sif); - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + e = lacp_packet_scan (vm, mif); + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].actor_state, - sif->actor.state); + [mif->sw_if_index].actor_state, + mif->actor.state); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].partner_state, - sif->partner.state); - sif->last_packet_signature_valid = 1; - sif->last_packet_signature = last_packet_signature; + [mif->sw_if_index].partner_state, + mif->partner.state); + mif->last_packet_signature_valid = 1; + mif->last_packet_signature = last_packet_signature; } - sif->pdu_received++; + mif->pdu_received++; - if (sif->last_rx_pkt) - _vec_len (sif->last_rx_pkt) = 0; + if (mif->last_rx_pkt) + _vec_len (mif->last_rx_pkt) = 0; return e; } diff --git a/src/plugins/lacp/lacp.api b/src/plugins/lacp/lacp.api index d50bd78836b..4ee8f62a880 100644 --- a/src/plugins/lacp/lacp.api +++ b/src/plugins/lacp/lacp.api @@ -31,8 +31,8 @@ define sw_interface_lacp_dump }; /** \brief Reply for lacp dump request - @param sw_if_index - software index of slave interface - @param interface_name - name of slave interface + @param sw_if_index - software index of member interface + @param interface_name - name of member interface @param rx_state - rx machine state @param tx_state - tx machine state @param mux_state - mux machine state diff --git a/src/plugins/lacp/lacp.c b/src/plugins/lacp/lacp.c index 01d8e7b25e0..319a8f79d48 100644 --- a/src/plugins/lacp/lacp.c +++ b/src/plugins/lacp/lacp.c @@ -29,20 +29,20 @@ lacp_main_t lacp_main; * Generate lacp pdu */ static void -lacp_fill_pdu (lacp_pdu_t * lacpdu, slave_if_t * sif) +lacp_fill_pdu (lacp_pdu_t * lacpdu, member_if_t * mif) { /* Actor TLV */ - lacpdu->actor.port_info = sif->actor; + lacpdu->actor.port_info = mif->actor; /* Partner TLV */ - lacpdu->partner.port_info = sif->partner; + lacpdu->partner.port_info = mif->partner; } /* * send a lacp pkt on an ethernet interface */ static void -lacp_send_ethernet_lacp_pdu (vlib_main_t * vm, slave_if_t * sif) +lacp_send_ethernet_lacp_pdu (vlib_main_t * vm, member_if_t * mif) { lacp_main_t *lm = &lacp_main; u32 *to_next; @@ -58,18 +58,18 @@ lacp_send_ethernet_lacp_pdu (vlib_main_t * vm, slave_if_t * sif) * into the buffer by the packet template mechanism */ h0 = vlib_packet_template_get_packet - (vm, &lm->packet_templates[sif->packet_template_index], &bi0); + (vm, &lm->packet_templates[mif->packet_template_index], &bi0); if (!h0) return; /* Add the interface's ethernet source address */ - hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index); + hw = vnet_get_sup_hw_interface (vnm, mif->sw_if_index); clib_memcpy (h0->ethernet.src_address, hw->hw_address, vec_len (hw->hw_address)); - lacp_fill_pdu (&h0->lacp, sif); + lacp_fill_pdu (&h0->lacp, mif); /* Set the outbound packet length */ b0 = vlib_get_buffer (vm, bi0); @@ -89,44 +89,44 @@ lacp_send_ethernet_lacp_pdu (vlib_main_t * vm, slave_if_t * sif) vlib_put_frame_to_node (vm, hw->output_node_index, f); - sif->last_lacpdu_sent_time = vlib_time_now (vm); - sif->pdu_sent++; + mif->last_lacpdu_sent_time = vlib_time_now (vm); + mif->pdu_sent++; } /* * Decide which lacp packet template to use */ static int -lacp_pick_packet_template (slave_if_t * sif) +lacp_pick_packet_template (member_if_t * mif) { - sif->packet_template_index = LACP_PACKET_TEMPLATE_ETHERNET; + mif->packet_template_index = LACP_PACKET_TEMPLATE_ETHERNET; return 0; } void -lacp_send_lacp_pdu (vlib_main_t * vm, slave_if_t * sif) +lacp_send_lacp_pdu (vlib_main_t * vm, member_if_t * mif) { - if ((sif->mode != BOND_MODE_LACP) || (sif->port_enabled == 0)) + if ((mif->mode != BOND_MODE_LACP) || (mif->port_enabled == 0)) { - lacp_stop_timer (&sif->periodic_timer); + lacp_stop_timer (&mif->periodic_timer); return; } - if (sif->packet_template_index == (u8) ~ 0) + if (mif->packet_template_index == (u8) ~ 0) { /* If we don't know how to talk to this peer, don't try again */ - if (lacp_pick_packet_template (sif)) + if (lacp_pick_packet_template (mif)) { - lacp_stop_timer (&sif->periodic_timer); + lacp_stop_timer (&mif->periodic_timer); return; } } - switch (sif->packet_template_index) + switch (mif->packet_template_index) { case LACP_PACKET_TEMPLATE_ETHERNET: - lacp_send_ethernet_lacp_pdu (vm, sif); + lacp_send_ethernet_lacp_pdu (vm, mif); break; default: @@ -138,51 +138,51 @@ void lacp_periodic (vlib_main_t * vm) { bond_main_t *bm = &bond_main; - slave_if_t *sif; + member_if_t *mif; bond_if_t *bif; u8 actor_state, partner_state; /* *INDENT-OFF* */ - pool_foreach (sif, bm->neighbors, + pool_foreach (mif, bm->neighbors, ({ - if (sif->port_enabled == 0) + if (mif->port_enabled == 0) continue; - actor_state = sif->actor.state; - partner_state = sif->partner.state; - if (lacp_timer_is_running (sif->current_while_timer) && - lacp_timer_is_expired (vm, sif->current_while_timer)) + actor_state = mif->actor.state; + partner_state = mif->partner.state; + if (lacp_timer_is_running (mif->current_while_timer) && + lacp_timer_is_expired (vm, mif->current_while_timer)) { - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_TIMER_EXPIRED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_TIMER_EXPIRED, &mif->rx_state); } - if (lacp_timer_is_running (sif->periodic_timer) && - lacp_timer_is_expired (vm, sif->periodic_timer)) + if (lacp_timer_is_running (mif->periodic_timer) && + lacp_timer_is_expired (vm, mif->periodic_timer)) { - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_TIMER_EXPIRED, &sif->ptx_state); + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_TIMER_EXPIRED, &mif->ptx_state); } - if (lacp_timer_is_running (sif->wait_while_timer) && - lacp_timer_is_expired (vm, sif->wait_while_timer)) + if (lacp_timer_is_running (mif->wait_while_timer) && + lacp_timer_is_expired (vm, mif->wait_while_timer)) { - sif->ready_n = 1; - lacp_stop_timer (&sif->wait_while_timer); - lacp_selection_logic (vm, sif); + mif->ready_n = 1; + lacp_stop_timer (&mif->wait_while_timer); + lacp_selection_logic (vm, mif); } - if (actor_state != sif->actor.state) + if (actor_state != mif->actor.state) { - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].actor_state, - sif->actor.state); + [mif->sw_if_index].actor_state, + mif->actor.state); } - if (partner_state != sif->partner.state) + if (partner_state != mif->partner.state) { - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].partner_state, - sif->partner.state); + [mif->sw_if_index].partner_state, + mif->partner.state); } })); /* *INDENT-ON* */ @@ -190,7 +190,7 @@ lacp_periodic (vlib_main_t * vm) static void lacp_interface_enable_disable (vlib_main_t * vm, bond_if_t * bif, - slave_if_t * sif, u8 enable) + member_if_t * mif, u8 enable) { lacp_main_t *lm = &lacp_main; uword port_number; @@ -202,8 +202,8 @@ lacp_interface_enable_disable (vlib_main_t * vm, bond_if_t * bif, bif->port_number_bitmap = clib_bitmap_set (bif->port_number_bitmap, port_number, 1); // bitmap starts at 0. Our port number starts at 1. - lacp_init_neighbor (sif, bif->hw_address, port_number + 1, sif->group); - lacp_init_state_machines (vm, sif); + lacp_init_neighbor (mif, bif->hw_address, port_number + 1, mif->group); + lacp_init_state_machines (vm, mif); lm->lacp_int++; if (lm->lacp_int == 1) { @@ -315,77 +315,77 @@ lacp_periodic_init (vlib_main_t * vm) int lacp_machine_dispatch (lacp_machine_t * machine, vlib_main_t * vm, - slave_if_t * sif, int event, int *state) + member_if_t * mif, int event, int *state) { lacp_fsm_state_t *transition; int rc = 0; transition = &machine->tables[*state].state_table[event]; - LACP_DBG2 (sif, event, *state, machine, transition); + LACP_DBG2 (mif, event, *state, machine, transition); *state = transition->next_state; if (transition->action) - rc = (*transition->action) ((void *) vm, (void *) sif); + rc = (*transition->action) ((void *) vm, (void *) mif); return rc; } void -lacp_init_neighbor (slave_if_t * sif, u8 * hw_address, u16 port_number, +lacp_init_neighbor (member_if_t * mif, u8 * hw_address, u16 port_number, u32 group) { - lacp_stop_timer (&sif->wait_while_timer); - lacp_stop_timer (&sif->current_while_timer); - lacp_stop_timer (&sif->actor_churn_timer); - lacp_stop_timer (&sif->partner_churn_timer); - lacp_stop_timer (&sif->periodic_timer); - lacp_stop_timer (&sif->last_lacpdu_sent_time); - lacp_stop_timer (&sif->last_lacpdu_recd_time); - lacp_stop_timer (&sif->last_marker_pdu_sent_time); - lacp_stop_timer (&sif->last_marker_pdu_recd_time); - sif->lacp_enabled = 1; - sif->loopback_port = 0; - sif->ready = 0; - sif->ready_n = 0; - sif->port_moved = 0; - sif->ntt = 0; - sif->selected = LACP_PORT_UNSELECTED; - sif->actor.state = LACP_STATE_AGGREGATION; - if (sif->ttl_in_seconds == LACP_SHORT_TIMOUT_TIME) - sif->actor.state |= LACP_STATE_LACP_TIMEOUT; - if (sif->is_passive == 0) - sif->actor.state |= LACP_STATE_LACP_ACTIVITY; - clib_memcpy (sif->actor.system, hw_address, 6); - sif->actor.system_priority = htons (LACP_DEFAULT_SYSTEM_PRIORITY); - sif->actor.key = htons (group); - sif->actor.port_number = htons (port_number); - sif->actor.port_priority = htons (LACP_DEFAULT_PORT_PRIORITY); - - sif->partner.system_priority = htons (LACP_DEFAULT_SYSTEM_PRIORITY); - sif->partner.key = htons (group); - sif->partner.port_number = htons (port_number); - sif->partner.port_priority = htons (LACP_DEFAULT_PORT_PRIORITY); - sif->partner.state = 0; - - sif->actor_admin = sif->actor; - sif->partner_admin = sif->partner; + lacp_stop_timer (&mif->wait_while_timer); + lacp_stop_timer (&mif->current_while_timer); + lacp_stop_timer (&mif->actor_churn_timer); + lacp_stop_timer (&mif->partner_churn_timer); + lacp_stop_timer (&mif->periodic_timer); + lacp_stop_timer (&mif->last_lacpdu_sent_time); + lacp_stop_timer (&mif->last_lacpdu_recd_time); + lacp_stop_timer (&mif->last_marker_pdu_sent_time); + lacp_stop_timer (&mif->last_marker_pdu_recd_time); + mif->lacp_enabled = 1; + mif->loopback_port = 0; + mif->ready = 0; + mif->ready_n = 0; + mif->port_moved = 0; + mif->ntt = 0; + mif->selected = LACP_PORT_UNSELECTED; + mif->actor.state = LACP_STATE_AGGREGATION; + if (mif->ttl_in_seconds == LACP_SHORT_TIMOUT_TIME) + mif->actor.state |= LACP_STATE_LACP_TIMEOUT; + if (mif->is_passive == 0) + mif->actor.state |= LACP_STATE_LACP_ACTIVITY; + clib_memcpy (mif->actor.system, hw_address, 6); + mif->actor.system_priority = htons (LACP_DEFAULT_SYSTEM_PRIORITY); + mif->actor.key = htons (group); + mif->actor.port_number = htons (port_number); + mif->actor.port_priority = htons (LACP_DEFAULT_PORT_PRIORITY); + + mif->partner.system_priority = htons (LACP_DEFAULT_SYSTEM_PRIORITY); + mif->partner.key = htons (group); + mif->partner.port_number = htons (port_number); + mif->partner.port_priority = htons (LACP_DEFAULT_PORT_PRIORITY); + mif->partner.state = 0; + + mif->actor_admin = mif->actor; + mif->partner_admin = mif->partner; } void -lacp_init_state_machines (vlib_main_t * vm, slave_if_t * sif) +lacp_init_state_machines (vlib_main_t * vm, member_if_t * mif) { bond_main_t *bm = &bond_main; - bond_if_t *bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); + bond_if_t *bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); - lacp_init_tx_machine (vm, sif); - lacp_init_mux_machine (vm, sif); - lacp_init_ptx_machine (vm, sif); - lacp_init_rx_machine (vm, sif); + lacp_init_tx_machine (vm, mif); + lacp_init_mux_machine (vm, mif); + lacp_init_ptx_machine (vm, mif); + lacp_init_rx_machine (vm, mif); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].actor_state, - sif->actor.state); + [mif->sw_if_index].actor_state, + mif->actor.state); stat_segment_set_state_counter (bm->stats[bif->sw_if_index] - [sif->sw_if_index].partner_state, - sif->partner.state); + [mif->sw_if_index].partner_state, + mif->partner.state); } VLIB_INIT_FUNCTION (lacp_periodic_init); @@ -394,24 +394,24 @@ static clib_error_t * lacp_sw_interface_up_down (vnet_main_t * vnm, u32 sw_if_index, u32 flags) { lacp_main_t *lm = &lacp_main; - slave_if_t *sif; + member_if_t *mif; vlib_main_t *vm = lm->vlib_main; - sif = bond_get_slave_by_sw_if_index (sw_if_index); - if (sif) + mif = bond_get_member_by_sw_if_index (sw_if_index); + if (mif) { - if (sif->lacp_enabled == 0) + if (mif->lacp_enabled == 0) return 0; /* port_enabled is both admin up and hw link up */ - sif->port_enabled = ((flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) && + mif->port_enabled = ((flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) && vnet_sw_interface_is_link_up (vnm, sw_if_index)); - if (sif->port_enabled == 0) + if (mif->port_enabled == 0) { - lacp_init_neighbor (sif, sif->actor_admin.system, - ntohs (sif->actor_admin.port_number), - ntohs (sif->actor_admin.key)); - lacp_init_state_machines (vm, sif); + lacp_init_neighbor (mif, mif->actor_admin.system, + ntohs (mif->actor_admin.port_number), + ntohs (mif->actor_admin.key)); + lacp_init_state_machines (vm, mif); } } @@ -424,27 +424,27 @@ static clib_error_t * lacp_hw_interface_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) { lacp_main_t *lm = &lacp_main; - slave_if_t *sif; + member_if_t *mif; vnet_sw_interface_t *sw; vlib_main_t *vm = lm->vlib_main; sw = vnet_get_hw_sw_interface (vnm, hw_if_index); - sif = bond_get_slave_by_sw_if_index (sw->sw_if_index); - if (sif) + mif = bond_get_member_by_sw_if_index (sw->sw_if_index); + if (mif) { - if (sif->lacp_enabled == 0) + if (mif->lacp_enabled == 0) return 0; /* port_enabled is both admin up and hw link up */ - sif->port_enabled = ((flags & VNET_HW_INTERFACE_FLAG_LINK_UP) && + mif->port_enabled = ((flags & VNET_HW_INTERFACE_FLAG_LINK_UP) && vnet_sw_interface_is_admin_up (vnm, sw->sw_if_index)); - if (sif->port_enabled == 0) + if (mif->port_enabled == 0) { - lacp_init_neighbor (sif, sif->actor_admin.system, - ntohs (sif->actor_admin.port_number), - ntohs (sif->actor_admin.key)); - lacp_init_state_machines (vm, sif); + lacp_init_neighbor (mif, mif->actor_admin.system, + ntohs (mif->actor_admin.port_number), + ntohs (mif->actor_admin.key)); + lacp_init_state_machines (vm, mif); } } diff --git a/src/plugins/lacp/machine.h b/src/plugins/lacp/machine.h index 0590b6cf101..2e628b6d51c 100644 --- a/src/plugins/lacp/machine.h +++ b/src/plugins/lacp/machine.h @@ -29,7 +29,7 @@ typedef struct int next_state; } lacp_fsm_state_t; -typedef void (*debug_func) (slave_if_t * sif, int event, int state, +typedef void (*debug_func) (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); typedef struct @@ -44,7 +44,7 @@ typedef struct } lacp_machine_t; extern int lacp_machine_dispatch (lacp_machine_t * machine, vlib_main_t * vm, - slave_if_t * sif, int event, int *state); + member_if_t * mif, int event, int *state); #endif /* __LACP_MACHINE_H__ */ diff --git a/src/plugins/lacp/mux_machine.c b/src/plugins/lacp/mux_machine.c index 6a5549077a2..974dbd9dac9 100644 --- a/src/plugins/lacp/mux_machine.c +++ b/src/plugins/lacp/mux_machine.c @@ -80,39 +80,39 @@ lacp_machine_t lacp_mux_machine = { }; static void -lacp_detach_mux_from_aggregator (vlib_main_t * vm, slave_if_t * sif) +lacp_detach_mux_from_aggregator (vlib_main_t * vm, member_if_t * mif) { - sif->actor.state &= ~LACP_STATE_SYNCHRONIZATION; - sif->ready = 0; - sif->ready_n = 0; + mif->actor.state &= ~LACP_STATE_SYNCHRONIZATION; + mif->ready = 0; + mif->ready_n = 0; } static void -lacp_attach_mux_to_aggregator (vlib_main_t * vm, slave_if_t * sif) +lacp_attach_mux_to_aggregator (vlib_main_t * vm, member_if_t * mif) { - sif->actor.state |= LACP_STATE_SYNCHRONIZATION; + mif->actor.state |= LACP_STATE_SYNCHRONIZATION; } int lacp_mux_action_detached (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_detach_mux_from_aggregator (vm, sif); - sif->actor.state &= ~LACP_STATE_COLLECTING; - bond_disable_collecting_distributing (vm, sif); - sif->actor.state &= ~LACP_STATE_DISTRIBUTING; - sif->ntt = 1; - lacp_start_periodic_timer (vm, sif, 0); + lacp_detach_mux_from_aggregator (vm, mif); + mif->actor.state &= ~LACP_STATE_COLLECTING; + bond_disable_collecting_distributing (vm, mif); + mif->actor.state &= ~LACP_STATE_DISTRIBUTING; + mif->ntt = 1; + lacp_start_periodic_timer (vm, mif, 0); - if (sif->selected == LACP_PORT_SELECTED) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_SELECTED, &sif->mux_state); + if (mif->selected == LACP_PORT_SELECTED) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_SELECTED, &mif->mux_state); - if (sif->selected == LACP_PORT_STANDBY) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, LACP_MUX_EVENT_STANDBY, - &sif->mux_state); + if (mif->selected == LACP_PORT_STANDBY) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, LACP_MUX_EVENT_STANDBY, + &mif->mux_state); return 0; } @@ -121,24 +121,24 @@ int lacp_mux_action_attached (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; - - lacp_attach_mux_to_aggregator (vm, sif); - sif->actor.state &= ~LACP_STATE_COLLECTING; - bond_disable_collecting_distributing (vm, sif); - sif->actor.state &= ~LACP_STATE_DISTRIBUTING; - sif->ntt = 1; - lacp_start_periodic_timer (vm, sif, 0); - - if ((sif->selected == LACP_PORT_UNSELECTED) || - (sif->selected == LACP_PORT_STANDBY)) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_UNSELECTED, &sif->mux_state); - - if ((sif->selected == LACP_PORT_SELECTED) && - (sif->partner.state & LACP_STATE_SYNCHRONIZATION)) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, LACP_MUX_EVENT_SYNC, - &sif->mux_state); + member_if_t *mif = p2; + + lacp_attach_mux_to_aggregator (vm, mif); + mif->actor.state &= ~LACP_STATE_COLLECTING; + bond_disable_collecting_distributing (vm, mif); + mif->actor.state &= ~LACP_STATE_DISTRIBUTING; + mif->ntt = 1; + lacp_start_periodic_timer (vm, mif, 0); + + if ((mif->selected == LACP_PORT_UNSELECTED) || + (mif->selected == LACP_PORT_STANDBY)) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_UNSELECTED, &mif->mux_state); + + if ((mif->selected == LACP_PORT_SELECTED) && + (mif->partner.state & LACP_STATE_SYNCHRONIZATION)) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, LACP_MUX_EVENT_SYNC, + &mif->mux_state); return 0; } @@ -146,18 +146,18 @@ int lacp_mux_action_waiting (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - if (!lacp_timer_is_running (sif->wait_while_timer)) - lacp_start_wait_while_timer (vm, sif, LACP_AGGREGATE_WAIT_TIME); + if (!lacp_timer_is_running (mif->wait_while_timer)) + lacp_start_wait_while_timer (vm, mif, LACP_AGGREGATE_WAIT_TIME); - if ((sif->selected == LACP_PORT_SELECTED) && sif->ready) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_READY, &sif->mux_state); + if ((mif->selected == LACP_PORT_SELECTED) && mif->ready) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_READY, &mif->mux_state); - if (sif->selected == LACP_PORT_UNSELECTED) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_UNSELECTED, &sif->mux_state); + if (mif->selected == LACP_PORT_UNSELECTED) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_UNSELECTED, &mif->mux_state); return 0; } @@ -166,18 +166,18 @@ int lacp_mux_action_collecting_distributing (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - sif->actor.state |= LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING | + mif->actor.state |= LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING | LACP_STATE_DISTRIBUTING; - bond_enable_collecting_distributing (vm, sif); - sif->ntt = 1; - lacp_start_periodic_timer (vm, sif, 0); - if ((sif->selected == LACP_PORT_UNSELECTED) || - (sif->selected == LACP_PORT_STANDBY) || - !(sif->partner.state & LACP_STATE_SYNCHRONIZATION)) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_UNSELECTED, &sif->mux_state); + bond_enable_collecting_distributing (vm, mif); + mif->ntt = 1; + lacp_start_periodic_timer (vm, mif, 0); + if ((mif->selected == LACP_PORT_UNSELECTED) || + (mif->selected == LACP_PORT_STANDBY) || + !(mif->partner.state & LACP_STATE_SYNCHRONIZATION)) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_UNSELECTED, &mif->mux_state); return 0; @@ -204,7 +204,7 @@ format_mux_event (u8 * s, va_list * args) } void -lacp_mux_debug_func (slave_if_t * sif, int event, int state, +lacp_mux_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition) { vlib_worker_thread_t *w = vlib_worker_threads + os_get_thread_index (); @@ -224,16 +224,16 @@ lacp_mux_debug_func (slave_if_t * sif, int event, int state, ed->event = elog_string (&vlib_global_main.elog_main, "%U-MUX: %U, %U->%U%c", format_vnet_sw_if_index_name, vnet_get_main (), - sif->sw_if_index, format_mux_event, event, + mif->sw_if_index, format_mux_event, event, format_mux_sm_state, state, format_mux_sm_state, transition->next_state, 0); } void -lacp_init_mux_machine (vlib_main_t * vm, slave_if_t * sif) +lacp_init_mux_machine (vlib_main_t * vm, member_if_t * mif) { - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, LACP_MUX_EVENT_BEGIN, - &sif->mux_state); + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, LACP_MUX_EVENT_BEGIN, + &mif->mux_state); } /* diff --git a/src/plugins/lacp/mux_machine.h b/src/plugins/lacp/mux_machine.h index 48e9a0bed4e..6fd251327d0 100644 --- a/src/plugins/lacp/mux_machine.h +++ b/src/plugins/lacp/mux_machine.h @@ -53,7 +53,7 @@ int lacp_mux_action_detached (void *p1, void *p2); int lacp_mux_action_attached (void *p1, void *p2); int lacp_mux_action_waiting (void *p1, void *p2); int lacp_mux_action_collecting_distributing (void *p1, void *p2); -void lacp_mux_debug_func (slave_if_t * sif, int event, int state, +void lacp_mux_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); #define LACP_ACTION_DETACHED LACP_ACTION_ROUTINE(lacp_mux_action_detached) @@ -63,10 +63,10 @@ void lacp_mux_debug_func (slave_if_t * sif, int event, int state, LACP_ACTION_ROUTINE(lacp_mux_action_collecting_distributing) static inline void -lacp_start_wait_while_timer (vlib_main_t * vm, slave_if_t * sif, +lacp_start_wait_while_timer (vlib_main_t * vm, member_if_t * mif, u8 expiration) { - sif->wait_while_timer = vlib_time_now (vm) + expiration; + mif->wait_while_timer = vlib_time_now (vm) + expiration; } #endif /* __LACP_MUX_MACHINE_H__ */ diff --git a/src/plugins/lacp/node.h b/src/plugins/lacp/node.h index 59af66f20d0..0c4e4572c07 100644 --- a/src/plugins/lacp/node.h +++ b/src/plugins/lacp/node.h @@ -146,15 +146,15 @@ int lacp_dump_ifs (lacp_interface_details_t ** out_bondids); lacp_error_t lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0); void lacp_periodic (vlib_main_t * vm); u8 *lacp_input_format_trace (u8 * s, va_list * args); -void lacp_init_neighbor (slave_if_t * sif, u8 * hw_address, +void lacp_init_neighbor (member_if_t * mif, u8 * hw_address, u16 port_number, u32 group); -void lacp_init_state_machines (vlib_main_t * vm, slave_if_t * sif); -void lacp_init_rx_machine (vlib_main_t * vm, slave_if_t * sif); -void lacp_init_tx_machine (vlib_main_t * vm, slave_if_t * sif); -void lacp_init_ptx_machine (vlib_main_t * vm, slave_if_t * sif); -void lacp_init_mux_machine (vlib_main_t * vm, slave_if_t * sif); -void lacp_selection_logic (vlib_main_t * vm, slave_if_t * sif); -void lacp_send_lacp_pdu (vlib_main_t * vm, slave_if_t * sif); +void lacp_init_state_machines (vlib_main_t * vm, member_if_t * mif); +void lacp_init_rx_machine (vlib_main_t * vm, member_if_t * mif); +void lacp_init_tx_machine (vlib_main_t * vm, member_if_t * mif); +void lacp_init_ptx_machine (vlib_main_t * vm, member_if_t * mif); +void lacp_init_mux_machine (vlib_main_t * vm, member_if_t * mif); +void lacp_selection_logic (vlib_main_t * vm, member_if_t * mif); +void lacp_send_lacp_pdu (vlib_main_t * vm, member_if_t * mif); static inline void lacp_stop_timer (f64 * timer) diff --git a/src/plugins/lacp/ptx_machine.c b/src/plugins/lacp/ptx_machine.c index 941fc58cbc4..bb9d033c13a 100644 --- a/src/plugins/lacp/ptx_machine.c +++ b/src/plugins/lacp/ptx_machine.c @@ -75,10 +75,10 @@ int lacp_ptx_action_no_periodic (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_stop_timer (&sif->periodic_timer); - lacp_ptx_post_short_timeout_event (vm, sif); + lacp_stop_timer (&mif->periodic_timer); + lacp_ptx_post_short_timeout_event (vm, mif); return 0; } @@ -86,26 +86,26 @@ int lacp_ptx_action_slow_periodic (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; u8 timer_expired; - if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) && - !(sif->actor.state & LACP_STATE_LACP_ACTIVITY)) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_NO_PERIODIC, &sif->ptx_state); + if (!(mif->partner.state & LACP_STATE_LACP_ACTIVITY) && + !(mif->actor.state & LACP_STATE_LACP_ACTIVITY)) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_NO_PERIODIC, &mif->ptx_state); else { - if (lacp_timer_is_running (sif->periodic_timer) && - lacp_timer_is_expired (vm, sif->periodic_timer)) + if (lacp_timer_is_running (mif->periodic_timer) && + lacp_timer_is_expired (vm, mif->periodic_timer)) timer_expired = 1; else timer_expired = 0; - lacp_schedule_periodic_timer (vm, sif); + lacp_schedule_periodic_timer (vm, mif); - if (timer_expired || (sif->partner.state & LACP_STATE_LACP_TIMEOUT)) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_TIMER_EXPIRED, &sif->ptx_state); + if (timer_expired || (mif->partner.state & LACP_STATE_LACP_TIMEOUT)) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_TIMER_EXPIRED, &mif->ptx_state); } return 0; @@ -115,30 +115,30 @@ int lacp_ptx_action_fast_periodic (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; u8 timer_expired; - if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) && - !(sif->actor.state & LACP_STATE_LACP_ACTIVITY)) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_NO_PERIODIC, &sif->ptx_state); + if (!(mif->partner.state & LACP_STATE_LACP_ACTIVITY) && + !(mif->actor.state & LACP_STATE_LACP_ACTIVITY)) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_NO_PERIODIC, &mif->ptx_state); else { - if (lacp_timer_is_running (sif->periodic_timer) && - lacp_timer_is_expired (vm, sif->periodic_timer)) + if (lacp_timer_is_running (mif->periodic_timer) && + lacp_timer_is_expired (vm, mif->periodic_timer)) timer_expired = 1; else timer_expired = 0; - lacp_start_periodic_timer (vm, sif, LACP_FAST_PERIODIC_TIMER); + lacp_start_periodic_timer (vm, mif, LACP_FAST_PERIODIC_TIMER); if (timer_expired) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_TIMER_EXPIRED, &sif->ptx_state); + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_TIMER_EXPIRED, &mif->ptx_state); - if (!(sif->partner.state & LACP_STATE_LACP_TIMEOUT)) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_LONG_TIMEOUT, &sif->ptx_state); + if (!(mif->partner.state & LACP_STATE_LACP_TIMEOUT)) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_LONG_TIMEOUT, &mif->ptx_state); } return 0; @@ -148,23 +148,23 @@ int lacp_ptx_action_timer_expired (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) && - !(sif->actor.state & LACP_STATE_LACP_ACTIVITY)) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_NO_PERIODIC, &sif->ptx_state); + if (!(mif->partner.state & LACP_STATE_LACP_ACTIVITY) && + !(mif->actor.state & LACP_STATE_LACP_ACTIVITY)) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_NO_PERIODIC, &mif->ptx_state); else { - sif->ntt = 1; - lacp_machine_dispatch (&lacp_tx_machine, vm, sif, LACP_TX_EVENT_NTT, - &sif->tx_state); - if (sif->partner.state & LACP_STATE_LACP_TIMEOUT) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_SHORT_TIMEOUT, &sif->ptx_state); + mif->ntt = 1; + lacp_machine_dispatch (&lacp_tx_machine, vm, mif, LACP_TX_EVENT_NTT, + &mif->tx_state); + if (mif->partner.state & LACP_STATE_LACP_TIMEOUT) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_SHORT_TIMEOUT, &mif->ptx_state); else - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_LONG_TIMEOUT, &sif->ptx_state); + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_LONG_TIMEOUT, &mif->ptx_state); } return 0; @@ -191,7 +191,7 @@ format_ptx_event (u8 * s, va_list * args) } void -lacp_ptx_debug_func (slave_if_t * sif, int event, int state, +lacp_ptx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition) { vlib_worker_thread_t *w = vlib_worker_threads + os_get_thread_index (); @@ -211,16 +211,16 @@ lacp_ptx_debug_func (slave_if_t * sif, int event, int state, ed->event = elog_string (&vlib_global_main.elog_main, "%U-PTX: %U, %U->%U%c", format_vnet_sw_if_index_name, vnet_get_main (), - sif->sw_if_index, format_ptx_event, event, + mif->sw_if_index, format_ptx_event, event, format_ptx_sm_state, state, format_ptx_sm_state, transition->next_state, 0); } void -lacp_init_ptx_machine (vlib_main_t * vm, slave_if_t * sif) +lacp_init_ptx_machine (vlib_main_t * vm, member_if_t * mif) { - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_NO_PERIODIC, &sif->ptx_state); + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_NO_PERIODIC, &mif->ptx_state); } /* diff --git a/src/plugins/lacp/ptx_machine.h b/src/plugins/lacp/ptx_machine.h index 4b4f4134254..7b8fc535da8 100644 --- a/src/plugins/lacp/ptx_machine.h +++ b/src/plugins/lacp/ptx_machine.h @@ -51,7 +51,7 @@ int lacp_ptx_action_no_periodic (void *p1, void *p2); int lacp_ptx_action_slow_periodic (void *p1, void *p2); int lacp_ptx_action_fast_periodic (void *p1, void *p2); int lacp_ptx_action_timer_expired (void *p1, void *p2); -void lacp_ptx_debug_func (slave_if_t * sif, int event, int state, +void lacp_ptx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); #define LACP_ACTION_NO_PERIODIC \ @@ -64,36 +64,36 @@ void lacp_ptx_debug_func (slave_if_t * sif, int event, int state, LACP_ACTION_ROUTINE(lacp_ptx_action_timer_expired) static inline void -lacp_start_periodic_timer (vlib_main_t * vm, slave_if_t * sif, u8 expiration) +lacp_start_periodic_timer (vlib_main_t * vm, member_if_t * mif, u8 expiration) { - sif->periodic_timer = vlib_time_now (vm) + expiration; + mif->periodic_timer = vlib_time_now (vm) + expiration; } static inline void -lacp_schedule_periodic_timer (vlib_main_t * vm, slave_if_t * sif) +lacp_schedule_periodic_timer (vlib_main_t * vm, member_if_t * mif) { // do fast rate if partner is in short timeout or // we are not yet synchronized - if ((sif->partner.state & LACP_STATE_LACP_TIMEOUT) || - (((sif->actor.state & (LACP_STATE_SYNCHRONIZATION | + if ((mif->partner.state & LACP_STATE_LACP_TIMEOUT) || + (((mif->actor.state & (LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING | LACP_STATE_DISTRIBUTING)) != (LACP_STATE_SYNCHRONIZATION | LACP_STATE_COLLECTING | LACP_STATE_DISTRIBUTING)) - && (sif->partner.state & LACP_STATE_AGGREGATION))) - lacp_start_periodic_timer (vm, sif, LACP_FAST_PERIODIC_TIMER); + && (mif->partner.state & LACP_STATE_AGGREGATION))) + lacp_start_periodic_timer (vm, mif, LACP_FAST_PERIODIC_TIMER); else - lacp_start_periodic_timer (vm, sif, LACP_SLOW_PERIODIC_TIMER); + lacp_start_periodic_timer (vm, mif, LACP_SLOW_PERIODIC_TIMER); } static inline void -lacp_ptx_post_short_timeout_event (vlib_main_t * vm, slave_if_t * sif) +lacp_ptx_post_short_timeout_event (vlib_main_t * vm, member_if_t * mif) { - if (sif->lacp_enabled && sif->port_enabled && - ((sif->partner.state & LACP_STATE_LACP_ACTIVITY) || - (sif->actor.state & LACP_STATE_LACP_ACTIVITY))) - lacp_machine_dispatch (&lacp_ptx_machine, vm, sif, - LACP_PTX_EVENT_SHORT_TIMEOUT, &sif->ptx_state); + if (mif->lacp_enabled && mif->port_enabled && + ((mif->partner.state & LACP_STATE_LACP_ACTIVITY) || + (mif->actor.state & LACP_STATE_LACP_ACTIVITY))) + lacp_machine_dispatch (&lacp_ptx_machine, vm, mif, + LACP_PTX_EVENT_SHORT_TIMEOUT, &mif->ptx_state); } #endif /* __LACP_PTX_MACHINE_H__ */ diff --git a/src/plugins/lacp/rx_machine.c b/src/plugins/lacp/rx_machine.c index 605cccba08c..60edc80d863 100644 --- a/src/plugins/lacp/rx_machine.c +++ b/src/plugins/lacp/rx_machine.c @@ -111,11 +111,11 @@ lacp_machine_t lacp_rx_machine = { }; static void -lacp_set_port_unselected (vlib_main_t * vm, slave_if_t * sif) +lacp_set_port_unselected (vlib_main_t * vm, member_if_t * mif) { - sif->selected = LACP_PORT_UNSELECTED; + mif->selected = LACP_PORT_UNSELECTED; - switch (sif->mux_state) + switch (mif->mux_state) { case LACP_MUX_STATE_DETACHED: break; @@ -125,78 +125,78 @@ lacp_set_port_unselected (vlib_main_t * vm, slave_if_t * sif) return; break; case LACP_MUX_STATE_COLLECTING_DISTRIBUTING: - if (sif->partner.state & LACP_STATE_SYNCHRONIZATION) + if (mif->partner.state & LACP_STATE_SYNCHRONIZATION) return; break; default: break; } - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, - LACP_MUX_EVENT_UNSELECTED, &sif->mux_state); + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, + LACP_MUX_EVENT_UNSELECTED, &mif->mux_state); } static void -lacp_update_default_selected (vlib_main_t * vm, slave_if_t * sif) +lacp_update_default_selected (vlib_main_t * vm, member_if_t * mif) { - if ((sif->partner_admin.state & LACP_STATE_AGGREGATION) != - (sif->partner.state & LACP_STATE_AGGREGATION) || - memcmp (&sif->partner, &sif->partner_admin, - sizeof (sif->partner) - sizeof (sif->partner.state))) + if ((mif->partner_admin.state & LACP_STATE_AGGREGATION) != + (mif->partner.state & LACP_STATE_AGGREGATION) || + memcmp (&mif->partner, &mif->partner_admin, + sizeof (mif->partner) - sizeof (mif->partner.state))) { - lacp_set_port_unselected (vm, sif); + lacp_set_port_unselected (vm, mif); } } static void -lacp_record_default (slave_if_t * sif) +lacp_record_default (member_if_t * mif) { - sif->partner = sif->partner_admin; - sif->actor.state |= LACP_STATE_DEFAULTED; + mif->partner = mif->partner_admin; + mif->actor.state |= LACP_STATE_DEFAULTED; } static void -lacp_update_selected (vlib_main_t * vm, slave_if_t * sif) +lacp_update_selected (vlib_main_t * vm, member_if_t * mif) { - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; if ((lacpdu->actor.port_info.state & LACP_STATE_AGGREGATION) != - (sif->partner.state & LACP_STATE_AGGREGATION) || - memcmp (&sif->partner, &lacpdu->actor.port_info, - sizeof (sif->partner) - sizeof (sif->partner.state))) + (mif->partner.state & LACP_STATE_AGGREGATION) || + memcmp (&mif->partner, &lacpdu->actor.port_info, + sizeof (mif->partner) - sizeof (mif->partner.state))) { - lacp_set_port_unselected (vm, sif); + lacp_set_port_unselected (vm, mif); } } static void -lacp_update_ntt (vlib_main_t * vm, slave_if_t * sif) +lacp_update_ntt (vlib_main_t * vm, member_if_t * mif) { - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; u8 states = LACP_STATE_LACP_ACTIVITY | LACP_STATE_LACP_TIMEOUT | LACP_STATE_SYNCHRONIZATION | LACP_STATE_AGGREGATION; if ((states & lacpdu->partner.port_info.state) != - (states & sif->actor.state) - || memcmp (&sif->actor, &lacpdu->partner.port_info, - sizeof (sif->actor) - sizeof (sif->actor.state))) + (states & mif->actor.state) + || memcmp (&mif->actor, &lacpdu->partner.port_info, + sizeof (mif->actor) - sizeof (mif->actor.state))) { - sif->ntt = 1; - lacp_start_periodic_timer (vm, sif, 0); + mif->ntt = 1; + lacp_start_periodic_timer (vm, mif, 0); } } /* - * compare lacpdu partner info against sif->partner. Return 1 if they match, 0 + * compare lacpdu partner info against mif->partner. Return 1 if they match, 0 * otherwise. */ static u8 -lacp_compare_partner (slave_if_t * sif) +lacp_compare_partner (member_if_t * mif) { - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; - if ((!memcmp (&sif->partner, &lacpdu->actor.port_info, - sizeof (sif->partner) - sizeof (sif->partner.state)) && - ((sif->actor.state & LACP_STATE_AGGREGATION) == + if ((!memcmp (&mif->partner, &lacpdu->actor.port_info, + sizeof (mif->partner) - sizeof (mif->partner.state)) && + ((mif->actor.state & LACP_STATE_AGGREGATION) == (lacpdu->partner.port_info.state & LACP_STATE_AGGREGATION))) || ((lacpdu->actor.port_info.state & LACP_STATE_AGGREGATION) == 0)) return 1; @@ -205,50 +205,50 @@ lacp_compare_partner (slave_if_t * sif) } static void -lacp_record_pdu (vlib_main_t * vm, slave_if_t * sif) +lacp_record_pdu (vlib_main_t * vm, member_if_t * mif) { - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; u8 match; /* Transition PTX out of NO_PERIODIC if needed */ - if (!(sif->partner.state & LACP_STATE_LACP_ACTIVITY) && + if (!(mif->partner.state & LACP_STATE_LACP_ACTIVITY) && (lacpdu->actor.port_info.state & LACP_STATE_LACP_ACTIVITY)) - lacp_ptx_post_short_timeout_event (vm, sif); - match = lacp_compare_partner (sif); - sif->partner = lacpdu->actor.port_info; - sif->actor.state &= ~LACP_STATE_DEFAULTED; + lacp_ptx_post_short_timeout_event (vm, mif); + match = lacp_compare_partner (mif); + mif->partner = lacpdu->actor.port_info; + mif->actor.state &= ~LACP_STATE_DEFAULTED; if (match && (lacpdu->actor.port_info.state & LACP_STATE_SYNCHRONIZATION)) - sif->partner.state |= LACP_STATE_SYNCHRONIZATION; + mif->partner.state |= LACP_STATE_SYNCHRONIZATION; else - sif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; + mif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; } static void -lacp_set_port_moved (vlib_main_t * vm, slave_if_t * sif, u8 val) +lacp_set_port_moved (vlib_main_t * vm, member_if_t * mif, u8 val) { - sif->port_moved = val; - - if (sif->port_moved) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PORT_MOVED, &sif->rx_state); - else if (!sif->port_enabled) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PORT_DISABLED, &sif->rx_state); + mif->port_moved = val; + + if (mif->port_moved) + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PORT_MOVED, &mif->rx_state); + else if (!mif->port_enabled) + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PORT_DISABLED, &mif->rx_state); } int lacp_rx_action_initialize (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_set_port_unselected (vm, sif); - lacp_record_default (sif); - sif->actor.state &= ~LACP_STATE_EXPIRED; - lacp_set_port_moved (vm, sif, 0); + lacp_set_port_unselected (vm, mif); + lacp_record_default (mif); + mif->actor.state &= ~LACP_STATE_EXPIRED; + lacp_set_port_moved (vm, mif, 0); /* UCT */ - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_BEGIN, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_BEGIN, &mif->rx_state); return 0; } @@ -257,22 +257,22 @@ int lacp_rx_action_port_disabled (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - sif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; - if (sif->port_moved) + mif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; + if (mif->port_moved) { - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PORT_MOVED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PORT_MOVED, &mif->rx_state); } - if (sif->port_enabled) + if (mif->port_enabled) { - if (sif->lacp_enabled) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_LACP_ENABLED, &sif->rx_state); + if (mif->lacp_enabled) + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_LACP_ENABLED, &mif->rx_state); else - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_LACP_DISABLED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_LACP_DISABLED, &mif->rx_state); } return 0; @@ -282,25 +282,25 @@ int lacp_rx_action_expired (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; u8 timer_expired; - sif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; - sif->partner.state |= LACP_STATE_LACP_TIMEOUT; - lacp_ptx_post_short_timeout_event (vm, sif); - if (lacp_timer_is_running (sif->current_while_timer) && - lacp_timer_is_expired (vm, sif->current_while_timer)) + mif->partner.state &= ~LACP_STATE_SYNCHRONIZATION; + mif->partner.state |= LACP_STATE_LACP_TIMEOUT; + lacp_ptx_post_short_timeout_event (vm, mif); + if (lacp_timer_is_running (mif->current_while_timer) && + lacp_timer_is_expired (vm, mif->current_while_timer)) timer_expired = 1; else timer_expired = 0; - lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds); - sif->actor.state |= LACP_STATE_EXPIRED; + lacp_start_current_while_timer (vm, mif, mif->ttl_in_seconds); + mif->actor.state |= LACP_STATE_EXPIRED; if (timer_expired) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_TIMER_EXPIRED, &sif->rx_state); - if (sif->last_rx_pkt && vec_len (sif->last_rx_pkt)) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PDU_RECEIVED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_TIMER_EXPIRED, &mif->rx_state); + if (mif->last_rx_pkt && vec_len (mif->last_rx_pkt)) + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PDU_RECEIVED, &mif->rx_state); return 0; } @@ -309,12 +309,12 @@ int lacp_rx_action_lacp_disabled (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_set_port_unselected (vm, sif); - lacp_record_default (sif); - sif->partner.state &= ~LACP_STATE_AGGREGATION; - sif->actor.state &= ~LACP_STATE_EXPIRED; + lacp_set_port_unselected (vm, mif); + lacp_record_default (mif); + mif->partner.state &= ~LACP_STATE_AGGREGATION; + mif->actor.state &= ~LACP_STATE_EXPIRED; return 0; } @@ -323,33 +323,33 @@ int lacp_rx_action_defaulted (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_stop_timer (&sif->current_while_timer); - lacp_update_default_selected (vm, sif); - lacp_record_default (sif); - sif->actor.state &= ~LACP_STATE_EXPIRED; - if (sif->last_rx_pkt && vec_len (sif->last_rx_pkt)) - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_PDU_RECEIVED, &sif->rx_state); + lacp_stop_timer (&mif->current_while_timer); + lacp_update_default_selected (vm, mif); + lacp_record_default (mif); + mif->actor.state &= ~LACP_STATE_EXPIRED; + if (mif->last_rx_pkt && vec_len (mif->last_rx_pkt)) + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_PDU_RECEIVED, &mif->rx_state); return 0; } static int -lacp_port_is_moved (vlib_main_t * vm, slave_if_t * sif) +lacp_port_is_moved (vlib_main_t * vm, member_if_t * mif) { bond_main_t *bm = &bond_main; - slave_if_t *sif2; - lacp_pdu_t *lacpdu = (lacp_pdu_t *) sif->last_rx_pkt; + member_if_t *mif2; + lacp_pdu_t *lacpdu = (lacp_pdu_t *) mif->last_rx_pkt; /* *INDENT-OFF* */ - pool_foreach (sif2, bm->neighbors, { + pool_foreach (mif2, bm->neighbors, { { - if ((sif != sif2) && (sif2->rx_state == LACP_RX_STATE_PORT_DISABLED) && - !memcmp (sif2->partner.system, + if ((mif != mif2) && (mif2->rx_state == LACP_RX_STATE_PORT_DISABLED) && + !memcmp (mif2->partner.system, lacpdu->partner.port_info.system, 6) && - (sif2->partner.port_number == lacpdu->partner.port_info.port_number)) + (mif2->partner.port_number == lacpdu->partner.port_info.port_number)) return 1; } }); @@ -362,16 +362,16 @@ int lacp_rx_action_current (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; - lacp_update_selected (vm, sif); - lacp_update_ntt (vm, sif); - lacp_record_pdu (vm, sif); - lacp_start_current_while_timer (vm, sif, sif->ttl_in_seconds); - sif->actor.state &= ~LACP_STATE_EXPIRED; - if (lacp_port_is_moved (vm, sif)) - lacp_set_port_moved (vm, sif, 1); - lacp_selection_logic (vm, sif); + lacp_update_selected (vm, mif); + lacp_update_ntt (vm, mif); + lacp_record_pdu (vm, mif); + lacp_start_current_while_timer (vm, mif, mif->ttl_in_seconds); + mif->actor.state &= ~LACP_STATE_EXPIRED; + if (lacp_port_is_moved (vm, mif)) + lacp_set_port_moved (vm, mif, 1); + lacp_selection_logic (vm, mif); return 0; } @@ -397,7 +397,7 @@ format_rx_event (u8 * s, va_list * args) } void -lacp_rx_debug_func (slave_if_t * sif, int event, int state, +lacp_rx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition) { vlib_worker_thread_t *w = vlib_worker_threads + os_get_thread_index (); @@ -416,18 +416,18 @@ lacp_rx_debug_func (slave_if_t * sif, int event, int state, ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); ed->event = elog_string (&vlib_global_main.elog_main, "%U-RX: %U, %U->%U%c", format_vnet_sw_if_index_name, vnet_get_main (), - sif->sw_if_index, format_rx_event, event, + mif->sw_if_index, format_rx_event, event, format_rx_sm_state, state, format_rx_sm_state, transition->next_state, 0); } void -lacp_init_rx_machine (vlib_main_t * vm, slave_if_t * sif) +lacp_init_rx_machine (vlib_main_t * vm, member_if_t * mif) { - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, LACP_RX_EVENT_BEGIN, - &sif->rx_state); - lacp_machine_dispatch (&lacp_rx_machine, vm, sif, - LACP_RX_EVENT_LACP_ENABLED, &sif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, LACP_RX_EVENT_BEGIN, + &mif->rx_state); + lacp_machine_dispatch (&lacp_rx_machine, vm, mif, + LACP_RX_EVENT_LACP_ENABLED, &mif->rx_state); } /* diff --git a/src/plugins/lacp/rx_machine.h b/src/plugins/lacp/rx_machine.h index 706dbd08c67..4642603379b 100644 --- a/src/plugins/lacp/rx_machine.h +++ b/src/plugins/lacp/rx_machine.h @@ -59,7 +59,7 @@ int lacp_rx_action_expired (void *, void *); int lacp_rx_action_lacp_disabled (void *, void *); int lacp_rx_action_defaulted (void *, void *); int lacp_rx_action_current (void *, void *); -void lacp_rx_debug_func (slave_if_t * sif, int event, int state, +void lacp_rx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); #define LACP_ACTION_INITIALIZE \ @@ -74,10 +74,10 @@ void lacp_rx_debug_func (slave_if_t * sif, int event, int state, #define LACP_ACTION_CURRENT LACP_ACTION_ROUTINE(lacp_rx_action_current) static inline void -lacp_start_current_while_timer (vlib_main_t * vm, slave_if_t * sif, +lacp_start_current_while_timer (vlib_main_t * vm, member_if_t * mif, u8 expiration) { - sif->current_while_timer = vlib_time_now (vm) + expiration; + mif->current_while_timer = vlib_time_now (vm) + expiration; } #endif /* __LACP_RX_MACHINE_H__ */ diff --git a/src/plugins/lacp/selection.c b/src/plugins/lacp/selection.c index 898b6a95023..f3fb6b9faa4 100644 --- a/src/plugins/lacp/selection.c +++ b/src/plugins/lacp/selection.c @@ -20,27 +20,27 @@ #include static void -lacp_set_port_selected (vlib_main_t * vm, slave_if_t * sif) +lacp_set_port_selected (vlib_main_t * vm, member_if_t * mif) { /* Handle loopback port */ - if (!memcmp (sif->partner.system, sif->actor.system, 6) && - (sif->partner.key == sif->actor.key)) + if (!memcmp (mif->partner.system, mif->actor.system, 6) && + (mif->partner.key == mif->actor.key)) { - sif->loopback_port = 1; - sif->actor.state &= ~LACP_STATE_AGGREGATION; + mif->loopback_port = 1; + mif->actor.state &= ~LACP_STATE_AGGREGATION; } - sif->selected = LACP_PORT_SELECTED; + mif->selected = LACP_PORT_SELECTED; - switch (sif->mux_state) + switch (mif->mux_state) { case LACP_MUX_STATE_DETACHED: break; case LACP_MUX_STATE_WAITING: - if (!sif->ready) + if (!mif->ready) return; break; case LACP_MUX_STATE_ATTACHED: - if (!(sif->partner.state & LACP_STATE_SYNCHRONIZATION)) + if (!(mif->partner.state & LACP_STATE_SYNCHRONIZATION)) return; break; case LACP_MUX_STATE_COLLECTING_DISTRIBUTING: @@ -48,39 +48,39 @@ lacp_set_port_selected (vlib_main_t * vm, slave_if_t * sif) default: break; } - lacp_machine_dispatch (&lacp_mux_machine, vm, sif, LACP_MUX_EVENT_SELECTED, - &sif->mux_state); + lacp_machine_dispatch (&lacp_mux_machine, vm, mif, LACP_MUX_EVENT_SELECTED, + &mif->mux_state); } void -lacp_selection_logic (vlib_main_t * vm, slave_if_t * sif) +lacp_selection_logic (vlib_main_t * vm, member_if_t * mif) { - slave_if_t *sif2; + member_if_t *mif2; bond_if_t *bif; u32 *sw_if_index; - bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); - vec_foreach (sw_if_index, bif->slaves) + bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance); + vec_foreach (sw_if_index, bif->members) { - sif2 = bond_get_slave_by_sw_if_index (*sw_if_index); - if (sif2 && (sif2->actor.state & LACP_STATE_SYNCHRONIZATION) && - (sif2->ready_n == 0)) + mif2 = bond_get_member_by_sw_if_index (*sw_if_index); + if (mif2 && (mif2->actor.state & LACP_STATE_SYNCHRONIZATION) && + (mif2->ready_n == 0)) goto out; } - vec_foreach (sw_if_index, bif->slaves) + vec_foreach (sw_if_index, bif->members) { - sif2 = bond_get_slave_by_sw_if_index (*sw_if_index); - if (sif2) + mif2 = bond_get_member_by_sw_if_index (*sw_if_index); + if (mif2) { - sif2->ready = 1; - if (sif2->selected == LACP_PORT_SELECTED) - lacp_machine_dispatch (&lacp_mux_machine, vm, sif2, - LACP_MUX_EVENT_READY, &sif2->mux_state); + mif2->ready = 1; + if (mif2->selected == LACP_PORT_SELECTED) + lacp_machine_dispatch (&lacp_mux_machine, vm, mif2, + LACP_MUX_EVENT_READY, &mif2->mux_state); } } out: - lacp_set_port_selected (vm, sif); + lacp_set_port_selected (vm, mif); } /* diff --git a/src/plugins/lacp/test/test_lacp.py b/src/plugins/lacp/test/test_lacp.py index fa4b0a21ca9..b5f2dae2cd3 100644 --- a/src/plugins/lacp/test/test_lacp.py +++ b/src/plugins/lacp/test/test_lacp.py @@ -105,21 +105,21 @@ class TestMarker(VppTestCase): bond1.add_vpp_config() bond1.admin_up() - bond0.enslave_vpp_bond_interface(sw_if_index=memif1.sw_if_index) - bond1.enslave_vpp_bond_interface(sw_if_index=memif11.sw_if_index) + bond0.add_member_vpp_bond_interface(sw_if_index=memif1.sw_if_index) + bond1.add_member_vpp_bond_interface(sw_if_index=memif11.sw_if_index) # wait for memif protocol exchange and hardware carrier to come up self.assertEqual(memif1.wait_for_link_up(10), True) self.assertEqual(memif11.wait_for_link_up(10), True) # verify memif1 in bond0 - intfs = self.vapi.sw_interface_slave_dump( + intfs = self.vapi.sw_member_interface_dump( sw_if_index=bond0.sw_if_index) for intf in intfs: self.assertEqual(intf.sw_if_index, memif1.sw_if_index) # verify memif11 in bond1 - intfs = self.vapi.sw_interface_slave_dump( + intfs = self.vapi.sw_member_interface_dump( sw_if_index=bond1.sw_if_index) for intf in intfs: self.assertEqual(intf.sw_if_index, memif11.sw_if_index) @@ -134,7 +134,7 @@ class TestMarker(VppTestCase): requester_system=bond_mac, requester_transaction_id=1)) - bond1.enslave_vpp_bond_interface(sw_if_index=self.pg0.sw_if_index) + bond1.add_member_vpp_bond_interface(sw_if_index=self.pg0.sw_if_index) self.pg0.add_stream(marker) self.pg_enable_capture(self.pg_interfaces) self.pg_start() @@ -185,19 +185,19 @@ class TestLACP(VppTestCase): if timeout <= 0: return 0 - def wait_for_slave_detach(self, bond, timeout, count, step=1): + def wait_for_member_detach(self, bond, timeout, count, step=1): while 1: - intfs = self.vapi.sw_interface_bond_dump() + intfs = self.vapi.sw_bond_interface_dump( + sw_if_index=bond.sw_if_index) for intf in intfs: - if (bond.sw_if_index == intf.sw_if_index): - if ((intf.slaves == count) and - (intf.active_slaves == count)): - return 1 - else: - self.sleep(1) - timeout -= step - if (timeouut <= 0): - return 0 + if ((intf.members == count) and + (intf.active_members == count)): + return 1 + else: + self.sleep(1) + timeout -= step + if (timeouut <= 0): + return 0 def test_lacp_connect(self): """ LACP protocol connect test """ @@ -284,13 +284,13 @@ class TestLACP(VppTestCase): bond1.add_vpp_config() bond1.admin_up() - # enslave memif1 and memif2 to bond0 - bond0.enslave_vpp_bond_interface(sw_if_index=memif1.sw_if_index) - bond0.enslave_vpp_bond_interface(sw_if_index=memif2.sw_if_index) + # add member memif1 and memif2 to bond0 + bond0.add_member_vpp_bond_interface(sw_if_index=memif1.sw_if_index) + bond0.add_member_vpp_bond_interface(sw_if_index=memif2.sw_if_index) - # enslave memif11 and memif12 to bond1 - bond1.enslave_vpp_bond_interface(sw_if_index=memif11.sw_if_index) - bond1.enslave_vpp_bond_interface(sw_if_index=memif12.sw_if_index) + # add member memif11 and memif12 to bond1 + bond1.add_member_vpp_bond_interface(sw_if_index=memif11.sw_if_index) + bond1.add_member_vpp_bond_interface(sw_if_index=memif12.sw_if_index) # wait for memif protocol exchange and hardware carrier to come up self.assertEqual(memif1.wait_for_link_up(10), True) @@ -299,14 +299,14 @@ class TestLACP(VppTestCase): self.assertEqual(memif12.wait_for_link_up(10), True) # verify memif1 and memif2 in bond0 - intfs = self.vapi.sw_interface_slave_dump( + intfs = self.vapi.sw_member_interface_dump( sw_if_index=bond0.sw_if_index) for intf in intfs: self.assertIn( intf.sw_if_index, (memif1.sw_if_index, memif2.sw_if_index)) # verify memif11 and memif12 in bond1 - intfs = self.vapi.sw_interface_slave_dump( + intfs = self.vapi.sw_member_interface_dump( sw_if_index=bond1.sw_if_index) for intf in intfs: self.assertIn( @@ -324,37 +324,37 @@ class TestLACP(VppTestCase): self.assertEqual( intf.partner_state, LACP_COLLECTION_AND_DISTRIBUTION_STATE) - intfs = self.vapi.sw_interface_bond_dump() + intfs = self.vapi.sw_bond_interface_dump(sw_if_index=0xFFFFFFFF) for intf in intfs: - self.assertEqual(intf.slaves, 2) - self.assertEqual(intf.active_slaves, 2) + self.assertEqual(intf.members, 2) + self.assertEqual(intf.active_members, 2) self.assertEqual( intf.mode, VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP) self.logger.info(self.vapi.ppcli("show lacp")) self.logger.info(self.vapi.ppcli("show lacp details")) - # detach slave memif1 + # detach member memif1 bond0.detach_vpp_bond_interface(sw_if_index=memif1.sw_if_index) - self.wait_for_slave_detach(bond0, timeout=10, count=1) - intfs = self.vapi.sw_interface_bond_dump() + self.wait_for_member_detach(bond0, timeout=10, count=1) + intfs = self.vapi.sw_bond_interface_dump( + sw_if_index=bond0.sw_if_index) for intf in intfs: - if (bond0.sw_if_index == intf.sw_if_index): - self.assertEqual(intf.slaves, 1) - self.assertEqual(intf.active_slaves, 1) - self.assertEqual( - intf.mode, VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP) + self.assertEqual(intf.members, 1) + self.assertEqual(intf.active_members, 1) + self.assertEqual( + intf.mode, VppEnum.vl_api_bond_mode_t.BOND_API_MODE_LACP) - # detach slave memif2 + # detach member memif2 bond0.detach_vpp_bond_interface(sw_if_index=memif2.sw_if_index) - self.wait_for_slave_detach(bond0, timeout=10, count=0) + self.wait_for_member_detach(bond0, timeout=10, count=0) - intfs = self.vapi.sw_interface_bond_dump() + intfs = self.vapi.sw_bond_interface_dump( + sw_if_index=bond0.sw_if_index) for intf in intfs: - if (bond0.sw_if_index == intf.sw_if_index): - self.assertEqual(intf.slaves, 0) - self.assertEqual(intf.active_slaves, 0) + self.assertEqual(intf.members, 0) + self.assertEqual(intf.active_members, 0) bond0.remove_vpp_config() bond1.remove_vpp_config() diff --git a/src/plugins/lacp/tx_machine.c b/src/plugins/lacp/tx_machine.c index 3377da86422..1eb3bc1c4b7 100644 --- a/src/plugins/lacp/tx_machine.c +++ b/src/plugins/lacp/tx_machine.c @@ -39,22 +39,22 @@ int lacp_tx_action_transmit (void *p1, void *p2) { vlib_main_t *vm = p1; - slave_if_t *sif = p2; + member_if_t *mif = p2; f64 now = vlib_time_now (vm); - if (!lacp_timer_is_running (sif->periodic_timer)) + if (!lacp_timer_is_running (mif->periodic_timer)) return 0; // No more than 3 LACPDUs per fast interval - if (now <= (sif->last_lacpdu_sent_time + 0.333)) + if (now <= (mif->last_lacpdu_sent_time + 0.333)) return 0; - if (sif->ntt) + if (mif->ntt) { - lacp_send_lacp_pdu (vm, sif); - lacp_schedule_periodic_timer (vm, sif); + lacp_send_lacp_pdu (vm, mif); + lacp_schedule_periodic_timer (vm, mif); } - sif->ntt = 0; + mif->ntt = 0; return 0; } @@ -80,7 +80,7 @@ format_tx_event (u8 * s, va_list * args) } void -lacp_tx_debug_func (slave_if_t * sif, int event, int state, +lacp_tx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition) { vlib_worker_thread_t *w = vlib_worker_threads + os_get_thread_index (); @@ -99,16 +99,16 @@ lacp_tx_debug_func (slave_if_t * sif, int event, int state, ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, w->elog_track); ed->event = elog_string (&vlib_global_main.elog_main, "%U-TX: %U, %U->%U%c", format_vnet_sw_if_index_name, vnet_get_main (), - sif->sw_if_index, format_tx_event, event, + mif->sw_if_index, format_tx_event, event, format_tx_sm_state, state, format_tx_sm_state, transition->next_state, 0); } void -lacp_init_tx_machine (vlib_main_t * vm, slave_if_t * sif) +lacp_init_tx_machine (vlib_main_t * vm, member_if_t * mif) { - lacp_machine_dispatch (&lacp_tx_machine, vm, sif, LACP_TX_EVENT_BEGIN, - &sif->tx_state); + lacp_machine_dispatch (&lacp_tx_machine, vm, mif, LACP_TX_EVENT_BEGIN, + &mif->tx_state); } /* diff --git a/src/plugins/lacp/tx_machine.h b/src/plugins/lacp/tx_machine.h index 428c19b5edd..5e87aed4e6d 100644 --- a/src/plugins/lacp/tx_machine.h +++ b/src/plugins/lacp/tx_machine.h @@ -43,7 +43,7 @@ typedef enum extern lacp_machine_t lacp_tx_machine; int lacp_tx_action_transmit (void *p1, void *p2); -void lacp_tx_debug_func (slave_if_t * sif, int event, int state, +void lacp_tx_debug_func (member_if_t * mif, int event, int state, lacp_fsm_state_t * transition); #define LACP_ACTION_TRANSMIT LACP_ACTION_ROUTINE(lacp_tx_action_transmit) -- cgit 1.2.3-korg