aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2020-04-29 11:17:08 -0500
committerNeale Ranns <nranns@cisco.com>2020-04-30 07:59:52 +0000
commit3d18fbf8e62f4647c85848cb7bab1940d8bad400 (patch)
treeee51d6bb5c7681e8625132607a2fa198cb9b2d28 /src
parent6e39ff03a6fa28a2655d767454394413252a269d (diff)
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 <mgsmith@netgate.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/devices/tap/tap.c7
1 files changed, 5 insertions, 2 deletions
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);