From 6787994d307f0eb80f92971c91bac3bb0606cf23 Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek Date: Fri, 23 Aug 2019 10:14:36 +0200 Subject: [PATCH] net/vpp: fix detach error handling When VPP detach fails (e.g. when VPP dies before application), net framework never finishes. Signed-off-by: Tomasz Kulasek Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464678 (master) (cherry picked from commit 75da6acb1a942c5d0185622f9241f160d12001e4) Change-Id: I2cbc7bde274e185fdf7f3cf1c7ea3ddd14dcf365 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467139 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- module/sock/vpp/vpp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/module/sock/vpp/vpp.c b/module/sock/vpp/vpp.c index 9383739b9e..190704b1e8 100644 --- a/module/sock/vpp/vpp.c +++ b/module/sock/vpp/vpp.c @@ -131,6 +131,7 @@ static struct spdk_vpp_main { struct spdk_poller *vpp_queue_poller; struct spdk_poller *app_queue_poller; + struct spdk_poller *timeout_poller; } g_svm; struct spdk_vpp_sock_group_impl { @@ -1263,8 +1264,13 @@ err: static void _spdk_vpp_application_detached(void *arg) { + if (!g_svm.vpp_initialized) { + return; + } + spdk_poller_unregister(&g_svm.vpp_queue_poller); spdk_poller_unregister(&g_svm.app_queue_poller); + spdk_poller_unregister(&g_svm.timeout_poller); g_svm.vpp_initialized = false; g_svm.vpp_state = VPP_STATE_START; @@ -1276,13 +1282,22 @@ _spdk_vpp_application_detached(void *arg) spdk_net_framework_fini_next(); } +static int +_spdk_vpp_application_detached_timeout(void *arg) +{ + if (g_svm.vpp_initialized) { + /* We need to finish detach on initial thread */ + spdk_thread_send_msg(g_svm.init_thread, _spdk_vpp_application_detached, NULL); + } + return 0; +} + static void vl_api_application_detach_reply_t_handler(vl_api_application_detach_reply_t *mp) { if (mp->retval) { SPDK_ERRLOG("Application detach from VPP failed (%d).\n", ntohl(mp->retval)); g_svm.vpp_state = VPP_STATE_FAILED; - return; } /* We need to finish detach on initial thread */ @@ -1305,6 +1320,9 @@ _spdk_vpp_app_detach(void) bmp->context = ntohl(0xfeedface); vl_msg_api_send_shmem(g_svm.vl_input_queue, (u8 *)&bmp); + g_svm.timeout_poller = spdk_poller_register(_spdk_vpp_application_detached_timeout, + NULL, 10000000); + return 0; }