bonding lacp: deleting virtual interface which was enslaved may cause crash 38/22138/2
authorSteven Luong <sluong@cisco.com>
Mon, 5 Aug 2019 16:47:58 +0000 (09:47 -0700)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 20 Sep 2019 05:48:27 +0000 (05:48 +0000)
commitc5dd20250b74aa0d84b0280df034fc69b273709f
tree09935fa9fa69ca7b0fbb40c51d9c724a9acc63d7
parent69dd1f5bceae81b2b422a410db0f72d12043c97d
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
(cherry picked from commit bac326cb7c5f8856786ca046df8cfa3be9f53926)
src/plugins/lacp/cli.c
src/plugins/lacp/lacp.c
src/vnet/bonding/cli.c
src/vnet/bonding/device.c
src/vnet/bonding/node.c