unformat_input_t _line_input, *line_input = &_line_input;
u8 vc_cfg_input = 0;
struct stat s;
+#if VCL_BAPI_ENABLED
u32 uid, gid;
+#endif
fd = open (conf_fname, O_RDONLY);
if (fd < 0)
VCFG_DBG (0, "VCL<%d>: configured max-workers %u", getpid (),
vcl_cfg->max_workers);
}
- else if (unformat (line_input, "api-socket-name %s",
- &vcl_cfg->vpp_bapi_socket_name))
- {
- vec_terminate_c_string (vcl_cfg->vpp_bapi_socket_name);
- VCFG_DBG (0, "VCL<%d>: configured api-socket-name (%s)",
- getpid (), vcl_cfg->vpp_bapi_socket_name);
- }
else if (unformat (line_input, "app-socket-api %s",
&vcl_cfg->vpp_app_socket_api))
{
VCFG_DBG (0, "VCL<%d>: configured app-socket-api (%s)",
getpid (), vcl_cfg->vpp_app_socket_api);
}
- else if (unformat (line_input, "uid %d", &uid))
- {
- vl_set_memory_uid (uid);
- VCFG_DBG (0, "VCL<%d>: configured uid %d", getpid (), uid);
- }
- else if (unformat (line_input, "gid %d", &gid))
- {
- vl_set_memory_gid (gid);
- VCFG_DBG (0, "VCL<%d>: configured gid %d", getpid (), gid);
- }
else if (unformat (line_input, "segment-size 0x%lx",
&vcl_cfg->segment_size))
{
VCFG_DBG (0, "VCL<%d>: configured huge_page (%d)", getpid (),
vcl_cfg->huge_page);
}
+ else if (unformat (line_input, "use-mq-eventfd"))
+ {
+ vcl_cfg->use_mq_eventfd = 1;
+ VCFG_DBG (0, "VCL<%d>: configured with mq with eventfd",
+ getpid ());
+ }
+ else if (unformat (line_input, "tls-engine %u",
+ &vcl_cfg->tls_engine))
+ {
+ VCFG_DBG (0, "VCL<%d>: configured tls-engine %u (0x%x)",
+ getpid (), vcl_cfg->tls_engine, vcl_cfg->tls_engine);
+ }
+ else if (unformat (line_input, "multi-thread-workers"))
+ {
+ vcl_cfg->mt_wrk_supported = 1;
+ VCFG_DBG (0, "VCL<%d>: configured with multithread workers",
+ getpid ());
+ }
+ else if (unformat (line_input, "app_original_dst"))
+ {
+ vcl_cfg->app_original_dst = 1;
+ VCFG_DBG (0, "VCL<%d>: support original destination", getpid ());
+ }
+#if VCL_BAPI_ENABLED
else if (unformat (line_input, "namespace-secret %lu",
&vcl_cfg->namespace_secret))
{
- VCFG_DBG (0, "VCL<%d>: configured namespace_secret %llu "
- "(0x%llx)", getpid (),
+ VCFG_DBG (0,
+ "VCL<%d>: configured namespace_secret %llu "
+ "(0x%llx)",
+ getpid (),
(unsigned long long) vcl_cfg->namespace_secret,
(unsigned long long) vcl_cfg->namespace_secret);
}
if (nsid_vec_len > max_nsid_vec_len)
{
vec_set_len (vcl_cfg->namespace_id, max_nsid_vec_len);
- VCFG_DBG (0, "VCL<%d>: configured namespace_id is too long,"
+ VCFG_DBG (0,
+ "VCL<%d>: configured namespace_id is too long,"
" truncated to %d characters!",
getpid (), max_nsid_vec_len);
}
- VCFG_DBG (0, "VCL<%d>: configured namespace_id %s",
- getpid (), (char *) vcl_cfg->namespace_id);
+ VCFG_DBG (0, "VCL<%d>: configured namespace_id %s", getpid (),
+ (char *) vcl_cfg->namespace_id);
}
- else if (unformat (line_input, "use-mq-eventfd"))
- {
- vcl_cfg->use_mq_eventfd = 1;
- VCFG_DBG (0, "VCL<%d>: configured with mq with eventfd",
- getpid ());
- }
- else if (unformat (line_input, "tls-engine %u",
- &vcl_cfg->tls_engine))
+ else if (unformat (line_input, "api-socket-name %s",
+ &vcl_cfg->vpp_bapi_socket_name))
{
- VCFG_DBG (0, "VCL<%d>: configured tls-engine %u (0x%x)",
- getpid (), vcl_cfg->tls_engine, vcl_cfg->tls_engine);
+ vec_terminate_c_string (vcl_cfg->vpp_bapi_socket_name);
+ VCFG_DBG (0, "VCL<%d>: configured api-socket-name (%s)",
+ getpid (), vcl_cfg->vpp_bapi_socket_name);
}
- else if (unformat (line_input, "multi-thread-workers"))
+ else if (unformat (line_input, "uid %d", &uid))
{
- vcl_cfg->mt_wrk_supported = 1;
- VCFG_DBG (0, "VCL<%d>: configured with multithread workers",
- getpid ());
+ vl_set_memory_uid (uid);
+ VCFG_DBG (0, "VCL<%d>: configured uid %d", getpid (), uid);
}
- else if (unformat (line_input, "app_original_dst"))
+ else if (unformat (line_input, "gid %d", &gid))
{
- vcl_cfg->app_original_dst = 1;
- VCFG_DBG (0, "VCL<%d>: support original destination", getpid ());
+ vl_set_memory_gid (gid);
+ VCFG_DBG (0, "VCL<%d>: configured gid %d", getpid (), gid);
}
+#endif
else if (unformat (line_input, "}"))
{
vc_cfg_input = 0;
/*
* VCL Binary API
*/
+#if defined(VCL_BAPI_ENABLED)
int vcl_bapi_attach (void);
int vcl_bapi_app_worker_add (void);
void vcl_bapi_app_worker_del (vcl_worker_t * wrk);
int vcl_bapi_del_cert_key_pair (u32 ckpair_index);
u32 vcl_bapi_max_nsid_len (void);
int vcl_bapi_worker_set (void);
+#endif
/*
* VCL Socket API
int vcl_sapi_add_cert_key_pair (vppcom_cert_key_pair_t *ckpair);
int vcl_sapi_del_cert_key_pair (u32 ckpair_index);
+static inline int
+vcl_api_attach (void)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_attach ();
+#if VCL_BAPI_ENABLED
+ return vcl_bapi_attach ();
+#else
+ return -1;
+#endif
+}
+
+static inline 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);
+
+#if VCL_BAPI_ENABLED
+ return vcl_bapi_recv_fds (wrk, fds, n_fds);
+#else
+ return -1;
+#endif
+}
+
+static inline void
+vcl_api_detach (vcl_worker_t *wrk)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_detach (wrk);
+
+#if VCL_BAPI_ENABLED
+ vcl_bapi_disconnect_from_vpp ();
+#endif
+}
+
+static inline int
+vcl_api_add_cert_key_pair (vppcom_cert_key_pair_t *ckpair)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_add_cert_key_pair (ckpair);
+
+#if VCL_BAPI_ENABLED
+ return vcl_bapi_add_cert_key_pair (ckpair);
+#else
+ return -1;
+#endif
+}
+
+static inline int
+vcl_api_app_worker_add (void)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_app_worker_add ();
+
+#if VCL_BAPI_ENABLED
+ return vcl_bapi_app_worker_add ();
+#else
+ return -1;
+#endif
+}
+
+static inline void
+vcl_api_app_worker_del (vcl_worker_t *wrk)
+{
+ if (wrk->api_client_handle == ~0)
+ return;
+
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_app_worker_del (wrk);
+
+#if VCL_BAPI_ENABLED
+ vcl_bapi_app_worker_del (wrk);
+#endif
+}
+
+static inline int
+vcl_api_del_cert_key_pair (uint32_t ckpair_index)
+{
+ if (vcm->cfg.vpp_app_socket_api)
+ return vcl_sapi_del_cert_key_pair (ckpair_index);
+
+#if VCL_BAPI_ENABLED
+ return vcl_bapi_del_cert_key_pair (ckpair_index);
+#else
+ return -1;
+#endif
+}
+
/*
* Utility functions
*/
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)
{
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 ();
-}
-
int
vcl_is_first_reattach_to_execute ()
{
vcl_worker_detach_sessions (wrk);
}
-static void
-vcl_api_detach (vcl_worker_t * wrk)
-{
- if (wrk->api_client_handle == ~0)
- return;
-
- 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
*/
vcl_worker_cleanup (wrk, 0 /* notify vpp */ );
}
- vcl_api_detach (current_wrk);
+ if (current_wrk->api_client_handle != ~0)
+ {
+ vcl_send_app_detach (current_wrk);
+ vcl_api_detach (current_wrk);
+ }
+
vcl_worker_cleanup (current_wrk, 0 /* notify vpp */ );
vcl_set_worker_index (~0);
int
vppcom_add_cert_key_pair (vppcom_cert_key_pair_t *ckpair)
{
- if (vcm->cfg.vpp_app_socket_api)
- return vcl_sapi_add_cert_key_pair (ckpair);
- else
- return vcl_bapi_add_cert_key_pair (ckpair);
+ return vcl_api_add_cert_key_pair (ckpair);
}
int
vppcom_del_cert_key_pair (uint32_t ckpair_index)
{
- if (vcm->cfg.vpp_app_socket_api)
- return vcl_sapi_del_cert_key_pair (ckpair_index);
- else
- return vcl_bapi_del_cert_key_pair (ckpair_index);
+ return vcl_api_del_cert_key_pair (ckpair_index);
}
int