tap: allow deletion of tun interface 80/26780/2
authorMatthew Smith <mgsmith@netgate.com>
Wed, 29 Apr 2020 16:17:08 +0000 (11:17 -0500)
committerNeale Ranns <nranns@cisco.com>
Thu, 30 Apr 2020 07:59:52 +0000 (07:59 +0000)
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 <mgsmith@netgate.com>
src/vnet/devices/tap/tap.c

index 76271dd..ea16f76 100644 (file)
@@ -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);