summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/arping/arping_api.c2
-rw-r--r--src/plugins/avf/avf_api.c2
-rw-r--r--src/plugins/geneve/geneve_api.c4
-rw-r--r--src/plugins/lacp/lacp_api.c3
-rw-r--r--src/plugins/tracedump/graph_api.c2
-rw-r--r--src/plugins/tracedump/tracedump.c2
-rw-r--r--src/vlibapi/api.h24
-rw-r--r--src/vlibapi/api_common.h84
-rw-r--r--src/vlibapi/api_helper_macros.h2
-rw-r--r--src/vlibapi/api_shared.c156
-rw-r--r--src/vlibmemory/memclnt_api.c8
-rw-r--r--src/vlibmemory/memory_api.c33
-rw-r--r--src/vlibmemory/memory_client.c19
-rw-r--r--src/vlibmemory/memory_shared.c11
-rw-r--r--src/vlibmemory/socket_api.c4
-rw-r--r--src/vlibmemory/vlib_api.c2
-rw-r--r--src/vlibmemory/vlib_api_cli.c137
-rw-r--r--src/vnet/classify/classify_api.c7
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c4
-rw-r--r--src/vnet/interface_api.c25
-rw-r--r--src/vnet/ip/ip_api.c8
-rw-r--r--src/vnet/l2/l2_api.c2
-rw-r--r--src/vnet/mpls/mpls_api.c3
-rw-r--r--src/vnet/vxlan-gpe/vxlan_gpe_api.c4
-rw-r--r--src/vnet/vxlan/vxlan_api.c3
25 files changed, 258 insertions, 293 deletions
diff --git a/src/plugins/arping/arping_api.c b/src/plugins/arping/arping_api.c
index e0c47c7cf33..50fbb04115b 100644
--- a/src/plugins/arping/arping_api.c
+++ b/src/plugins/arping/arping_api.c
@@ -74,7 +74,7 @@ arping_plugin_api_hookup (vlib_main_t *vm)
am->msg_id_base = setup_message_id_table ();
/* Mark API as mp safe */
- vam->is_mp_safe[am->msg_id_base + VL_API_ARPING] = 1;
+ vl_api_set_msg_thread_safe (vam, am->msg_id_base + VL_API_ARPING, 1);
return 0;
}
diff --git a/src/plugins/avf/avf_api.c b/src/plugins/avf/avf_api.c
index 366a983f373..05b4ead90fb 100644
--- a/src/plugins/avf/avf_api.c
+++ b/src/plugins/avf/avf_api.c
@@ -95,7 +95,7 @@ avf_plugin_api_hookup (vlib_main_t * vm)
/* ask for a correctly-sized block of API message decode slots */
avm->msg_id_base = setup_message_id_table ();
- am->is_mp_safe[avm->msg_id_base + VL_API_AVF_DELETE] = 1;
+ vl_api_set_msg_thread_safe (am, avm->msg_id_base + VL_API_AVF_DELETE, 1);
return 0;
}
diff --git a/src/plugins/geneve/geneve_api.c b/src/plugins/geneve/geneve_api.c
index d35a1bf5dbc..5a983948c26 100644
--- a/src/plugins/geneve/geneve_api.c
+++ b/src/plugins/geneve/geneve_api.c
@@ -238,8 +238,8 @@ geneve_api_hookup (vlib_main_t * vm)
*/
geneve_base_msg_id = setup_message_id_table ();
- am->api_trace_cfg[VL_API_GENEVE_ADD_DEL_TUNNEL + REPLY_MSG_ID_BASE].size +=
- 16 * sizeof (u32);
+ vl_api_increase_msg_trace_size (
+ am, VL_API_GENEVE_ADD_DEL_TUNNEL + REPLY_MSG_ID_BASE, 16 * sizeof (u32));
return 0;
}
diff --git a/src/plugins/lacp/lacp_api.c b/src/plugins/lacp/lacp_api.c
index fce2492be8c..fab28cb6a13 100644
--- a/src/plugins/lacp/lacp_api.c
+++ b/src/plugins/lacp/lacp_api.c
@@ -125,7 +125,8 @@ lacp_plugin_api_hookup (vlib_main_t * vm)
lm->msg_id_base = setup_message_id_table ();
/* Mark these APIs as mp safe */
- am->is_mp_safe[lm->msg_id_base + VL_API_SW_INTERFACE_LACP_DUMP] = 1;
+ vl_api_set_msg_thread_safe (
+ am, lm->msg_id_base + VL_API_SW_INTERFACE_LACP_DUMP, 1);
return 0;
}
diff --git a/src/plugins/tracedump/graph_api.c b/src/plugins/tracedump/graph_api.c
index 0626f7d6b42..20eb1b920fc 100644
--- a/src/plugins/tracedump/graph_api.c
+++ b/src/plugins/tracedump/graph_api.c
@@ -252,7 +252,7 @@ graph_api_hookup (vlib_main_t * vm)
gmp->msg_id_base = setup_message_id_table ();
- am->is_mp_safe[gmp->msg_id_base + VL_API_GRAPH_NODE_GET] = 1;
+ vl_api_set_msg_thread_safe (am, gmp->msg_id_base + VL_API_GRAPH_NODE_GET, 1);
return 0;
}
diff --git a/src/plugins/tracedump/tracedump.c b/src/plugins/tracedump/tracedump.c
index f1073fe247d..17b9a423b53 100644
--- a/src/plugins/tracedump/tracedump.c
+++ b/src/plugins/tracedump/tracedump.c
@@ -349,7 +349,7 @@ tracedump_init (vlib_main_t * vm)
/* Add our API messages to the global name_crc hash table */
tdmp->msg_id_base = setup_message_id_table ();
- am->is_mp_safe[tdmp->msg_id_base + VL_API_TRACE_DUMP] = 1;
+ vl_api_set_msg_thread_safe (am, tdmp->msg_id_base + VL_API_TRACE_DUMP, 1);
return error;
}
diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h
index d290301f8d4..f838a80cf71 100644
--- a/src/vlibapi/api.h
+++ b/src/vlibapi/api.h
@@ -124,6 +124,30 @@ typedef int (*vl_msg_traverse_trace_fn) (u8 *, void *);
int vl_msg_traverse_trace (vl_api_trace_t *tp, vl_msg_traverse_trace_fn fn,
void *ctx);
+always_inline void
+vl_api_increase_msg_trace_size (api_main_t *am, u32 msg_id, u32 inc)
+{
+ am->msg_data[msg_id].trace_size += inc;
+}
+
+always_inline void
+vl_api_set_msg_thread_safe (api_main_t *am, u32 msg_id, int v)
+{
+ am->msg_data[msg_id].is_mp_safe = v != 0;
+}
+
+always_inline void
+vl_api_set_msg_autoendian (api_main_t *am, u32 msg_id, int v)
+{
+ am->msg_data[msg_id].is_autoendian = v != 0;
+}
+
+always_inline void
+vl_api_allow_msg_replay (api_main_t *am, u32 msg_id, int v)
+{
+ am->msg_data[msg_id].replay_allowed = v != 0;
+}
+
#endif /* included_api_h */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vlibapi/api_common.h b/src/vlibapi/api_common.h
index 491ecb8eaef..66a547fb93d 100644
--- a/src/vlibapi/api_common.h
+++ b/src/vlibapi/api_common.h
@@ -81,14 +81,6 @@ typedef struct vl_api_registration_
#define VL_API_INVALID_FI ((u32)~0)
-/** Trace configuration for a single message */
-typedef struct
-{
- int size; /**< for sanity checking */
- int trace_enable; /**< trace this message */
- int replay_enable; /**< This message can be replayed */
-} trace_cfg_t;
-
/**
* API trace state
*/
@@ -136,11 +128,11 @@ typedef struct
void *fromjson; /**< JSON to binary convert function */
void *calc_size; /**< message size calculation */
int size; /**< message size */
- int traced; /**< is this message to be traced? */
- int replay; /**< is this message to be replayed? */
- int message_bounce; /**< do not free message after processing */
- int is_mp_safe; /**< worker thread barrier required? */
- int is_autoendian; /**< endian conversion required? */
+ int traced : 1; /**< is this message to be traced? */
+ int replay : 1; /**< is this message to be replayed? */
+ int message_bounce : 1; /**< do not free message after processing */
+ int is_mp_safe : 1; /**< worker thread barrier required? */
+ int is_autoendian : 1; /**< endian conversion required? */
} vl_msg_api_msg_config_t;
/** Message header structure */
@@ -231,47 +223,54 @@ typedef struct
char name[64];
} api_version_t;
-/** API main structure, used by both vpp and binary API clients */
-typedef struct api_main_t
+typedef struct
{
/** Message handler vector */
- void (**msg_handlers) (void *);
+ void (*handler) (void *);
/** non-default message cleanup handler vector */
- void (**msg_cleanup_handlers) (void *);
+ void (*cleanup_handler) (void *);
+
+ /** Message name vector */
+ const char *name;
+
+ /** Message convert function vector */
+ cJSON *(*tojson_handler) (void *);
+
+ /** Message convert function vector */
+ void *(*fromjson_handler) (cJSON *, int *);
/** Message endian handler vector */
- void (**msg_endian_handlers) (void *);
+ void (*endian_handler) (void *);
/** Message print function vector */
- void (**msg_print_handlers) (void *, void *);
+ void (*print_handler) (void *, void *);
/** Message print function vector in JSON */
- void (**msg_print_json_handlers) (void *, void *);
-
- /** Message convert function vector */
- cJSON *(**msg_tojson_handlers) (void *);
-
- /** Message convert function vector */
- void *(**msg_fromjson_handlers) (cJSON *, int *);
+ void (*print_json_handler) (void *, void *);
/** Message calc size function vector */
- uword (**msg_calc_size_funcs) (void *);
+ uword (*calc_size_func) (void *);
- /** Message name vector */
- const char **msg_names;
+ /** trace size for sanity checking */
+ int trace_size;
- /** API message ID by name hash table */
- uword *msg_id_by_name;
+ /** Flags */
+ u8 bounce : 1; /**> Don't automatically free message buffer vetor */
+ u8 is_mp_safe : 1; /**< Message is mp safe vector */
+ u8 is_autoendian : 1; /**< Message requires us to do endian conversion */
+ u8 trace_enable : 1; /**< trace this message */
+ u8 replay_allowed : 1; /**< This message can be replayed */
- /** Don't automatically free message buffer vetor */
- u8 *message_bounce;
+} vl_api_msg_data_t;
- /** Message is mp safe vector */
- u8 *is_mp_safe;
+/** API main structure, used by both vpp and binary API clients */
+typedef struct api_main_t
+{
+ vl_api_msg_data_t *msg_data;
- /** Message requires us to do endian conversion */
- u8 *is_autoendian;
+ /** API message ID by name hash table */
+ uword *msg_id_by_name;
/** Allocator ring vectors (in shared memory) */
struct ring_alloc_ *arings;
@@ -294,9 +293,6 @@ typedef struct api_main_t
/** Print every received message */
int msg_print_flag;
- /** Current trace configuration */
- trace_cfg_t *api_trace_cfg;
-
/** Current process PID */
int our_pid;
@@ -411,6 +407,14 @@ vlibapi_get_main (void)
return my_api_main;
}
+always_inline vl_api_msg_data_t *
+vl_api_get_msg_data (api_main_t *am, u32 msg_id)
+{
+ if (msg_id >= vec_len (am->msg_data))
+ return 0;
+ return am->msg_data + msg_id;
+}
+
always_inline void
vlibapi_set_main (api_main_t * am)
{
diff --git a/src/vlibapi/api_helper_macros.h b/src/vlibapi/api_helper_macros.h
index 6b5b37ae746..9c93d33934b 100644
--- a/src/vlibapi/api_helper_macros.h
+++ b/src/vlibapi/api_helper_macros.h
@@ -30,7 +30,7 @@
#define _NATIVE_TO_NETWORK(t, rmp) \
api_main_t *am = vlibapi_get_main (); \
void (*endian_fp) (void *); \
- endian_fp = am->msg_endian_handlers[t + (REPLY_MSG_ID_BASE)]; \
+ endian_fp = am->msg_data[t + (REPLY_MSG_ID_BASE)].endian_handler; \
(*endian_fp) (rmp);
#define REPLY_MACRO(msg) \
diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c
index 17560e5de23..98da604a456 100644
--- a/src/vlibapi/api_shared.c
+++ b/src/vlibapi/api_shared.c
@@ -79,13 +79,11 @@ vl_msg_api_trace (api_main_t * am, vl_api_trace_t * tp, void *msg)
u8 **old_trace;
u8 *msg_copy;
u32 length;
- trace_cfg_t *cfgp;
u16 msg_id = clib_net_to_host_u16 (*((u16 *) msg));
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, msg_id);
msgbuf_t *header = (msgbuf_t *) (((u8 *) msg) - offsetof (msgbuf_t, data));
- cfgp = am->api_trace_cfg + msg_id;
-
- if (!cfgp || !cfgp->trace_enable)
+ if (!m || !m->trace_enable)
return;
msg_copy = 0;
@@ -227,21 +225,18 @@ vl_msg_api_trace_write_one (api_main_t *am, u8 *msg, FILE *fp)
{
u8 *tmpmem = 0;
int tlen, slen;
- cJSON *(*tojson_fn) (void *);
u32 msg_length = vec_len (msg);
vec_validate (tmpmem, msg_length - 1);
clib_memcpy_fast (tmpmem, msg, msg_length);
u16 id = clib_net_to_host_u16 (*((u16 *) msg));
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, id);
- void (*endian_fp) (void *);
- endian_fp = am->msg_endian_handlers[id];
- (*endian_fp) (tmpmem);
+ m->endian_handler (tmpmem);
- if (id < vec_len (am->msg_tojson_handlers) && am->msg_tojson_handlers[id])
+ if (m && m->tojson_handler)
{
- tojson_fn = am->msg_tojson_handlers[id];
- cJSON *o = tojson_fn (tmpmem);
+ cJSON *o = m->tojson_handler (tmpmem);
char *s = cJSON_Print (o);
slen = strlen (s);
tlen = fwrite (s, 1, slen, fp);
@@ -503,7 +498,7 @@ msg_handler_internal (api_main_t *am, void *the_msg, uword msg_len,
int trace_it, int do_it, int free_it)
{
u16 id = clib_net_to_host_u16 (*((u16 *) the_msg));
- u8 *(*print_fp) (void *, void *);
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, id);
if (PREDICT_FALSE (am->elog_trace_api_messages))
{
@@ -519,51 +514,44 @@ msg_handler_internal (api_main_t *am, void *the_msg, uword msg_len,
u32 c;
} *ed;
ed = ELOG_DATA (am->elog_main, e);
- if (id < vec_len (am->msg_names) && am->msg_names[id])
- ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
+ if (m && m->name)
+ ed->c = elog_string (am->elog_main, (char *) m->name);
else
ed->c = elog_string (am->elog_main, "BOGUS");
}
- if (id < vec_len (am->msg_handlers) && am->msg_handlers[id])
+ if (m && m->handler)
{
if (trace_it)
vl_msg_api_trace (am, am->rx_trace, the_msg);
if (am->msg_print_flag)
{
- fformat (stdout, "[%d]: %s\n", id, am->msg_names[id]);
- print_fp = (void *) am->msg_print_handlers[id];
- if (print_fp == 0)
- {
- fformat (stdout, " [no registered print fn]\n");
- }
+ fformat (stdout, "[%d]: %s\n", id, m->name);
+ if (m->print_handler)
+ m->print_handler (the_msg, stdout);
else
- {
- (*print_fp) (the_msg, stdout);
- }
+ fformat (stdout, " [no registered print fn]\n");
}
uword calc_size = 0;
- uword (*calc_size_fp) (void *);
- calc_size_fp = am->msg_calc_size_funcs[id];
- ASSERT (NULL != calc_size_fp);
- if (calc_size_fp)
+ ASSERT (NULL != m->calc_size_func);
+ if (m->calc_size_func)
{
- calc_size = (*calc_size_fp) (the_msg);
+ calc_size = m->calc_size_func (the_msg);
if (calc_size > msg_len)
{
clib_warning (
"Truncated message '%s' (id %u) received, calculated size "
"%lu is bigger than actual size %llu, message dropped.",
- am->msg_names[id], id, calc_size, msg_len);
+ m->name, id, calc_size, msg_len);
}
}
else
{
clib_warning ("Message '%s' (id %u) has NULL calc_size_func, cannot "
"verify message size is correct",
- am->msg_names[id], id);
+ m->name, id);
}
/* don't process message if it's truncated, otherwise byte swaps
@@ -572,30 +560,26 @@ msg_handler_internal (api_main_t *am, void *the_msg, uword msg_len,
if (do_it && calc_size <= msg_len)
{
- if (!am->is_mp_safe[id])
+ if (!m->is_mp_safe)
{
vl_msg_api_barrier_trace_context (am->msg_names[id]);
vl_msg_api_barrier_sync ();
}
- if (am->is_autoendian[id])
- {
- void (*endian_fp) (void *);
- endian_fp = am->msg_endian_handlers[id];
- (*endian_fp) (the_msg);
- }
+ if (m->is_autoendian)
+ m->endian_handler (the_msg);
if (PREDICT_FALSE (vec_len (am->perf_counter_cbs) != 0))
clib_call_callbacks (am->perf_counter_cbs, am, id,
0 /* before */ );
- (*am->msg_handlers[id]) (the_msg);
+ m->handler (the_msg);
if (PREDICT_FALSE (vec_len (am->perf_counter_cbs) != 0))
clib_call_callbacks (am->perf_counter_cbs, am, id,
1 /* after */ );
- if (!am->is_mp_safe[id])
+ if (!m->is_mp_safe)
vl_msg_api_barrier_release ();
}
}
@@ -629,10 +613,10 @@ msg_handler_internal (api_main_t *am, void *the_msg, uword msg_len,
u32 c;
} *ed;
ed = ELOG_DATA (am->elog_main, e);
- if (id < vec_len (am->msg_names) && am->msg_names[id])
+ if (m && m->name)
{
- ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
- ed->barrier = !am->is_mp_safe[id];
+ ed->c = elog_string (am->elog_main, (char *) m->name);
+ ed->barrier = !m->is_mp_safe;
}
else
{
@@ -693,14 +677,16 @@ vl_msg_api_cleanup_handler (void *the_msg)
{
api_main_t *am = vlibapi_get_main ();
u16 id = clib_net_to_host_u16 (*((u16 *) the_msg));
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, id);
- if (PREDICT_FALSE (id >= vec_len (am->msg_cleanup_handlers)))
+ if (PREDICT_FALSE (!m))
{
clib_warning ("_vl_msg_id too large: %d\n", id);
return;
}
- if (am->msg_cleanup_handlers[id])
- (*am->msg_cleanup_handlers[id]) (the_msg);
+
+ if (m->cleanup_handler)
+ m->cleanup_handler (the_msg);
vl_msg_api_free (the_msg);
}
@@ -712,17 +698,17 @@ void
vl_msg_api_replay_handler (void *the_msg)
{
api_main_t *am = vlibapi_get_main ();
-
u16 id = clib_net_to_host_u16 (*((u16 *) the_msg));
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, id);
- if (PREDICT_FALSE (id >= vec_len (am->msg_handlers)))
+ if (PREDICT_FALSE (!m))
{
clib_warning ("_vl_msg_id too large: %d\n", id);
return;
}
/* do NOT trace the message... */
- if (am->msg_handlers[id])
- (*am->msg_handlers[id]) (the_msg);
+ if (m->handler)
+ m->handler (the_msg);
/* do NOT free the message buffer... */
}
@@ -745,25 +731,11 @@ vl_msg_api_socket_handler (void *the_msg, uword msg_len)
1 /* do_it */, 0 /* free_it */);
}
-#define foreach_msg_api_vector \
- _ (msg_names) \
- _ (msg_handlers) \
- _ (msg_cleanup_handlers) \
- _ (msg_endian_handlers) \
- _ (msg_print_handlers) \
- _ (msg_print_json_handlers) \
- _ (msg_tojson_handlers) \
- _ (msg_fromjson_handlers) \
- _ (msg_calc_size_funcs) \
- _ (api_trace_cfg) \
- _ (message_bounce) \
- _ (is_mp_safe) \
- _ (is_autoendian)
-
void
vl_msg_api_config (vl_msg_api_msg_config_t * c)
{
api_main_t *am = vlibapi_get_main ();
+ vl_api_msg_data_t *m;
/*
* This happens during the java core tests if the message
@@ -782,32 +754,30 @@ vl_msg_api_config (vl_msg_api_msg_config_t * c)
return;
}
-#define _(a) vec_validate (am->a, c->id);
- foreach_msg_api_vector;
-#undef _
-
- if (am->msg_handlers[c->id] && am->msg_handlers[c->id] != c->handler)
- clib_warning
- ("BUG: re-registering 'vl_api_%s_t_handler'."
- "Handler was %llx, replaced by %llx",
- c->name, am->msg_handlers[c->id], c->handler);
-
- am->msg_names[c->id] = c->name;
- am->msg_handlers[c->id] = c->handler;
- am->msg_cleanup_handlers[c->id] = c->cleanup;
- am->msg_endian_handlers[c->id] = c->endian;
- am->msg_print_handlers[c->id] = c->print;
- am->msg_print_json_handlers[c->id] = c->print_json;
- am->msg_tojson_handlers[c->id] = c->tojson;
- am->msg_fromjson_handlers[c->id] = c->fromjson;
- am->msg_calc_size_funcs[c->id] = c->calc_size;
- am->message_bounce[c->id] = c->message_bounce;
- am->is_mp_safe[c->id] = c->is_mp_safe;
- am->is_autoendian[c->id] = c->is_autoendian;
-
- am->api_trace_cfg[c->id].size = c->size;
- am->api_trace_cfg[c->id].trace_enable = c->traced;
- am->api_trace_cfg[c->id].replay_enable = c->replay;
+ vec_validate (am->msg_data, c->id);
+ m = vl_api_get_msg_data (am, c->id);
+
+ if (m->handler && m->handler != c->handler)
+ clib_warning ("BUG: re-registering 'vl_api_%s_t_handler'."
+ "Handler was %llx, replaced by %llx",
+ c->name, m->handler, c->handler);
+
+ m->name = c->name;
+ m->handler = c->handler;
+ m->cleanup_handler = c->cleanup;
+ m->endian_handler = c->endian;
+ m->print_handler = c->print;
+ m->print_json_handler = c->print_json;
+ m->tojson_handler = c->tojson;
+ m->fromjson_handler = c->fromjson;
+ m->calc_size_func = c->calc_size;
+ m->bounce = c->message_bounce;
+ m->is_mp_safe = c->is_mp_safe;
+ m->is_autoendian = c->is_autoendian;
+
+ m->trace_size = c->size;
+ m->trace_enable = c->traced;
+ m->replay_allowed = c->replay;
if (!am->msg_id_by_name)
am->msg_id_by_name = hash_create_string (0, sizeof (uword));
@@ -864,10 +834,10 @@ void
vl_msg_api_set_cleanup_handler (int msg_id, void *fp)
{
api_main_t *am = vlibapi_get_main ();
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, msg_id);
ASSERT (msg_id > 0);
- vec_validate (am->msg_cleanup_handlers, msg_id);
- am->msg_cleanup_handlers[msg_id] = fp;
+ m->cleanup_handler = fp;
}
void
diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c
index 289a4c5d947..9e2971a9d04 100644
--- a/src/vlibmemory/memclnt_api.c
+++ b/src/vlibmemory/memclnt_api.c
@@ -193,8 +193,8 @@ vlib_api_init (void)
foreach_vlib_api_msg;
#undef _
- am->is_mp_safe[VL_API_CONTROL_PING] = 1;
- am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING_REPLY, 1);
return 0;
}
@@ -727,10 +727,10 @@ rpc_api_hookup (vlib_main_t *vm)
foreach_plugin_trace_msg;
#undef _
- am->api_trace_cfg[VL_API_TRACE_PLUGIN_MSG_IDS].replay_enable = 0;
+ vl_api_allow_msg_replay (am, VL_API_TRACE_PLUGIN_MSG_IDS, 0);
/* No reason to halt the parade to create a trace record... */
- am->is_mp_safe[VL_API_TRACE_PLUGIN_MSG_IDS] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_TRACE_PLUGIN_MSG_IDS, 1);
rpc_call_main_thread_cb_fn = vl_api_rpc_call_main_thread;
return 0;
}
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index ecdcc7260be..80d8628bf56 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -532,9 +532,9 @@ vl_mem_api_init (const char *region_name)
* special-case freeing of memclnt_delete messages, so we can
* simply munmap pairwise / private API segments...
*/
- am->message_bounce[VL_API_MEMCLNT_DELETE] = 1;
- am->is_mp_safe[VL_API_MEMCLNT_KEEPALIVE_REPLY] = 1;
- am->is_mp_safe[VL_API_MEMCLNT_KEEPALIVE] = 1;
+ am->msg_data[VL_API_MEMCLNT_DELETE].bounce = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_MEMCLNT_KEEPALIVE_REPLY, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_MEMCLNT_KEEPALIVE, 1);
vlib_set_queue_signal_callback (vm, memclnt_queue_callback);
@@ -768,6 +768,7 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
vlib_node_runtime_t *node, u8 is_private)
{
u16 id = clib_net_to_host_u16 (*((u16 *) the_msg));
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, id);
u8 *(*handler) (void *, void *, void *);
u8 *(*print_fp) (void *, void *);
svm_region_t *old_vlib_rp;
@@ -785,23 +786,23 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
u32 c;
} * ed;
ed = ELOG_DATA (am->elog_main, e);
- if (id < vec_len (am->msg_names) && am->msg_names[id])
- ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
+ if (m && m->name)
+ ed->c = elog_string (am->elog_main, (char *) m->name);
else
ed->c = elog_string (am->elog_main, "BOGUS");
}
- if (id < vec_len (am->msg_handlers) && am->msg_handlers[id])
+ if (m && m->handler)
{
- handler = (void *) am->msg_handlers[id];
+ handler = (void *) m->handler;
if (PREDICT_FALSE (am->rx_trace && am->rx_trace->enabled))
vl_msg_api_trace (am, am->rx_trace, the_msg);
if (PREDICT_FALSE (am->msg_print_flag))
{
- fformat (stdout, "[%d]: %s\n", id, am->msg_names[id]);
- print_fp = (void *) am->msg_print_handlers[id];
+ fformat (stdout, "[%d]: %s\n", id, m->name);
+ print_fp = (void *) am->msg_data[id].print_handler;
if (print_fp == 0)
{
fformat (stdout, " [no registered print fn for msg %d]\n", id);
@@ -811,11 +812,11 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
(*print_fp) (the_msg, vm);
}
}
- is_mp_safe = am->is_mp_safe[id];
+ is_mp_safe = am->msg_data[id].is_mp_safe;
if (!is_mp_safe)
{
- vl_msg_api_barrier_trace_context (am->msg_names[id]);
+ vl_msg_api_barrier_trace_context (am->msg_data[id].name);
vl_msg_api_barrier_sync ();
}
if (is_private)
@@ -829,10 +830,10 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
if (PREDICT_FALSE (vl_mem_api_fuzz_hook != 0))
(*vl_mem_api_fuzz_hook) (id, the_msg);
- if (am->is_autoendian[id])
+ if (m->is_autoendian)
{
void (*endian_fp) (void *);
- endian_fp = am->msg_endian_handlers[id];
+ endian_fp = am->msg_data[id].endian_handler;
(*endian_fp) (the_msg);
}
if (PREDICT_FALSE (vec_len (am->perf_counter_cbs) != 0))
@@ -859,7 +860,7 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
* Special-case, so we can e.g. bounce messages off the vnet
* main thread without copying them...
*/
- if (id >= vec_len (am->message_bounce) || !(am->message_bounce[id]))
+ if (!m || !m->bounce)
{
if (is_private)
{
@@ -892,8 +893,8 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp,
u32 c;
} * ed;
ed = ELOG_DATA (am->elog_main, e);
- if (id < vec_len (am->msg_names) && am->msg_names[id])
- ed->c = elog_string (am->elog_main, (char *) am->msg_names[id]);
+ if (m && m->name)
+ ed->c = elog_string (am->elog_main, (char *) m->name);
else
ed->c = elog_string (am->elog_main, "BOGUS");
ed->barrier = is_mp_safe;
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index 585fca67998..330390e9b1a 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -377,7 +377,7 @@ vl_client_install_client_message_handlers (void)
vl_api_##n##_t_endian, vl_api_##n##_t_print, sizeof (vl_api_##n##_t), 0, \
vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \
vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \
- am->api_trace_cfg[VL_API_##N].replay_enable = 0;
+ am->msg_data[VL_API_##N].replay_allowed = 0;
foreach_api_msg;
#undef _
}
@@ -562,6 +562,8 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
vl_api_get_first_msg_id_t *mp;
api_main_t *am = vlibapi_get_main ();
memory_client_main_t *mm = vlibapi_get_memory_client_main ();
+ vl_api_msg_data_t *m =
+ vl_api_get_msg_data (am, VL_API_GET_FIRST_MSG_ID_REPLY);
f64 timeout;
void *old_handler;
clib_time_t clib_time;
@@ -574,12 +576,11 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_time_init (&clib_time);
/* Push this plugin's first_msg_id_reply handler */
- old_handler = am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY];
- am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = (void *)
- vl_api_get_first_msg_id_reply_t_handler;
- if (!am->msg_calc_size_funcs[VL_API_GET_FIRST_MSG_ID_REPLY])
+ old_handler = m->handler;
+ m->handler = (void *) vl_api_get_first_msg_id_reply_t_handler;
+ if (!m->calc_size_func)
{
- am->msg_calc_size_funcs[VL_API_GET_FIRST_MSG_ID_REPLY] =
+ m->calc_size_func =
(uword (*) (void *)) vl_api_get_first_msg_id_reply_t_calc_size;
}
@@ -608,7 +609,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
sock_err:
/* Restore old handler */
- am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
+ m->handler = old_handler;
return -1;
}
@@ -633,7 +634,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
}
}
/* Restore old handler */
- am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
+ m->handler = old_handler;
return rv;
}
@@ -641,7 +642,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
result:
/* Restore the old handler */
- am->msg_handlers[VL_API_GET_FIRST_MSG_ID_REPLY] = old_handler;
+ m->handler = old_handler;
if (rv == (u16) ~ 0)
clib_warning ("plugin '%s' not registered", plugin_name);
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c
index b70f45fae14..77a610b9434 100644
--- a/src/vlibmemory/memory_shared.c
+++ b/src/vlibmemory/memory_shared.c
@@ -117,14 +117,16 @@ vl_msg_api_alloc_internal (svm_region_t *vlib_rp, int nbytes, int pool,
if (CLIB_DEBUG > 0)
{
u16 *msg_idp, msg_id;
+ vl_api_msg_data_t *m;
clib_warning
("garbage collect pool %d ring %d index %d", pool, i,
q->head);
msg_idp = (u16 *) (rv->data);
msg_id = clib_net_to_host_u16 (*msg_idp);
- if (msg_id < vec_len (vlibapi_get_main ()->msg_names))
+ m = vl_api_get_msg_data (am, msg_id);
+ if (m)
clib_warning ("msg id %d name %s", (u32) msg_id,
- vlibapi_get_main ()->msg_names[msg_id]);
+ m->name);
}
shmem_hdr->garbage_collects++;
goto collected;
@@ -731,10 +733,7 @@ vl_unmap_shmem_internal (u8 is_client)
is_client ? svm_region_exit_client () : svm_region_exit ();
- /* $$$ more careful cleanup, valgrind run... */
- vec_free (am->msg_handlers);
- vec_free (am->msg_endian_handlers);
- vec_free (am->msg_print_handlers);
+ vec_free (am->msg_data);
}
void
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c
index 3df182b68b6..e451d62d3a3 100644
--- a/src/vlibmemory/socket_api.c
+++ b/src/vlibmemory/socket_api.c
@@ -132,7 +132,7 @@ vl_socket_api_send (vl_api_registration_t * rp, u8 * elem)
cf = vl_api_registration_file (rp);
ASSERT (rp->registration_type > REGISTRATION_TYPE_SHMEM);
- if (msg_id >= vec_len (am->api_trace_cfg))
+ if (msg_id >= vec_len (am->msg_data))
{
clib_warning ("id out of range: %d", msg_id);
vl_msg_api_free ((void *) elem);
@@ -802,7 +802,7 @@ vl_sock_api_init (vlib_main_t * vm)
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, vl_api_##n##_t_calc_size); \
- am->api_trace_cfg[VL_API_##N].replay_enable = 0;
+ am->msg_data[VL_API_##N].replay_allowed = 0;
foreach_vlib_api_msg;
#undef _
diff --git a/src/vlibmemory/vlib_api.c b/src/vlibmemory/vlib_api.c
index b598f0b9852..3d4f8829d9a 100644
--- a/src/vlibmemory/vlib_api.c
+++ b/src/vlibmemory/vlib_api.c
@@ -340,7 +340,7 @@ vlib_apis_hookup (vlib_main_t *vm)
*/
msg_id_base = setup_message_id_table ();
- am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_GET_NODE_GRAPH, 1);
return 0;
}
diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c
index 39e22507c1b..084080f1e6d 100644
--- a/src/vlibmemory/vlib_api_cli.c
+++ b/src/vlibmemory/vlib_api_cli.c
@@ -242,20 +242,19 @@ vl_api_message_table_command (vlib_main_t * vm,
vlib_cli_output (vm, "%-4s %-40s %6s %7s", "ID", "Name", "Bounce",
"MP-safe");
- for (i = 1; i < vec_len (am->msg_names); i++)
+ for (i = 1; i < vec_len (am->msg_data); i++)
{
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, i);
if (verbose == 0)
{
vlib_cli_output (vm, "%-4d %s", i,
- am->msg_names[i] ? am->msg_names[i] :
- " [no handler]");
+ m->name ? m->name : " [no handler]");
}
else
{
vlib_cli_output (vm, "%-4d %-40s %6d %7d", i,
- am->msg_names[i] ? am->msg_names[i] :
- " [no handler]", am->message_bounce[i],
- am->is_mp_safe[i]);
+ m->name ? m->name : " [no handler]", m->bounce,
+ m->is_mp_safe);
}
}
@@ -510,7 +509,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
assert_size (file_size_left, clib_max (size, sizeof (u16)));
msg_id = ntohs (*((u16 *) msg));
if (msg_id >= vec_len (msgid_vec) ||
- msgid_vec[msg_id] >= vec_len (am->api_trace_cfg))
+ msgid_vec[msg_id] >= vec_len (am->msg_data))
vlib_cli_output (vm, "warning: unknown msg id %d for msg number %d\n",
msg_id, i);
@@ -522,7 +521,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
for (; i <= last_index; i++)
{
- trace_cfg_t *cfgp;
+ vl_api_msg_data_t *m;
u16 msg_id;
int size;
@@ -537,7 +536,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
msg_id = ntohs (*((u16 *) msg));
if (msg_id >= vec_len (msgid_vec) ||
- msgid_vec[msg_id] >= vec_len (am->api_trace_cfg))
+ msgid_vec[msg_id] >= vec_len (am->msg_data))
{
vlib_cli_output (
vm, "warning: unknown msg id %d for msg number %d, skipping\n",
@@ -547,7 +546,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
}
msg_id = msgid_vec[msg_id];
- cfgp = am->api_trace_cfg + msg_id;
+ m = vl_api_get_msg_data (am, msg_id);
/* Copy the buffer (from the read-only mmap'ed file) */
vec_validate (tmpbuf, size - 1 + sizeof (uword));
@@ -561,9 +560,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
if (((which == DUMP || which == DUMP_JSON) &&
clib_arch_is_little_endian))
{
- void (*endian_fp) (void *);
- if (msg_id >= vec_len (am->msg_endian_handlers)
- || (am->msg_endian_handlers[msg_id] == 0))
+ if (m && m->endian_handler == 0)
{
vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id);
munmap (hp, file_size);
@@ -571,8 +568,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
am->replay_in_progress = 0;
return;
}
- endian_fp = am->msg_endian_handlers[msg_id];
- (*endian_fp) (tmpbuf + sizeof (uword));
+ m->endian_handler (tmpbuf + sizeof (uword));
}
/* msg_id always in network byte order */
@@ -585,13 +581,9 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
switch (which)
{
case DUMP_JSON:
- if (msg_id < vec_len (am->msg_print_json_handlers) &&
- am->msg_print_json_handlers[msg_id])
+ if (m && m->print_json_handler)
{
- u8 *(*print_fp) (void *, void *);
-
- print_fp = (void *) am->msg_print_json_handlers[msg_id];
- (*print_fp) (tmpbuf + sizeof (uword), vm);
+ m->print_json_handler (tmpbuf + sizeof (uword), vm);
}
else
{
@@ -602,13 +594,9 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
break;
case DUMP:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id])
+ if (m && m->print_handler)
{
- u8 *(*print_fp) (void *, void *);
-
- print_fp = (void *) am->msg_print_handlers[msg_id];
- (*print_fp) (tmpbuf + sizeof (uword), vm);
+ m->print_handler (tmpbuf + sizeof (uword), vm);
}
else
{
@@ -619,25 +607,20 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
break;
case INITIALIZERS:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id])
+ if (m && m->print_handler)
{
u8 *s;
int j;
- u8 *(*print_fp) (void *, void *);
-
- print_fp = (void *) am->msg_print_handlers[msg_id];
vlib_cli_output (vm, "/*");
- (*print_fp) (tmpbuf + sizeof (uword), vm);
+ m->print_handler (tmpbuf + sizeof (uword), vm);
vlib_cli_output (vm, "*/\n");
- s = format (0, "static u8 * vl_api_%s_%d[%d] = {",
- am->msg_names[msg_id], i,
- am->api_trace_cfg[msg_id].size);
+ s = format (0, "static u8 * vl_api_%s_%d[%d] = {", m->name, i,
+ m->trace_size);
- for (j = 0; j < am->api_trace_cfg[msg_id].size; j++)
+ for (j = 0; j < m->trace_size; j++)
{
if ((j & 7) == 0)
s = format (s, "\n ");
@@ -650,22 +633,17 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
break;
case REPLAY:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id] && cfgp->replay_enable)
+ if (m && m->print_handler && m->replay_allowed)
{
- void (*handler) (void *, vlib_main_t *);
-
- handler = (void *) am->msg_handlers[msg_id];
-
- if (!am->is_mp_safe[msg_id])
+ if (!m->is_mp_safe)
vl_msg_api_barrier_sync ();
- (*handler) (tmpbuf + sizeof (uword), vm);
- if (!am->is_mp_safe[msg_id])
+ m->handler (tmpbuf + sizeof (uword));
+ if (!m->is_mp_safe)
vl_msg_api_barrier_release ();
}
else
{
- if (cfgp->replay_enable)
+ if (m->replay_allowed)
vlib_cli_output (vm, "Skipping msg id %d: no handler\n",
msg_id);
break;
@@ -708,11 +686,17 @@ vl_msg_print_trace (u8 *msg, void *ctx)
vl_msg_print_args *a = ctx;
api_main_t *am = vlibapi_get_main ();
u16 msg_id = ntohs (*((u16 *) msg));
- void (*print_fp) (void *, void *);
- void (**handlers) (void *, void *);
+ vl_api_msg_data_t *m = vl_api_get_msg_data (am, msg_id);
+ void (*handler) (void *, void *) = 0;
u8 is_json = a->is_json;
u8 *tmpbuf = 0;
+ if (!m)
+ {
+ vlib_cli_output (a->vm, "Unknown msg id %d\n", msg_id);
+ return 0;
+ }
+
if (clib_arch_is_little_endian)
{
u32 msg_length = vec_len (msg);
@@ -720,25 +704,15 @@ vl_msg_print_trace (u8 *msg, void *ctx)
clib_memcpy_fast (tmpbuf, msg, msg_length);
msg = tmpbuf;
- void (*endian_fp) (void *);
- endian_fp = am->msg_endian_handlers[msg_id];
- (*endian_fp) (tmpbuf);
+ m->endian_handler (tmpbuf);
}
- if (is_json)
- handlers = am->msg_print_json_handlers;
- else
- handlers = am->msg_print_handlers;
+ handler = is_json ? m->print_json_handler : m->print_handler;
- if (msg_id < vec_len (handlers) && handlers[msg_id])
- {
- print_fp = (void *) handlers[msg_id];
- (*print_fp) (msg, a->vm);
- }
+ if (handler)
+ handler (msg, a->vm);
else
- {
- vlib_cli_output (a->vm, "Skipping msg id %d: no print fcn\n", msg_id);
- }
+ vlib_cli_output (a->vm, "Skipping msg id %d: no print fcn\n", msg_id);
vec_free (tmpbuf);
return 0;
@@ -825,9 +799,8 @@ vl_msg_exec_json_command (vlib_main_t *vm, cJSON *o)
{
api_main_t *am = vlibapi_get_main ();
u16 msg_id;
- void *(*fromjson) (cJSON *, int *);
int len = 0, rv = -1;
- trace_cfg_t *cfgp;
+ vl_api_msg_data_t *m;
u8 *msg = 0;
cJSON *msg_id_obj = cJSON_GetObjectItem (o, "_msgname");
@@ -849,6 +822,7 @@ vl_msg_exec_json_command (vlib_main_t *vm, cJSON *o)
u8 *name_crc = format (0, "%s_%s%c", name, crc, 0);
msg_id = vl_msg_find_id_by_name_and_crc (vm, am, (char *) name_crc);
+ m = vl_api_get_msg_data (am, msg_id);
if (msg_id == (u16) ~0)
{
msg_id = vl_msg_find_id_by_name (vm, am, name);
@@ -862,28 +836,19 @@ vl_msg_exec_json_command (vlib_main_t *vm, cJSON *o)
}
vec_free (name_crc);
- cfgp = am->api_trace_cfg + msg_id;
- if (!am->api_trace_cfg)
- {
- vlib_cli_output (vm, "msg id %d no trace config\n", msg_id);
- return rv;
- }
-
- if (cfgp->replay_enable)
+ if (m->replay_allowed)
{
-
if (proc_warning)
vlib_cli_output (vm, "warning: msg %d has different signature\n");
- fromjson = am->msg_fromjson_handlers[msg_id];
- if (!fromjson)
+ if (!m->fromjson_handler)
{
vlib_cli_output (vm, "missing fromjson convert function! id %d\n",
msg_id);
return rv;
}
- msg = (u8 *) fromjson (o, &len);
+ msg = (u8 *) m->fromjson_handler (o, &len);
if (!msg)
{
vlib_cli_output (vm, "failed to convert JSON (msg id %d)!\n",
@@ -892,24 +857,18 @@ vl_msg_exec_json_command (vlib_main_t *vm, cJSON *o)
}
if (clib_arch_is_little_endian)
- {
- void (*endian_fp) (void *);
- endian_fp = am->msg_endian_handlers[msg_id];
- (*endian_fp) (msg);
- }
+ m->endian_handler (msg);
- void (*handler) (void *, vlib_main_t *);
- handler = (void *) am->msg_handlers[msg_id];
- if (!handler)
+ if (!m->handler)
{
vlib_cli_output (vm, "no handler for msg id %d!\n", msg_id);
goto end;
}
- if (!am->is_mp_safe[msg_id])
+ if (!m->is_mp_safe)
vl_msg_api_barrier_sync ();
- (*handler) (msg, vm);
- if (!am->is_mp_safe[msg_id])
+ m->handler (msg);
+ if (!m->is_mp_safe)
vl_msg_api_barrier_release ();
}
diff --git a/src/vnet/classify/classify_api.c b/src/vnet/classify/classify_api.c
index 0f9243c0365..53e3cb6c349 100644
--- a/src/vnet/classify/classify_api.c
+++ b/src/vnet/classify/classify_api.c
@@ -966,9 +966,10 @@ classify_api_hookup (vlib_main_t * vm)
/*
* Trace space for classifier mask+match
*/
- am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
- am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size +=
- 5 * sizeof (u32x4);
+ vl_api_increase_msg_trace_size (am, VL_API_CLASSIFY_ADD_DEL_TABLE,
+ 5 * sizeof (u32x4));
+ vl_api_increase_msg_trace_size (am, VL_API_CLASSIFY_ADD_DEL_SESSION,
+ 5 * sizeof (u32x4));
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index 6dd9da08a23..cc1896b108a 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -330,8 +330,8 @@ vhost_user_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
/* Mark CREATE_VHOST_USER_IF as mp safe */
- am->is_mp_safe[VL_API_CREATE_VHOST_USER_IF] = 1;
- am->is_mp_safe[VL_API_CREATE_VHOST_USER_IF_V2] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_CREATE_VHOST_USER_IF, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_CREATE_VHOST_USER_IF_V2, 1);
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 29f98f7851f..5766f2ca21f 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -1630,21 +1630,24 @@ interface_api_hookup (vlib_main_t * vm)
REPLY_MSG_ID_BASE = setup_message_id_table ();
/* Mark these APIs as mp safe */
- am->is_mp_safe[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DUMP] = 1;
- am->is_mp_safe[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DETAILS] = 1;
- am->is_mp_safe[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TAG_ADD_DEL] = 1;
- am->is_mp_safe[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SET_INTERFACE_NAME] =
- 1;
+ vl_api_set_msg_thread_safe (am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DUMP,
+ 1);
+ vl_api_set_msg_thread_safe (
+ am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DETAILS, 1);
+ vl_api_set_msg_thread_safe (
+ am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TAG_ADD_DEL, 1);
+ vl_api_set_msg_thread_safe (
+ am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SET_INTERFACE_NAME, 1);
/* Do not replay VL_API_SW_INTERFACE_DUMP messages */
- am->api_trace_cfg[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DUMP]
- .replay_enable = 0;
+ vl_api_allow_msg_replay (am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DUMP,
+ 0);
/* Mark these APIs as autoendian */
- am->is_autoendian[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SET_TX_PLACEMENT] =
- 1;
- am->is_autoendian[REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TX_PLACEMENT_GET] =
- 1;
+ vl_api_set_msg_autoendian (
+ am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SET_TX_PLACEMENT, 1);
+ vl_api_set_msg_autoendian (
+ am, REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_TX_PLACEMENT_GET, 1);
return 0;
}
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index ae4ee0cec52..e03b0103391 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -2119,10 +2119,10 @@ ip_api_hookup (vlib_main_t * vm)
/*
* Mark the route add/del API as MP safe
*/
- am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
- am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_REPLY] = 1;
- am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_V2] = 1;
- am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_V2_REPLY] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_REPLY, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_V2, 1);
+ vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_V2_REPLY, 1);
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 5a0432de43d..c555a17d5ea 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -1281,7 +1281,7 @@ l2_api_hookup (vlib_main_t * vm)
api_main_t *am = vlibapi_get_main ();
/* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
- am->is_mp_safe[VL_API_BRIDGE_DOMAIN_DUMP] = 1;
+ vl_api_set_msg_thread_safe (am, VL_API_BRIDGE_DOMAIN_DUMP, 1);
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index 4efb61786ad..fac52827e1d 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -508,7 +508,8 @@ mpls_api_hookup (vlib_main_t * vm)
/*
* Trace space for 8 MPLS encap labels
*/
- am->api_trace_cfg[VL_API_MPLS_TUNNEL_ADD_DEL].size += 8 * sizeof (u32);
+ vl_api_increase_msg_trace_size (am, VL_API_MPLS_TUNNEL_ADD_DEL,
+ 8 * sizeof (u32));
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/vxlan-gpe/vxlan_gpe_api.c b/src/vnet/vxlan-gpe/vxlan_gpe_api.c
index 9423b2745be..e9cf17f270b 100644
--- a/src/vnet/vxlan-gpe/vxlan_gpe_api.c
+++ b/src/vnet/vxlan-gpe/vxlan_gpe_api.c
@@ -342,8 +342,8 @@ vxlan_gpe_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
- am->api_trace_cfg[VL_API_VXLAN_GPE_ADD_DEL_TUNNEL].size +=
- 17 * sizeof (u32);
+ vl_api_increase_msg_trace_size (am, VL_API_VXLAN_GPE_ADD_DEL_TUNNEL,
+ 17 * sizeof (u32));
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vnet/vxlan/vxlan_api.c b/src/vnet/vxlan/vxlan_api.c
index c97597a2ef2..56fd654951f 100644
--- a/src/vnet/vxlan/vxlan_api.c
+++ b/src/vnet/vxlan/vxlan_api.c
@@ -354,7 +354,8 @@ vxlan_api_hookup (vlib_main_t * vm)
{
api_main_t *am = vlibapi_get_main ();
- am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32);
+ vl_api_increase_msg_trace_size (am, VL_API_VXLAN_ADD_DEL_TUNNEL,
+ 16 * sizeof (u32));
/*
* Set up the (msg_name, crc, message-id) table