aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bonding/cli.c
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2018-03-28 17:59:00 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-30 20:43:49 +0000
commit70488ab7f87096534aaadd7eab30e8515ac3d60d (patch)
treea6aa6bfeb5d3b078f934273101e69ff36955daab /src/vnet/bonding/cli.c
parentc1613a72a7ef5443319a868879804bb53714068d (diff)
bond: show trace causes a crash if the interface is deleted
For the debug image, if the interface is removed and the trace was collected prior to the interface delete, show trace may cause a crash. This is because vnet_get_sw_interface_name and vnet_get_sup_hw_interface are not safe if the interface is deleted. The fix is to use format_vnet_sw_if_index_name if all we need is to get the interface name in the trace to display. It would show "DELETED" which is better than a crash. Change-Id: I912402d3e71592ece9f49d36c8a6b7af97f3b69e Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/bonding/cli.c')
-rw-r--r--src/vnet/bonding/cli.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c
index 901032e7c4c..1768912bf12 100644
--- a/src/vnet/bonding/cli.c
+++ b/src/vnet/bonding/cli.c
@@ -176,6 +176,8 @@ bond_delete_if (vlib_main_t * vm, u32 sw_if_index)
vnet_hw_interface_t *hw;
u32 *sif_sw_if_index;
u32 thread_index;
+ u32 **s_list = 0;
+ u32 i;
hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
if (hw == NULL || bond_dev_class.index != hw->dev_class_index)
@@ -185,11 +187,20 @@ bond_delete_if (vlib_main_t * vm, u32 sw_if_index)
vec_foreach (sif_sw_if_index, bif->slaves)
{
- sif = bond_get_slave_by_sw_if_index (*sif_sw_if_index);
- if (sif)
- bond_delete_neighbor (vm, bif, sif);
+ vec_add1 (s_list, sif_sw_if_index);
}
+ 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);
+
/* bring down the interface */
vnet_hw_interface_set_flags (vnm, bif->hw_if_index, 0);
vnet_sw_interface_set_flags (vnm, bif->sw_if_index, 0);