fd closed twice 63/2963/2
authorEyal Bari <ebari@cisco.com>
Mon, 19 Sep 2016 15:47:39 +0000 (18:47 +0300)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 20 Sep 2016 17:29:19 +0000 (17:29 +0000)
fd close()ed after call to unix_file_del of same fd

Change-Id: Ia8bf77b72b6cea7c70e004199ce11a33b6260720
Signed-off-by: Eyal Bari <ebari@cisco.com>
vnet/vnet/devices/af_packet/af_packet.c
vnet/vnet/devices/netmap/netmap.c
vnet/vnet/devices/virtio/vhost-user.c
vnet/vnet/unix/tapcli.c

index 17eddd6..cec25fe 100644 (file)
@@ -308,6 +308,9 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
       unix_file_del (&unix_main, unix_main.file_pool + apif->unix_file_index);
       apif->unix_file_index = ~0;
     }
+  else
+    close (apif->fd);
+
   ring_sz = apif->rx_req->tp_block_size * apif->rx_req->tp_block_nr +
     apif->tx_req->tp_block_size * apif->tx_req->tp_block_nr;
   if (munmap (apif->rx_ring, ring_sz))
@@ -315,7 +318,6 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name)
                  host_if_name);
   apif->rx_ring = NULL;
   apif->tx_ring = NULL;
-  close (apif->fd);
   apif->fd = -1;
 
   vec_free (apif->rx_req);
index fe6f1ea..3bdb442 100644 (file)
@@ -59,8 +59,7 @@ close_netmap_if (netmap_main_t * nm, netmap_if_t * nif)
       unix_file_del (&unix_main, unix_main.file_pool + nif->unix_file_index);
       nif->unix_file_index = ~0;
     }
-
-  if (nif->fd > -1)
+  else if (nif->fd > -1)
     close (nif->fd);
 
   if (nif->mem_region)
index 76c682f..2ca5aa8 100644 (file)
@@ -252,10 +252,11 @@ vhost_user_if_disconnect (vhost_user_intf_t * vui)
       unix_file_del (&unix_main, unix_main.file_pool + vui->unix_file_index);
       vui->unix_file_index = ~0;
     }
+  else
+    close (vui->unix_fd);
 
   hash_unset (vum->vhost_user_interface_index_by_sock_fd, vui->unix_fd);
   hash_unset (vum->vhost_user_interface_index_by_listener_fd, vui->unix_fd);
-  close (vui->unix_fd);
   vui->unix_fd = -1;
   vui->is_up = 0;
   for (q = 0; q < vui->num_vrings; q++)
index c2328f0..0be68a9 100644 (file)
@@ -1025,10 +1025,11 @@ static int tapcli_tap_disconnect (tapcli_interface_t *ti)
     unix_file_del (&unix_main, unix_main.file_pool + ti->unix_file_index);
     ti->unix_file_index = ~0;
   }
+  else
+    close(ti->unix_fd);
 
   hash_unset (tm->tapcli_interface_index_by_unix_fd, ti->unix_fd);
   hash_unset (tm->tapcli_interface_index_by_sw_if_index, ti->sw_if_index);
-  close(ti->unix_fd);
   close(ti->provision_fd);
   ti->unix_fd = -1;
   ti->provision_fd = -1;