summaryrefslogtreecommitdiffstats
path: root/src/vnet/bonding/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/bonding/cli.c')
-rw-r--r--src/vnet/bonding/cli.c88
1 files changed, 43 insertions, 45 deletions
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)