aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2018-07-16 19:18:56 +0300
committerFlorin Coras <florin.coras@gmail.com>2018-07-18 04:50:38 +0000
commite4b49c738b74ea25e190cac68399c724a023f067 (patch)
tree28c801f7af9eeb3cad29530b2844e985320abe02 /src
parentee8b973de9d6cfd01f7f5ac6c9058c23f6220ab6 (diff)
loopback:fix delete to check interface class
Change-Id: Ia563b279e85b5da93f79db5a2a4d9b8c04f5be99 Signed-off-by: Eyal Bari <ebari@cisco.com> (cherry picked from commit b52c034c7d53014e9d5c1dfc3501e9adfb0c6391)
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ethernet/interface.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c
index a358080438a..1eb28d7e937 100644
--- a/src/vnet/ethernet/interface.c
+++ b/src/vnet/ethernet/interface.c
@@ -838,25 +838,18 @@ int
vnet_delete_loopback_interface (u32 sw_if_index)
{
vnet_main_t *vnm = vnet_get_main ();
- vnet_sw_interface_t *si;
- u32 hw_if_index;
- vnet_hw_interface_t *hw;
- u32 instance;
if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
return VNET_API_ERROR_INVALID_SW_IF_INDEX;
- si = vnet_get_sw_interface (vnm, sw_if_index);
- hw_if_index = si->hw_if_index;
- hw = vnet_get_hw_interface (vnm, hw_if_index);
- instance = hw->dev_instance;
+ vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ if (hw == 0 || hw->dev_class_index != ethernet_simulated_device_class.index)
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX;
- if (loopback_instance_free (instance) < 0)
- {
- return VNET_API_ERROR_INVALID_SW_IF_INDEX;
- }
+ if (loopback_instance_free (hw->dev_instance) < 0)
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX;
- ethernet_delete_interface (vnm, hw_if_index);
+ ethernet_delete_interface (vnm, hw->hw_if_index);
return 0;
}