From 3d18fbf8e62f4647c85848cb7bab1940d8bad400 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Wed, 29 Apr 2020 11:17:08 -0500 Subject: tap: allow deletion of tun interface Type: improvement tap_delete_if() returns early if the interface type is not VIRTIO_IF_TYPE_TAP. Allow VIRTIO_IF_TYPE_TUN also and take appropriate action for those interfaces. Change-Id: I196b6d6f3f5e1543a14d6be76fd879d44c9794fd Signed-off-by: Matthew Smith --- src/vnet/devices/tap/tap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/vnet') diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c index 76271dd3f95..ea16f76bcb0 100644 --- a/src/vnet/devices/tap/tap.c +++ b/src/vnet/devices/tap/tap.c @@ -770,7 +770,7 @@ tap_delete_if (vlib_main_t * vm, u32 sw_if_index) vif = pool_elt_at_index (mm->interfaces, hw->dev_instance); - if (vif->type != VIRTIO_IF_TYPE_TAP) + if ((vif->type != VIRTIO_IF_TYPE_TAP) && (vif->type != VIRTIO_IF_TYPE_TUN)) return VNET_API_ERROR_INVALID_INTERFACE; /* bring down the interface */ @@ -779,7 +779,10 @@ tap_delete_if (vlib_main_t * vm, u32 sw_if_index) for (i = 0; i < vif->num_rxqs; i++) vnet_hw_interface_unassign_rx_thread (vnm, vif->hw_if_index, i); - ethernet_delete_interface (vnm, vif->hw_if_index); + if (vif->type == VIRTIO_IF_TYPE_TAP) + ethernet_delete_interface (vnm, vif->hw_if_index); + else /* VIRTIO_IF_TYPE_TUN */ + vnet_delete_hw_interface (vnm, vif->hw_if_index); vif->hw_if_index = ~0; tap_free (vm, vif); -- cgit 1.2.3-korg