aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bonding/device.c
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-08-05 09:47:58 -0700
committerDave Barach <openvpp@barachs.net>2019-08-17 11:54:47 +0000
commitbac326cb7c5f8856786ca046df8cfa3be9f53926 (patch)
treea8548c92ba59cee7fbf227171d7154d193da49af /src/vnet/bonding/device.c
parentc02924ec6ebe0aa8e4903c6ca2cc0bf6c36da8cb (diff)
bonding lacp: deleting virtual interface which was enslaved may cause crash
Virtual interfaces may be part of the bonding like physical interfaces. The difference is virtual interfaces may disappear dynamically. As an example, the following CLI sequence may crash the debug image create vhost-user socket /tmp/sock1 create bond mode lacp bond add BondEthernet0 VirtualEthernet0/0/0 delete vhost-user VirtualEhernet0/0/0 Notice the virtual interface is deleted without first doing bond delete. The proper order is to first remove the slave interface from the bond prior to deleting the virtual interface as shown below. But we should handle it anyway. create vhost-user socket /tmp/sock1 create bond mode lacp bond add BondEthernet0 VirtualEthernet0/0/0 bond del VirtualEthernet0/0/0 <----- delete vhost-user VirtualEhernet0/0/0 The fix is to register for VNET_SW_INTERFACE_ADD_DEL_FUNCTION and remove the slave interface from the bond if the to-be-deleted interface is part of the bond. We check the interface that it is actually up before we send the lacp pdu. Up means both hw and sw admin up. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: If4d2da074338b16aab0df54e00d719e55c45221a
Diffstat (limited to 'src/vnet/bonding/device.c')
-rw-r--r--src/vnet/bonding/device.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/vnet/bonding/device.c b/src/vnet/bonding/device.c
index e9771959437..77a53b6a17a 100644
--- a/src/vnet/bonding/device.c
+++ b/src/vnet/bonding/device.c
@@ -777,9 +777,10 @@ bond_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
for (i = 0; i < vec_len (event_data); i++)
{
hw_if_index = event_data[i];
- /* walk hw interface to process all subinterfaces */
- vnet_hw_interface_walk_sw (vnm, hw_if_index,
- bond_active_interface_switch_cb, 0);
+ if (vnet_get_hw_interface_or_null (vnm, hw_if_index))
+ /* walk hw interface to process all subinterfaces */
+ vnet_hw_interface_walk_sw (vnm, hw_if_index,
+ bond_active_interface_switch_cb, 0);
}
vec_reset_length (event_data);
}
@@ -808,6 +809,25 @@ VNET_DEVICE_CLASS (bond_dev_class) = {
/* *INDENT-ON* */
+static clib_error_t *
+bond_slave_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
+{
+ bond_main_t *bm = &bond_main;
+ slave_if_t *sif;
+ bond_detach_slave_args_t args = { 0 };
+
+ if (is_add)
+ return 0;
+ sif = bond_get_slave_by_sw_if_index (sw_if_index);
+ if (!sif)
+ return 0;
+ args.slave = sw_if_index;
+ bond_detach_slave (bm->vlib_main, &args);
+ return args.error;
+}
+
+VNET_SW_INTERFACE_ADD_DEL_FUNCTION (bond_slave_interface_add_del);
+
/*
* fd.io coding-style-patch-verification: ON
*