aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-10-16 15:03:06 +0200
committerDave Barach <openvpp@barachs.net>2019-10-17 13:32:14 +0000
commitcc3aac05697976b512ce68017ca02b27d613eff2 (patch)
tree7dbb95f1ae45e32d80ad505f8f56d411dfe9eeef /src
parenta9e1f7b99bcb2164f3481cf48134d4efe7319c04 (diff)
bonding: fix interface deletion
Copy sw_if_index value instead of using pointers to original bif->slaves content which could be overriden by eg. vec_del1(). Type: feature Change-Id: I37e458effd6b2367479574f7bd3facd4e93bada4 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/bonding/cli.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c
index 6d0245dc687..9687e8841fe 100644
--- a/src/vnet/bonding/cli.c
+++ b/src/vnet/bonding/cli.c
@@ -312,8 +312,7 @@ bond_delete_if (vlib_main_t * vm, u32 sw_if_index)
slave_if_t *sif;
vnet_hw_interface_t *hw;
u32 *sif_sw_if_index;
- u32 **s_list = 0;
- u32 i;
+ u32 *s_list = 0;
hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
if (hw == NULL || bond_dev_class.index != hw->dev_class_index)
@@ -321,21 +320,14 @@ bond_delete_if (vlib_main_t * vm, u32 sw_if_index)
bif = bond_get_master_by_dev_instance (hw->dev_instance);
- vec_foreach (sif_sw_if_index, bif->slaves)
+ vec_append (s_list, bif->slaves);
+ vec_foreach (sif_sw_if_index, s_list)
{
- vec_add1 (s_list, sif_sw_if_index);
+ sif = bond_get_slave_by_sw_if_index (*sif_sw_if_index);
+ if (sif)
+ bond_delete_neighbor (vm, bif, sif);
}
-
- for (i = 0; i < vec_len (s_list); i++)
- {
- sif_sw_if_index = s_list[i];
- sif = bond_get_slave_by_sw_if_index (*sif_sw_if_index);
- if (sif)
- bond_delete_neighbor (vm, bif, sif);
- }
-
- if (s_list)
- vec_free (s_list);
+ vec_free (s_list);
/* bring down the interface */
vnet_hw_interface_set_flags (vnm, bif->hw_if_index, 0);