summaryrefslogtreecommitdiffstats
path: root/src/vcl/vppcom.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-09-08 22:43:47 -0700
committerFlorin Coras <florin.coras@gmail.com>2020-09-14 14:33:50 +0000
commit935ce75cb060da34991e6b02bec5680445f85323 (patch)
tree1afceb3650b40c60ae9a83937e1ae839c9aee40a /src/vcl/vppcom.c
parentb88de908101081f870d94e1415659326b589b9ce (diff)
vcl: add support for app socket api
To enable add "app-socket-api /path/to/socket" to vcl.conf. On vpp side, add use-app-socket-api to session stanza in startup.conf VPP allocates a socket per application namespace which it places in the app_ns_sockets subfolder of the run folder (default /var/run/vpp). The socket used implicitly selects the app namespace for the vcl app. Type: feature Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ifc14b93dcbf6ef9bed1852d46cd069f4855b92ef
Diffstat (limited to 'src/vcl/vppcom.c')
-rw-r--r--src/vcl/vppcom.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 0f79f88423f..dcf8ba2aa72 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -863,6 +863,16 @@ vcl_session_worker_update_reply_handler (vcl_worker_t * wrk, void *data)
s->vpp_handle, wrk->wrk_index);
}
+static int
+vcl_api_recv_fd (vcl_worker_t * wrk, int *fds, int n_fds)
+{
+
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_recv_fds (wrk, fds, n_fds);
+
+ return vcl_bapi_recv_fds (wrk, fds, n_fds);
+}
+
static void
vcl_session_app_add_segment_handler (vcl_worker_t * wrk, void *data)
{
@@ -875,7 +885,7 @@ vcl_session_app_add_segment_handler (vcl_worker_t * wrk, void *data)
if (msg->fd_flags)
{
- vl_socket_client_recv_fd_msg2 (&wrk->bapi_sock_ctx, &fd, 1, 5);
+ vcl_api_recv_fd (wrk, &fd, 1);
seg_type = SSVM_SEGMENT_MEMFD;
}
@@ -1178,6 +1188,26 @@ vppcom_app_exit (void)
vcl_elog_stop (vcm);
}
+static int
+vcl_api_attach (void)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_attach ();
+
+ return vcl_bapi_attach ();
+}
+
+static void
+vcl_api_detach (vcl_worker_t * wrk)
+{
+ vcl_send_app_detach (wrk);
+
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_detach (wrk);
+
+ return vcl_bapi_disconnect_from_vpp ();
+}
+
/*
* VPPCOM Public API functions
*/
@@ -1211,7 +1241,7 @@ vppcom_app_create (const char *app_name)
/* Allocate default worker */
vcl_worker_alloc_and_init ();
- if ((rv = vcl_bapi_attach ()))
+ if ((rv = vcl_api_attach ()))
return rv;
VDBG (0, "app_name '%s', my_client_index %d (0x%x)", app_name,
@@ -1241,8 +1271,7 @@ vppcom_app_destroy (void)
}));
/* *INDENT-ON* */
- vcl_send_app_detach (current_wrk);
- vcl_bapi_disconnect_from_vpp ();
+ vcl_api_detach (current_wrk);
vcl_worker_cleanup (current_wrk, 0 /* notify vpp */ );
vcl_elog_stop (vcm);