summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-10-25 09:52:19 -0700
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-02-06 12:18:06 +0000
commit8427de5ab1a93495d2d33e9ab259c9dfc489ffee (patch)
tree87a866d1ef32130002258c6232cd2f2ace14a821 /src
parentdfad26986077ff26b471c008a0fd77a79f767a3c (diff)
lacp: add actor steady state check prior to skip processing lacp pdu
In a rare event, we may be skipping processing lacp pdu's when the it is not in steady state. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I4e4f81dfd4e95433879ee66cdf6edb8d8afbe9b0
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lacp/input.c4
-rw-r--r--src/plugins/lacp/protocol.h4
-rw-r--r--src/vnet/bonding/cli.c88
-rw-r--r--src/vnet/bonding/node.h3
4 files changed, 48 insertions, 51 deletions
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index ef7cca9c442..befb2ed408b 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -142,7 +142,6 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
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]);
@@ -203,10 +202,9 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
last_packet_signature =
hash_memory (sif->last_rx_pkt, vec_len (sif->last_rx_pkt), 0xd00b);
- bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
if (sif->last_packet_signature_valid &&
(sif->last_packet_signature == last_packet_signature) &&
- hash_get (bif->active_slave_by_sw_if_index, sif->sw_if_index))
+ ((sif->actor.state & LACP_STEADY_STATE) == LACP_STEADY_STATE))
{
lacp_start_current_while_timer (lm->vlib_main, sif,
sif->ttl_in_seconds);
diff --git a/src/plugins/lacp/protocol.h b/src/plugins/lacp/protocol.h
index 9fc2f35fd38..347e944f95e 100644
--- a/src/plugins/lacp/protocol.h
+++ b/src/plugins/lacp/protocol.h
@@ -61,6 +61,10 @@ typedef enum
_(6, DEFAULTED, "defaulted") \
_(7, EXPIRED, "expired")
+#define LACP_STEADY_STATE (LACP_STATE_SYNCHRONIZATION | \
+ LACP_STATE_COLLECTING | \
+ LACP_STATE_DISTRIBUTING)
+
typedef enum
{
#define _(a, b, c) LACP_STATE_##b = (1 << a),
diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c
index 52f6bc51993..b65fe80be1f 100644
--- a/src/vnet/bonding/cli.c
+++ b/src/vnet/bonding/cli.c
@@ -47,7 +47,6 @@ bond_disable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif)
bif->is_local_numa = 0;
}
vec_del1 (bif->active_slaves, i);
- hash_unset (bif->active_slave_by_sw_if_index, sif->sw_if_index);
if (sif->lacp_enabled && bif->numa_only)
{
/* For lacp mode, if we check it is a slave on local numa node,
@@ -114,58 +113,57 @@ bond_enable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif)
bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
clib_spinlock_lock_if_init (&bif->lockp);
- if (!hash_get (bif->active_slave_by_sw_if_index, sif->sw_if_index))
+ vec_foreach_index (i, bif->active_slaves)
+ {
+ p = *vec_elt_at_index (bif->active_slaves, i);
+ if (p == sif->sw_if_index)
+ goto done;
+ }
+
+ if ((sif->lacp_enabled && bif->numa_only)
+ && (vm->numa_node == hw->numa_node))
+ {
+ vec_insert_elts (bif->active_slaves, &sif->sw_if_index, 1,
+ bif->n_numa_slaves);
+ bif->n_numa_slaves++;
+ }
+ else
{
- hash_set (bif->active_slave_by_sw_if_index, sif->sw_if_index,
- sif->sw_if_index);
+ vec_add1 (bif->active_slaves, sif->sw_if_index);
+ }
- if ((sif->lacp_enabled && bif->numa_only)
- && (vm->numa_node == hw->numa_node))
- {
- vec_insert_elts (bif->active_slaves, &sif->sw_if_index, 1,
- bif->n_numa_slaves);
- bif->n_numa_slaves++;
- }
- else
+ /* First slave becomes active? */
+ if ((vec_len (bif->active_slaves) == 1) &&
+ (bif->mode == BOND_MODE_ACTIVE_BACKUP))
+ {
+ bif->sw_if_index_working = sif->sw_if_index;
+ bif->is_local_numa = (vm->numa_node == hw->numa_node) ? 1 : 0;
+ vlib_process_signal_event (bm->vlib_main, bond_process_node.index,
+ BOND_SEND_GARP_NA, bif->hw_if_index);
+ }
+ else if ((vec_len (bif->active_slaves) > 1)
+ && (bif->mode == BOND_MODE_ACTIVE_BACKUP)
+ && bif->is_local_numa == 0)
+ {
+ if (vm->numa_node == hw->numa_node)
{
- vec_add1 (bif->active_slaves, sif->sw_if_index);
- }
+ vec_foreach_index (i, bif->active_slaves)
+ {
+ p = *vec_elt_at_index (bif->active_slaves, 0);
+ if (p == sif->sw_if_index)
+ break;
- /* First slave becomes active? */
- if ((vec_len (bif->active_slaves) == 1) &&
- (bif->mode == BOND_MODE_ACTIVE_BACKUP))
- {
+ vec_del1 (bif->active_slaves, 0);
+ vec_add1 (bif->active_slaves, p);
+ }
bif->sw_if_index_working = sif->sw_if_index;
- bif->is_local_numa = (vm->numa_node == hw->numa_node) ? 1 : 0;
- vlib_process_signal_event (bm->vlib_main, bond_process_node.index,
+ bif->is_local_numa = 1;
+ vlib_process_signal_event (bm->vlib_main,
+ bond_process_node.index,
BOND_SEND_GARP_NA, bif->hw_if_index);
}
- else if ((vec_len (bif->active_slaves) > 1)
- && (bif->mode == BOND_MODE_ACTIVE_BACKUP)
- && bif->is_local_numa == 0)
- {
- if (vm->numa_node == hw->numa_node)
- {
- vec_foreach_index (i, bif->active_slaves)
- {
- p = *vec_elt_at_index (bif->active_slaves, 0);
- if (p == sif->sw_if_index)
- break;
-
- vec_del1 (bif->active_slaves, 0);
- hash_unset (bif->active_slave_by_sw_if_index, p);
- vec_add1 (bif->active_slaves, p);
- hash_set (bif->active_slave_by_sw_if_index, p, p);
- }
- bif->sw_if_index_working = sif->sw_if_index;
- bif->is_local_numa = 1;
- vlib_process_signal_event (bm->vlib_main,
- bond_process_node.index,
- BOND_SEND_GARP_NA, bif->hw_if_index);
-
- }
- }
}
+done:
clib_spinlock_unlock_if_init (&bif->lockp);
if (bif->mode == BOND_MODE_LACP)
diff --git a/src/vnet/bonding/node.h b/src/vnet/bonding/node.h
index e118cfeb3eb..3ac7f81fbda 100644
--- a/src/vnet/bonding/node.h
+++ b/src/vnet/bonding/node.h
@@ -183,9 +183,6 @@ typedef struct
/* Slaves that are in DISTRIBUTING state */
u32 *active_slaves;
- /* rapidly find an active slave */
- uword *active_slave_by_sw_if_index;
-
lacp_port_info_t partner;
lacp_port_info_t actor;
u8 individual_aggregator;