From 36217e3ca8a1ca2e7a341b6b44ffc25e6497191c Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Fri, 23 Jul 2021 08:51:10 +0000 Subject: api: API trace improvements Type: improvement * add support for JSON format in API trace * add ability to replay JSON API trace in both VPP and VAT2 * use CRC for backward compatibility check during JSON API replay * fix API trace CLI (and remove duplicits) * remove custom dump * remove vppapitrace.py * update docs accordingly Change-Id: I5294f68bebe6cbe738630f457f3a87720e06486b Signed-off-by: Filip Tehlar Signed-off-by: Ole Troan --- src/vlibmemory/socket_api.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/vlibmemory/socket_api.c') diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 60ca650d92f..ce834a70aac 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -495,7 +495,13 @@ vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t * mp) regp = socket_main.current_rp; - ASSERT (regp->registration_type == REGISTRATION_TYPE_SOCKET_SERVER); + /* client already connected through shared memory? */ + if (!regp || regp->registration_type != REGISTRATION_TYPE_SOCKET_SERVER) + { + clib_warning ( + "unsupported API call: already connected though shared memory?"); + return; + } regp->name = format (0, "%s%c", mp->name, 0); @@ -765,14 +771,15 @@ reply: vl_sock_api_send_fd_msg (cf->file_descriptor, &memfd->fd, 1); } -#define foreach_vlib_api_msg \ - _(SOCKCLNT_CREATE, sockclnt_create, 1) \ - _(SOCKCLNT_DELETE, sockclnt_delete, 1) \ - _(SOCK_INIT_SHM, sock_init_shm, 1) +#define foreach_vlib_api_msg \ + _ (SOCKCLNT_CREATE, sockclnt_create, 0) \ + _ (SOCKCLNT_DELETE, sockclnt_delete, 0) \ + _ (SOCK_INIT_SHM, sock_init_shm, 0) clib_error_t * vl_sock_api_init (vlib_main_t * vm) { + api_main_t *am = vlibapi_get_main (); clib_file_main_t *fm = &file_main; clib_file_t template = { 0 }; vl_api_registration_t *rp; @@ -784,13 +791,13 @@ vl_sock_api_init (vlib_main_t * vm) if (sm->socket_name == 0) return 0; -#define _(N,n,t) \ - vl_msg_api_set_handlers(VL_API_##N, #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), t); +#define _(N, n, t) \ + vl_msg_api_set_handlers (VL_API_##N, #n, vl_api_##n##_t_handler, \ + vl_noop_handler, vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, sizeof (vl_api_##n##_t), t, \ + vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \ + vl_api_##n##_t_fromjson); \ + am->api_trace_cfg[VL_API_##N].replay_enable = 0; foreach_vlib_api_msg; #undef _ -- cgit 1.2.3-korg