Commit 75da6acb authored by Tomasz Kulasek's avatar Tomasz Kulasek Committed by Jim Harris
Browse files

net/vpp: fix detach error handling



When VPP detach fails (e.g. when VPP dies before application), net
framework never finishes.

Change-Id: I2cbc7bde274e185fdf7f3cf1c7ea3ddd14dcf365
Signed-off-by: default avatarTomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/464678


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 32e22643
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -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;
}