From bac326cb7c5f8856786ca046df8cfa3be9f53926 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Mon, 5 Aug 2019 09:47:58 -0700 Subject: 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 Change-Id: If4d2da074338b16aab0df54e00d719e55c45221a --- src/vnet/bonding/cli.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/vnet/bonding/cli.c') diff --git a/src/vnet/bonding/cli.c b/src/vnet/bonding/cli.c index 9d3b9429ba7..f45a31ce99a 100644 --- a/src/vnet/bonding/cli.c +++ b/src/vnet/bonding/cli.c @@ -576,7 +576,8 @@ bond_enslave (vlib_main_t * vm, bond_enslave_args_t * args) pool_get (bm->neighbors, sif); clib_memset (sif, 0, sizeof (*sif)); sw = pool_elt_at_index (im->sw_interfaces, args->slave); - sif->port_enabled = sw->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP; + /* port_enabled is both admin up and hw link up */ + sif->port_enabled = vnet_sw_interface_is_up (vnm, sw->sw_if_index); sif->sw_if_index = sw->sw_if_index; sif->hw_if_index = sw->hw_if_index; sif->packet_template_index = (u8) ~ 0; @@ -642,8 +643,7 @@ bond_enslave (vlib_main_t * vm, bond_enslave_args_t * args) if (bm->lacp_enable_disable) (*bm->lacp_enable_disable) (vm, bif, sif, 1); } - else if (sif->port_enabled && - (sif_hw->flags & VNET_HW_INTERFACE_FLAG_LINK_UP)) + else if (sif->port_enabled) { bond_enable_collecting_distributing (vm, sif); } -- cgit 1.2.3-korg