diff options
author | Steven <sluong@cisco.com> | 2017-04-21 13:31:50 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-04-24 14:46:10 +0000 |
commit | 53129423a6f4e43b39f7547424fbaea99e56f7e2 (patch) | |
tree | 07305ca3fa23738aab32b1cb4b55a61608da2e71 /src/vnet | |
parent | 636815199a1f359fdd0da706985a74eca95254da (diff) |
vhost: remove socket linked file when deleting vhost interface
- Unlink the file created for the socket when deleting vhost interface
if we are the server mode.
- Remove all vhost interfaces when VPP process is exitting.
Change-Id: Id9b676cd027bbd67b473bbd01901d1ecc4d8e6cb
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/devices/virtio/vhost-user.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index cce9705e45b..4f4f038a38b 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -1354,15 +1354,6 @@ vhost_user_init (vlib_main_t * vm) VLIB_INIT_FUNCTION (vhost_user_init); -static clib_error_t * -vhost_user_exit (vlib_main_t * vm) -{ - /* TODO cleanup */ - return 0; -} - -VLIB_MAIN_LOOP_EXIT_FUNCTION (vhost_user_exit); - static u8 * format_vhost_trace (u8 * s, va_list * va) { @@ -2553,6 +2544,7 @@ vhost_user_term_if (vhost_user_intf_t * vui) vui->unix_server_index); unix_file_del (&unix_main, uf); vui->unix_server_index = ~0; + unlink (vui->sock_filename); } } @@ -2590,6 +2582,23 @@ vhost_user_delete_if (vnet_main_t * vnm, vlib_main_t * vm, u32 sw_if_index) return rv; } +static clib_error_t * +vhost_user_exit (vlib_main_t * vm) +{ + vnet_main_t *vnm = vnet_get_main (); + vhost_user_main_t *vum = &vhost_user_main; + vhost_user_intf_t *vui; + + /* *INDENT-OFF* */ + pool_foreach (vui, vum->vhost_user_interfaces, { + vhost_user_delete_if (vnm, vm, vui->sw_if_index); + }); + /* *INDENT-ON* */ + return 0; +} + +VLIB_MAIN_LOOP_EXIT_FUNCTION (vhost_user_exit); + /** * Open server unix socket on specified sock_filename. */ |