aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-03-08 19:08:56 -0500
committerOle Trøan <otroan@employees.org>2017-03-09 19:07:17 +0000
commit80f54e20270ed0628ee725e3e3c515731a0188f2 (patch)
treefa06d939942af6f5126ee645c38cb787814bfb6f
parentb3b2de71ceea0cc7ce18f89cc8180ed4a42e355d (diff)
vlib_mains == 0 special cases be gone
Clean up spurious binary API client link dependency on libvlib.so, which managed to hide behind vlib_mains == 0 checks reached by VLIB_xxx_FUNCTION macros. Change-Id: I5df1f8ab07dca1944250e643ccf06e60a8462325 Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c8
-rw-r--r--src/vlib-api.am4
-rw-r--r--src/vlib/buffer.c27
-rw-r--r--src/vlib/global_funcs.h2
-rw-r--r--src/vlib/node_cli.c28
-rw-r--r--src/vlib/node_funcs.h4
-rw-r--r--src/vlib/threads.c16
-rw-r--r--src/vlib/threads.h43
-rw-r--r--src/vlibapi/api.h4
-rw-r--r--src/vlibapi/api_shared.c530
-rw-r--r--src/vlibapi/node_serialize.c15
-rw-r--r--src/vlibmemory/memory_vlib.c471
-rw-r--r--src/vnet/devices/virtio/vhost-user.c9
-rw-r--r--src/vpp-api-test.am2
-rw-r--r--src/vpp/api/api.c1
-rw-r--r--src/vpp/api/gmon.c9
16 files changed, 575 insertions, 598 deletions
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index 16bec20ad16..b0aaaaeca17 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -380,13 +380,9 @@ dpdk_ipsec_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
im->cb.check_support_cb = dpdk_ipsec_check_support;
im->cb.add_del_sa_sess_cb = add_del_sa_sess;
- if (vec_len (vlib_mains) == 0)
- vlib_node_set_state (&vlib_global_main, dpdk_crypto_input_node.index,
+ for (i = 1; i < tm->n_vlib_mains; i++)
+ vlib_node_set_state (vlib_mains[i], dpdk_crypto_input_node.index,
VLIB_NODE_STATE_POLLING);
- else
- for (i = 1; i < tm->n_vlib_mains; i++)
- vlib_node_set_state (vlib_mains[i], dpdk_crypto_input_node.index,
- VLIB_NODE_STATE_POLLING);
/* TODO cryptodev counters */
diff --git a/src/vlib-api.am b/src/vlib-api.am
index c05929b1f2a..4e1dae99f92 100644
--- a/src/vlib-api.am
+++ b/src/vlib-api.am
@@ -14,7 +14,7 @@
lib_LTLIBRARIES += libvlibmemory.la libvlibapi.la libvlibmemoryclient.la \
libvlibsocket.la
-libvlibmemory_la_DEPENDENCIES = libvppinfra.la libsvm.la libvlib.la
+libvlibmemory_la_DEPENDENCIES = libvppinfra.la libsvm.la
libvlibmemory_la_LIBADD = $(libvlibmemory_la_DEPENDENCIES) -lpthread
libvlibmemory_la_SOURCES = \
vlibmemory/api.h \
@@ -26,7 +26,7 @@ libvlibmemory_la_SOURCES = \
vlibmemory/unix_shared_memory_queue.c \
vlibmemory/unix_shared_memory_queue.h
-libvlibapi_la_DEPENDENCIES = libvppinfra.la libvlib.la libvlibmemory.la
+libvlibapi_la_DEPENDENCIES = libvppinfra.la
libvlibapi_la_LIBADD = $(libvlibapi_la_DEPENDENCIES)
libvlibapi_la_SOURCES = \
vlibapi/api.h \
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 9f26bec7b56..6ba82584fcd 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -261,7 +261,28 @@ done:
return result;
}
-vlib_main_t **vlib_mains;
+/*
+ * Hand-craft a static vector w/ length 1, so vec_len(vlib_mains) =1
+ * and vlib_mains[0] = &vlib_global_main from the beginning of time.
+ *
+ * The only place which should ever expand vlib_mains is start_workers()
+ * in threads.c. It knows about the bootstrap vector.
+ */
+/* *INDENT-OFF* */
+static struct
+{
+ vec_header_t h;
+ vlib_main_t *vm;
+} __attribute__ ((packed)) __bootstrap_vlib_main_vector
+ __attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))) =
+{
+ .h.len = 1,
+ .vm = &vlib_global_main,
+};
+/* *INDENT-ON* */
+
+vlib_main_t **vlib_mains = &__bootstrap_vlib_main_vector.vm;
+
/* When dubugging validate that given buffers are either known allocated
or known free. */
@@ -280,7 +301,7 @@ vlib_buffer_validate_alloc_free (vlib_main_t * vm,
ASSERT (os_get_cpu_number () == 0);
/* smp disaster check */
- if (vlib_mains)
+ if (vec_len (vlib_mains) > 1)
ASSERT (vm == vlib_mains[0]);
is_free = expected_state == VLIB_BUFFER_KNOWN_ALLOCATED;
@@ -956,7 +977,7 @@ show_buffers (vlib_main_t * vm,
do
{
- curr_vm = vec_len (vlib_mains) ? vlib_mains[vm_index] : vm;
+ curr_vm = vlib_mains[vm_index];
bm = curr_vm->buffer_main;
/* *INDENT-OFF* */
diff --git a/src/vlib/global_funcs.h b/src/vlib/global_funcs.h
index bbdbdef50b2..f51ec381d7e 100644
--- a/src/vlib/global_funcs.h
+++ b/src/vlib/global_funcs.h
@@ -23,7 +23,7 @@ always_inline vlib_main_t *
vlib_get_main (void)
{
vlib_main_t *vm;
- vm = vlib_mains ? vlib_mains[os_get_cpu_number ()] : &vlib_global_main;
+ vm = vlib_mains[os_get_cpu_number ()];
ASSERT (vm);
return vm;
}
diff --git a/src/vlib/node_cli.c b/src/vlib/node_cli.c
index 05d0f0b5a95..62ab2e64bc4 100644
--- a/src/vlib/node_cli.c
+++ b/src/vlib/node_cli.c
@@ -248,16 +248,11 @@ show_node_runtime (vlib_main_t * vm,
if (unformat (input, "max") || unformat (input, "m"))
max = 1;
- if (vec_len (vlib_mains) == 0)
- vec_add1 (stat_vms, vm);
- else
+ for (i = 0; i < vec_len (vlib_mains); i++)
{
- for (i = 0; i < vec_len (vlib_mains); i++)
- {
- stat_vm = vlib_mains[i];
- if (stat_vm)
- vec_add1 (stat_vms, stat_vm);
- }
+ stat_vm = vlib_mains[i];
+ if (stat_vm)
+ vec_add1 (stat_vms, stat_vm);
}
/*
@@ -331,7 +326,7 @@ show_node_runtime (vlib_main_t * vm,
}
}
- if (vec_len (vlib_mains))
+ if (vec_len (vlib_mains) > 1)
{
vlib_worker_thread_t *w = vlib_worker_threads + j;
if (j > 0)
@@ -404,16 +399,11 @@ clear_node_runtime (vlib_main_t * vm,
vlib_main_t **stat_vms = 0, *stat_vm;
vlib_node_runtime_t *r;
- if (vec_len (vlib_mains) == 0)
- vec_add1 (stat_vms, vm);
- else
+ for (i = 0; i < vec_len (vlib_mains); i++)
{
- for (i = 0; i < vec_len (vlib_mains); i++)
- {
- stat_vm = vlib_mains[i];
- if (stat_vm)
- vec_add1 (stat_vms, stat_vm);
- }
+ stat_vm = vlib_mains[i];
+ if (stat_vm)
+ vec_add1 (stat_vms, stat_vm);
}
vlib_worker_thread_barrier_sync (vm);
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index f49a8d6fa75..8ccfc438020 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -201,7 +201,7 @@ vlib_get_frame_no_check (vlib_main_t * vm, uword frame_index)
vlib_frame_t *f;
u32 cpu_index = frame_index & VLIB_CPU_MASK;
u32 offset = frame_index & VLIB_OFFSET_MASK;
- vm = vlib_mains ? vlib_mains[cpu_index] : vm;
+ vm = vlib_mains[cpu_index];
f = vm->heap_base + offset;
return f;
}
@@ -213,7 +213,7 @@ vlib_frame_index_no_check (vlib_main_t * vm, vlib_frame_t * f)
ASSERT (((uword) f & VLIB_CPU_MASK) == 0);
- vm = vlib_mains ? vlib_mains[f->cpu_index] : vm;
+ vm = vlib_mains[f->cpu_index];
i = ((u8 *) f - (u8 *) vm->heap_base);
return i | f->cpu_index;
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index e3ea3c9cb47..4676be97412 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -570,9 +570,13 @@ start_workers (vlib_main_t * vm)
if (n_vlib_mains > 1)
{
- vec_validate (vlib_mains, tm->n_vlib_mains - 1);
+ /* Replace hand-crafted length-1 vector with a real vector */
+ vlib_mains = 0;
+
+ vec_validate_aligned (vlib_mains, tm->n_vlib_mains - 1,
+ CLIB_CACHE_LINE_BYTES);
_vec_len (vlib_mains) = 0;
- vec_add1 (vlib_mains, vm);
+ vec_add1_aligned (vlib_mains, vm, CLIB_CACHE_LINE_BYTES);
vlib_worker_threads->wait_at_barrier =
clib_mem_alloc_aligned (sizeof (u32), CLIB_CACHE_LINE_BYTES);
@@ -685,7 +689,7 @@ start_workers (vlib_main_t * vm)
/* Packet trace buffers are guaranteed to be empty, nothing to do here */
clib_mem_set_heap (oldheap);
- vec_add1 (vlib_mains, vm_clone);
+ vec_add1_aligned (vlib_mains, vm_clone, CLIB_CACHE_LINE_BYTES);
vm_clone->error_main.counters =
vec_dup (vlib_mains[0]->error_main.counters);
@@ -805,7 +809,7 @@ vlib_worker_thread_node_runtime_update (void)
ASSERT (os_get_cpu_number () == 0);
- if (vec_len (vlib_mains) == 0)
+ if (vec_len (vlib_mains) == 1)
return;
vm = vlib_mains[0];
@@ -1148,7 +1152,7 @@ vlib_worker_thread_barrier_sync (vlib_main_t * vm)
f64 deadline;
u32 count;
- if (!vlib_mains)
+ if (vec_len (vlib_mains) < 2)
return;
count = vec_len (vlib_mains) - 1;
@@ -1179,7 +1183,7 @@ vlib_worker_thread_barrier_release (vlib_main_t * vm)
{
f64 deadline;
- if (!vlib_mains)
+ if (vec_len (vlib_mains) < 2)
return;
if (--vlib_worker_threads[0].recursion_level > 0)
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index 75a5a2818fb..a032311c689 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -222,30 +222,25 @@ vlib_worker_thread_barrier_check (void)
}
}
-#define foreach_vlib_main(body) \
-do { \
- vlib_main_t ** __vlib_mains = 0, *this_vlib_main; \
- int ii; \
- \
- if (vec_len (vlib_mains) == 0) \
- vec_add1 (__vlib_mains, &vlib_global_main); \
- else \
- { \
- for (ii = 0; ii < vec_len (vlib_mains); ii++) \
- { \
- this_vlib_main = vlib_mains[ii]; \
- if (this_vlib_main) \
- vec_add1 (__vlib_mains, this_vlib_main); \
- } \
- } \
- \
- for (ii = 0; ii < vec_len (__vlib_mains); ii++) \
- { \
- this_vlib_main = __vlib_mains[ii]; \
- /* body uses this_vlib_main... */ \
- (body); \
- } \
- vec_free (__vlib_mains); \
+#define foreach_vlib_main(body) \
+do { \
+ vlib_main_t ** __vlib_mains = 0, *this_vlib_main; \
+ int ii; \
+ \
+ for (ii = 0; ii < vec_len (vlib_mains); ii++) \
+ { \
+ this_vlib_main = vlib_mains[ii]; \
+ if (this_vlib_main) \
+ vec_add1 (__vlib_mains, this_vlib_main); \
+ } \
+ \
+ for (ii = 0; ii < vec_len (__vlib_mains); ii++) \
+ { \
+ this_vlib_main = __vlib_mains[ii]; \
+ /* body uses this_vlib_main... */ \
+ (body); \
+ } \
+ vec_free (__vlib_mains); \
} while (0);
#define foreach_sched_policy \
diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h
index 2cbeb63c44c..87a561211d4 100644
--- a/src/vlibapi/api.h
+++ b/src/vlibapi/api.h
@@ -252,11 +252,13 @@ void vl_msg_api_queue_handler (unix_shared_memory_queue_t * q);
vl_api_trace_t *vl_msg_api_trace_get (api_main_t * am,
vl_api_trace_which_t which);
+void vl_msg_api_barrier_sync (void) __attribute__ ((weak));
+void vl_msg_api_barrier_release (void) __attribute__ ((weak));
void vl_msg_api_free (void *);
void vl_noop_handler (void *mp);
-clib_error_t *vl_api_init (vlib_main_t * vm);
void vl_msg_api_increment_missing_client_counter (void);
void vl_msg_api_post_mortem_dump (void);
+void vl_msg_api_post_mortem_dump_enable_disable (int enable);
void vl_msg_api_register_pd_handler (void *handler,
u16 msg_id_host_byte_order);
int vl_msg_api_pd_handler (void *mp, int rv);
diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c
index 69ba10c1c08..6774e3ddb75 100644
--- a/src/vlibapi/api_shared.c
+++ b/src/vlibapi/api_shared.c
@@ -23,11 +23,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <vppinfra/format.h>
#include <vppinfra/byte_order.h>
#include <vppinfra/error.h>
@@ -36,19 +31,14 @@
#include <vlibapi/api.h>
#include <vppinfra/elog.h>
-api_main_t api_main;
-
-void vl_msg_api_barrier_sync (void) __attribute__ ((weak));
-void
-vl_msg_api_barrier_sync (void)
-{
-}
-
-void vl_msg_api_barrier_release (void) __attribute__ ((weak));
-void
-vl_msg_api_barrier_release (void)
-{
-}
+/* *INDENT-OFF* */
+api_main_t api_main =
+ {
+ .region_name = "/unset",
+ .api_uid = -1,
+ .api_gid = -1,
+ };
+/* *INDENT-ON* */
void
vl_msg_api_increment_missing_client_counter (void)
@@ -57,14 +47,6 @@ vl_msg_api_increment_missing_client_counter (void)
am->missing_clients++;
}
-typedef enum
-{
- DUMP,
- CUSTOM_DUMP,
- REPLAY,
- INITIALIZERS,
-} vl_api_replay_t;
-
int
vl_msg_api_rx_trace_enabled (api_main_t * am)
{
@@ -397,6 +379,16 @@ vl_msg_api_trace_configure (api_main_t * am, vl_api_trace_which_t which,
return 0;
}
+void
+vl_msg_api_barrier_sync (void)
+{
+}
+
+void
+vl_msg_api_barrier_release (void)
+{
+}
+
always_inline void
msg_handler_internal (api_main_t * am,
void *the_msg, int trace_it, int do_it, int free_it)
@@ -748,495 +740,15 @@ vl_noop_handler (void *mp)
{
}
-clib_error_t *
-vl_api_init (vlib_main_t * vm)
-{
- static u8 once;
- api_main_t *am = &api_main;
-
- if (once)
- return 0;
-
- once = 1;
-
- am->region_name = "/unset";
- /*
- * Eventually passed to fchown, -1 => "current user"
- * instead of 0 => "root". A very fine disctinction at best.
- */
- if (am->api_uid == 0)
- am->api_uid = -1;
- if (am->api_gid == 0)
- am->api_gid = -1;
-
- return (0);
-}
-
-void vl_msg_api_custom_dump_configure (api_main_t * am)
- __attribute__ ((weak));
-void
-vl_msg_api_custom_dump_configure (api_main_t * am)
-{
-}
-
-VLIB_INIT_FUNCTION (vl_api_init);
-
-static void
-vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
- u32 first_index, u32 last_index,
- vl_api_replay_t which)
-{
- vl_api_trace_file_header_t *hp;
- int i, fd;
- struct stat statb;
- size_t file_size;
- u8 *msg;
- u8 endian_swap_needed = 0;
- api_main_t *am = &api_main;
- u8 *tmpbuf = 0;
- u32 nitems;
- void **saved_print_handlers = 0;
-
- fd = open ((char *) filename, O_RDONLY);
-
- if (fd < 0)
- {
- vlib_cli_output (vm, "Couldn't open %s\n", filename);
- return;
- }
-
- if (fstat (fd, &statb) < 0)
- {
- vlib_cli_output (vm, "Couldn't stat %s\n", filename);
- close (fd);
- return;
- }
-
- if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
- {
- vlib_cli_output (vm, "File not plausible: %s\n", filename);
- close (fd);
- return;
- }
-
- file_size = statb.st_size;
- file_size = (file_size + 4095) & ~(4096);
-
- hp = mmap (0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
-
- if (hp == (vl_api_trace_file_header_t *) MAP_FAILED)
- {
- vlib_cli_output (vm, "mmap failed: %s\n", filename);
- close (fd);
- return;
- }
- close (fd);
-
- if ((clib_arch_is_little_endian && hp->endian == VL_API_BIG_ENDIAN)
- || (clib_arch_is_big_endian && hp->endian == VL_API_LITTLE_ENDIAN))
- endian_swap_needed = 1;
-
- if (endian_swap_needed)
- nitems = ntohl (hp->nitems);
- else
- nitems = hp->nitems;
-
- if (last_index == (u32) ~ 0)
- {
- last_index = nitems - 1;
- }
-
- if (first_index >= nitems || last_index >= nitems)
- {
- vlib_cli_output (vm, "Range (%d, %d) outside file range (0, %d)\n",
- first_index, last_index, nitems - 1);
- munmap (hp, file_size);
- return;
- }
- if (hp->wrapped)
- vlib_cli_output (vm,
- "Note: wrapped/incomplete trace, results may vary\n");
-
- if (which == CUSTOM_DUMP)
- {
- saved_print_handlers = (void **) vec_dup (am->msg_print_handlers);
- vl_msg_api_custom_dump_configure (am);
- }
-
-
- msg = (u8 *) (hp + 1);
-
- for (i = 0; i < first_index; i++)
- {
- trace_cfg_t *cfgp;
- int size;
- u16 msg_id;
-
- size = clib_host_to_net_u32 (*(u32 *) msg);
- msg += sizeof (u32);
-
- if (clib_arch_is_little_endian)
- msg_id = ntohs (*((u16 *) msg));
- else
- msg_id = *((u16 *) msg);
-
- cfgp = am->api_trace_cfg + msg_id;
- if (!cfgp)
- {
- vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
- munmap (hp, file_size);
- return;
- }
- msg += size;
- }
-
- if (which == REPLAY)
- am->replay_in_progress = 1;
-
- for (; i <= last_index; i++)
- {
- trace_cfg_t *cfgp;
- u16 *msg_idp;
- u16 msg_id;
- int size;
-
- if (which == DUMP)
- vlib_cli_output (vm, "---------- trace %d -----------\n", i);
-
- size = clib_host_to_net_u32 (*(u32 *) msg);
- msg += sizeof (u32);
-
- if (clib_arch_is_little_endian)
- msg_id = ntohs (*((u16 *) msg));
- else
- msg_id = *((u16 *) msg);
-
- cfgp = am->api_trace_cfg + msg_id;
- if (!cfgp)
- {
- vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
- munmap (hp, file_size);
- vec_free (tmpbuf);
- am->replay_in_progress = 0;
- return;
- }
-
- /* Copy the buffer (from the read-only mmap'ed file) */
- vec_validate (tmpbuf, size - 1 + sizeof (uword));
- clib_memcpy (tmpbuf + sizeof (uword), msg, size);
- memset (tmpbuf, 0xf, sizeof (uword));
-
- /*
- * Endian swap if needed. All msg data is supposed to be
- * in network byte order. All msg handlers are supposed to
- * know that. The generic message dumpers don't know that.
- * One could fix apigen, I suppose.
- */
- if ((which == DUMP && clib_arch_is_little_endian) || endian_swap_needed)
- {
- void (*endian_fp) (void *);
- if (msg_id >= vec_len (am->msg_endian_handlers)
- || (am->msg_endian_handlers[msg_id] == 0))
- {
- vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id);
- munmap (hp, file_size);
- vec_free (tmpbuf);
- am->replay_in_progress = 0;
- return;
- }
- endian_fp = am->msg_endian_handlers[msg_id];
- (*endian_fp) (tmpbuf + sizeof (uword));
- }
-
- /* msg_id always in network byte order */
- if (clib_arch_is_little_endian)
- {
- msg_idp = (u16 *) (tmpbuf + sizeof (uword));
- *msg_idp = msg_id;
- }
-
- switch (which)
- {
- case CUSTOM_DUMP:
- case DUMP:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id])
- {
- u8 *(*print_fp) (void *, void *);
-
- print_fp = (void *) am->msg_print_handlers[msg_id];
- (*print_fp) (tmpbuf + sizeof (uword), vm);
- }
- else
- {
- vlib_cli_output (vm, "Skipping msg id %d: no print fcn\n",
- msg_id);
- break;
- }
- break;
-
- case INITIALIZERS:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id])
- {
- 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);
- 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);
-
- for (j = 0; j < am->api_trace_cfg[msg_id].size; j++)
- {
- if ((j & 7) == 0)
- s = format (s, "\n ");
- s = format (s, "0x%02x,", tmpbuf[sizeof (uword) + j]);
- }
- s = format (s, "\n};\n%c", 0);
- vlib_cli_output (vm, (char *) s);
- vec_free (s);
- }
- break;
-
- case REPLAY:
- if (msg_id < vec_len (am->msg_print_handlers) &&
- am->msg_print_handlers[msg_id] && cfgp->replay_enable)
- {
- void (*handler) (void *);
-
- handler = (void *) am->msg_handlers[msg_id];
-
- if (!am->is_mp_safe[msg_id])
- vl_msg_api_barrier_sync ();
- (*handler) (tmpbuf + sizeof (uword));
- if (!am->is_mp_safe[msg_id])
- vl_msg_api_barrier_release ();
- }
- else
- {
- if (cfgp->replay_enable)
- vlib_cli_output (vm, "Skipping msg id %d: no handler\n",
- msg_id);
- break;
- }
- break;
- }
-
- _vec_len (tmpbuf) = 0;
- msg += size;
- }
-
- if (saved_print_handlers)
- {
- clib_memcpy (am->msg_print_handlers, saved_print_handlers,
- vec_len (am->msg_print_handlers) * sizeof (void *));
- vec_free (saved_print_handlers);
- }
-
- munmap (hp, file_size);
- vec_free (tmpbuf);
- am->replay_in_progress = 0;
-}
-
-u8 *
-format_vl_msg_api_trace_status (u8 * s, va_list * args)
-{
- api_main_t *am = va_arg (*args, api_main_t *);
- vl_api_trace_which_t which = va_arg (*args, vl_api_trace_which_t);
- vl_api_trace_t *tp;
- char *trace_name;
-
- switch (which)
- {
- case VL_API_TRACE_TX:
- tp = am->tx_trace;
- trace_name = "TX trace";
- break;
-
- case VL_API_TRACE_RX:
- tp = am->rx_trace;
- trace_name = "RX trace";
- break;
-
- default:
- abort ();
- }
-
- if (tp == 0)
- {
- s = format (s, "%s: not yet configured.\n", trace_name);
- return s;
- }
-
- s = format (s, "%s: used %d of %d items, %s enabled, %s wrapped\n",
- trace_name, vec_len (tp->traces), tp->nitems,
- tp->enabled ? "is" : "is not", tp->wrapped ? "has" : "has not");
- return s;
-}
static u8 post_mortem_dump_enabled;
-static clib_error_t *
-api_trace_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
-{
- u32 nitems = 256 << 10;
- api_main_t *am = &api_main;
- vl_api_trace_which_t which = VL_API_TRACE_RX;
- u8 *filename;
- u32 first = 0;
- u32 last = (u32) ~ 0;
- FILE *fp;
- int rv;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "on") || unformat (input, "enable"))
- {
- if (unformat (input, "nitems %d", &nitems))
- ;
- vl_msg_api_trace_configure (am, which, nitems);
- vl_msg_api_trace_onoff (am, which, 1 /* on */ );
- }
- else if (unformat (input, "off"))
- {
- vl_msg_api_trace_onoff (am, which, 0);
- }
- else if (unformat (input, "save %s", &filename))
- {
- u8 *chroot_filename;
- if (strstr ((char *) filename, "..")
- || index ((char *) filename, '/'))
- {
- vlib_cli_output (vm, "illegal characters in filename '%s'",
- filename);
- return 0;
- }
-
- chroot_filename = format (0, "/tmp/%s%c", filename, 0);
-
- vec_free (filename);
-
- fp = fopen ((char *) chroot_filename, "w");
- if (fp == NULL)
- {
- vlib_cli_output (vm, "Couldn't create %s\n", chroot_filename);
- return 0;
- }
- rv = vl_msg_api_trace_save (am, which, fp);
- fclose (fp);
- if (rv == -1)
- vlib_cli_output (vm, "API Trace data not present\n");
- else if (rv == -2)
- vlib_cli_output (vm, "File for writing is closed\n");
- else if (rv == -10)
- vlib_cli_output (vm, "Error while writing header to file\n");
- else if (rv == -11)
- vlib_cli_output (vm, "Error while writing trace to file\n");
- else if (rv == -12)
- vlib_cli_output (vm,
- "Error while writing end of buffer trace to file\n");
- else if (rv == -13)
- vlib_cli_output (vm,
- "Error while writing start of buffer trace to file\n");
- else if (rv < 0)
- vlib_cli_output (vm, "Unkown error while saving: %d", rv);
- else
- vlib_cli_output (vm, "API trace saved to %s\n", chroot_filename);
- vec_free (chroot_filename);
- }
- else if (unformat (input, "dump %s", &filename))
- {
- vl_msg_api_process_file (vm, filename, first, last, DUMP);
- }
- else if (unformat (input, "custom-dump %s", &filename))
- {
- vl_msg_api_process_file (vm, filename, first, last, CUSTOM_DUMP);
- }
- else if (unformat (input, "replay %s", &filename))
- {
- vl_msg_api_process_file (vm, filename, first, last, REPLAY);
- }
- else if (unformat (input, "initializers %s", &filename))
- {
- vl_msg_api_process_file (vm, filename, first, last, INITIALIZERS);
- }
- else if (unformat (input, "tx"))
- {
- which = VL_API_TRACE_TX;
- }
- else if (unformat (input, "first %d", &first))
- {
- ;
- }
- else if (unformat (input, "last %d", &last))
- {
- ;
- }
- else if (unformat (input, "status"))
- {
- vlib_cli_output (vm, "%U", format_vl_msg_api_trace_status,
- am, which);
- }
- else if (unformat (input, "free"))
- {
- vl_msg_api_trace_onoff (am, which, 0);
- vl_msg_api_trace_free (am, which);
- }
- else if (unformat (input, "post-mortem-on"))
- post_mortem_dump_enabled = 1;
- else if (unformat (input, "post-mortem-off"))
- post_mortem_dump_enabled = 0;
- else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
- }
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (api_trace_command, static) = {
- .path = "api trace",
- .short_help =
- "api trace [on|off][dump|save|replay <file>][status][free][post-mortem-on]",
- .function = api_trace_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-api_config_fn (vlib_main_t * vm, unformat_input_t * input)
+void
+vl_msg_api_post_mortem_dump_enable_disable (int enable)
{
- u32 nitems = 256 << 10;
- vl_api_trace_which_t which = VL_API_TRACE_RX;
- api_main_t *am = &api_main;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "on") || unformat (input, "enable"))
- {
- if (unformat (input, "nitems %d", &nitems))
- ;
- vl_msg_api_trace_configure (am, which, nitems);
- vl_msg_api_trace_onoff (am, which, 1 /* on */ );
- post_mortem_dump_enabled = 1;
- }
- else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
- }
- return 0;
+ post_mortem_dump_enabled = enable;
}
-VLIB_CONFIG_FUNCTION (api_config_fn, "api-trace");
-
void
vl_msg_api_post_mortem_dump (void)
{
diff --git a/src/vlibapi/node_serialize.c b/src/vlibapi/node_serialize.c
index 4dc1a7d2272..50e5c41c219 100644
--- a/src/vlibapi/node_serialize.c
+++ b/src/vlibapi/node_serialize.c
@@ -73,16 +73,11 @@ vlib_node_serialize (vlib_node_main_t * nm, u8 * vector,
if (vec_len (stat_vms) == 0)
{
- if (vec_len (vlib_mains) == 0)
- vec_add1 (stat_vms, vm);
- else
+ for (i = 0; i < vec_len (vlib_mains); i++)
{
- for (i = 0; i < vec_len (vlib_mains); i++)
- {
- stat_vm = vlib_mains[i];
- if (stat_vm)
- vec_add1 (stat_vms, stat_vm);
- }
+ stat_vm = vlib_mains[i];
+ if (stat_vm)
+ vec_add1 (stat_vms, stat_vm);
}
}
@@ -286,7 +281,7 @@ vlib_node_unserialize (u8 * vector)
return nodes_by_thread;
}
-#if CLIB_DEBUG > 0
+#if TEST_CODE
static clib_error_t *
test_node_serialize_command_fn (vlib_main_t * vm,
diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c
index 3a7415c0867..d2e0596824d 100644
--- a/src/vlibmemory/memory_vlib.c
+++ b/src/vlibmemory/memory_vlib.c
@@ -22,6 +22,8 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <signal.h>
#include <pthread.h>
#include <vppinfra/vec.h>
@@ -1437,6 +1439,475 @@ rpc_api_hookup (vlib_main_t * vm)
VLIB_API_INIT_FUNCTION (rpc_api_hookup);
+typedef enum
+{
+ DUMP,
+ CUSTOM_DUMP,
+ REPLAY,
+ INITIALIZERS,
+} vl_api_replay_t;
+
+u8 *
+format_vl_msg_api_trace_status (u8 * s, va_list * args)
+{
+ api_main_t *am = va_arg (*args, api_main_t *);
+ vl_api_trace_which_t which = va_arg (*args, vl_api_trace_which_t);
+ vl_api_trace_t *tp;
+ char *trace_name;
+
+ switch (which)
+ {
+ case VL_API_TRACE_TX:
+ tp = am->tx_trace;
+ trace_name = "TX trace";
+ break;
+
+ case VL_API_TRACE_RX:
+ tp = am->rx_trace;
+ trace_name = "RX trace";
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (tp == 0)
+ {
+ s = format (s, "%s: not yet configured.\n", trace_name);
+ return s;
+ }
+
+ s = format (s, "%s: used %d of %d items, %s enabled, %s wrapped\n",
+ trace_name, vec_len (tp->traces), tp->nitems,
+ tp->enabled ? "is" : "is not", tp->wrapped ? "has" : "has not");
+ return s;
+}
+
+void vl_msg_api_custom_dump_configure (api_main_t * am)
+ __attribute__ ((weak));
+void
+vl_msg_api_custom_dump_configure (api_main_t * am)
+{
+}
+
+static void
+vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
+ u32 first_index, u32 last_index,
+ vl_api_replay_t which)
+{
+ vl_api_trace_file_header_t *hp;
+ int i, fd;
+ struct stat statb;
+ size_t file_size;
+ u8 *msg;
+ u8 endian_swap_needed = 0;
+ api_main_t *am = &api_main;
+ u8 *tmpbuf = 0;
+ u32 nitems;
+ void **saved_print_handlers = 0;
+
+ fd = open ((char *) filename, O_RDONLY);
+
+ if (fd < 0)
+ {
+ vlib_cli_output (vm, "Couldn't open %s\n", filename);
+ return;
+ }
+
+ if (fstat (fd, &statb) < 0)
+ {
+ vlib_cli_output (vm, "Couldn't stat %s\n", filename);
+ close (fd);
+ return;
+ }
+
+ if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
+ {
+ vlib_cli_output (vm, "File not plausible: %s\n", filename);
+ close (fd);
+ return;
+ }
+
+ file_size = statb.st_size;
+ file_size = (file_size + 4095) & ~(4096);
+
+ hp = mmap (0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
+
+ if (hp == (vl_api_trace_file_header_t *) MAP_FAILED)
+ {
+ vlib_cli_output (vm, "mmap failed: %s\n", filename);
+ close (fd);
+ return;
+ }
+ close (fd);
+
+ if ((clib_arch_is_little_endian && hp->endian == VL_API_BIG_ENDIAN)
+ || (clib_arch_is_big_endian && hp->endian == VL_API_LITTLE_ENDIAN))
+ endian_swap_needed = 1;
+
+ if (endian_swap_needed)
+ nitems = ntohl (hp->nitems);
+ else
+ nitems = hp->nitems;
+
+ if (last_index == (u32) ~ 0)
+ {
+ last_index = nitems - 1;
+ }
+
+ if (first_index >= nitems || last_index >= nitems)
+ {
+ vlib_cli_output (vm, "Range (%d, %d) outside file range (0, %d)\n",
+ first_index, last_index, nitems - 1);
+ munmap (hp, file_size);
+ return;
+ }
+ if (hp->wrapped)
+ vlib_cli_output (vm,
+ "Note: wrapped/incomplete trace, results may vary\n");
+
+ if (which == CUSTOM_DUMP)
+ {
+ saved_print_handlers = (void **) vec_dup (am->msg_print_handlers);
+ vl_msg_api_custom_dump_configure (am);
+ }
+
+
+ msg = (u8 *) (hp + 1);
+
+ for (i = 0; i < first_index; i++)
+ {
+ trace_cfg_t *cfgp;
+ int size;
+ u16 msg_id;
+
+ size = clib_host_to_net_u32 (*(u32 *) msg);
+ msg += sizeof (u32);
+
+ if (clib_arch_is_little_endian)
+ msg_id = ntohs (*((u16 *) msg));
+ else
+ msg_id = *((u16 *) msg);
+
+ cfgp = am->api_trace_cfg + msg_id;
+ if (!cfgp)
+ {
+ vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
+ munmap (hp, file_size);
+ return;
+ }
+ msg += size;
+ }
+
+ if (which == REPLAY)
+ am->replay_in_progress = 1;
+
+ for (; i <= last_index; i++)
+ {
+ trace_cfg_t *cfgp;
+ u16 *msg_idp;
+ u16 msg_id;
+ int size;
+
+ if (which == DUMP)
+ vlib_cli_output (vm, "---------- trace %d -----------\n", i);
+
+ size = clib_host_to_net_u32 (*(u32 *) msg);
+ msg += sizeof (u32);
+
+ if (clib_arch_is_little_endian)
+ msg_id = ntohs (*((u16 *) msg));
+ else
+ msg_id = *((u16 *) msg);
+
+ cfgp = am->api_trace_cfg + msg_id;
+ if (!cfgp)
+ {
+ vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
+ munmap (hp, file_size);
+ vec_free (tmpbuf);
+ am->replay_in_progress = 0;
+ return;
+ }
+
+ /* Copy the buffer (from the read-only mmap'ed file) */
+ vec_validate (tmpbuf, size - 1 + sizeof (uword));
+ clib_memcpy (tmpbuf + sizeof (uword), msg, size);
+ memset (tmpbuf, 0xf, sizeof (uword));
+
+ /*
+ * Endian swap if needed. All msg data is supposed to be
+ * in network byte order. All msg handlers are supposed to
+ * know that. The generic message dumpers don't know that.
+ * One could fix apigen, I suppose.
+ */
+ if ((which == DUMP && clib_arch_is_little_endian) || endian_swap_needed)
+ {
+ void (*endian_fp) (void *);
+ if (msg_id >= vec_len (am->msg_endian_handlers)
+ || (am->msg_endian_handlers[msg_id] == 0))
+ {
+ vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id);
+ munmap (hp, file_size);
+ vec_free (tmpbuf);
+ am->replay_in_progress = 0;
+ return;
+ }
+ endian_fp = am->msg_endian_handlers[msg_id];
+ (*endian_fp) (tmpbuf + sizeof (uword));
+ }
+
+ /* msg_id always in network byte order */
+ if (clib_arch_is_little_endian)
+ {
+ msg_idp = (u16 *) (tmpbuf + sizeof (uword));
+ *msg_idp = msg_id;
+ }
+
+ switch (which)
+ {
+ case CUSTOM_DUMP:
+ case DUMP:
+ if (msg_id < vec_len (am->msg_print_handlers) &&
+ am->msg_print_handlers[msg_id])
+ {
+ u8 *(*print_fp) (void *, void *);
+
+ print_fp = (void *) am->msg_print_handlers[msg_id];
+ (*print_fp) (tmpbuf + sizeof (uword), vm);
+ }
+ else
+ {
+ vlib_cli_output (vm, "Skipping msg id %d: no print fcn\n",
+ msg_id);
+ break;
+ }
+ break;
+
+ case INITIALIZERS:
+ if (msg_id < vec_len (am->msg_print_handlers) &&
+ am->msg_print_handlers[msg_id])
+ {
+ 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);
+ 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);
+
+ for (j = 0; j < am->api_trace_cfg[msg_id].size; j++)
+ {
+ if ((j & 7) == 0)
+ s = format (s, "\n ");
+ s = format (s, "0x%02x,", tmpbuf[sizeof (uword) + j]);
+ }
+ s = format (s, "\n};\n%c", 0);
+ vlib_cli_output (vm, (char *) s);
+ vec_free (s);
+ }
+ break;
+
+ case REPLAY:
+ if (msg_id < vec_len (am->msg_print_handlers) &&
+ am->msg_print_handlers[msg_id] && cfgp->replay_enable)
+ {
+ void (*handler) (void *);
+
+ handler = (void *) am->msg_handlers[msg_id];
+
+ if (!am->is_mp_safe[msg_id])
+ vl_msg_api_barrier_sync ();
+ (*handler) (tmpbuf + sizeof (uword));
+ if (!am->is_mp_safe[msg_id])
+ vl_msg_api_barrier_release ();
+ }
+ else
+ {
+ if (cfgp->replay_enable)
+ vlib_cli_output (vm, "Skipping msg id %d: no handler\n",
+ msg_id);
+ break;
+ }
+ break;
+ }
+
+ _vec_len (tmpbuf) = 0;
+ msg += size;
+ }
+
+ if (saved_print_handlers)
+ {
+ clib_memcpy (am->msg_print_handlers, saved_print_handlers,
+ vec_len (am->msg_print_handlers) * sizeof (void *));
+ vec_free (saved_print_handlers);
+ }
+
+ munmap (hp, file_size);
+ vec_free (tmpbuf);
+ am->replay_in_progress = 0;
+}
+
+static clib_error_t *
+api_trace_command_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ u32 nitems = 256 << 10;
+ api_main_t *am = &api_main;
+ vl_api_trace_which_t which = VL_API_TRACE_RX;
+ u8 *filename;
+ u32 first = 0;
+ u32 last = (u32) ~ 0;
+ FILE *fp;
+ int rv;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "on") || unformat (input, "enable"))
+ {
+ if (unformat (input, "nitems %d", &nitems))
+ ;
+ vl_msg_api_trace_configure (am, which, nitems);
+ vl_msg_api_trace_onoff (am, which, 1 /* on */ );
+ }
+ else if (unformat (input, "off"))
+ {
+ vl_msg_api_trace_onoff (am, which, 0);
+ }
+ else if (unformat (input, "save %s", &filename))
+ {
+ u8 *chroot_filename;
+ if (strstr ((char *) filename, "..")
+ || index ((char *) filename, '/'))
+ {
+ vlib_cli_output (vm, "illegal characters in filename '%s'",
+ filename);
+ return 0;
+ }
+
+ chroot_filename = format (0, "/tmp/%s%c", filename, 0);
+
+ vec_free (filename);
+
+ fp = fopen ((char *) chroot_filename, "w");
+ if (fp == NULL)
+ {
+ vlib_cli_output (vm, "Couldn't create %s\n", chroot_filename);
+ return 0;
+ }
+ rv = vl_msg_api_trace_save (am, which, fp);
+ fclose (fp);
+ if (rv == -1)
+ vlib_cli_output (vm, "API Trace data not present\n");
+ else if (rv == -2)
+ vlib_cli_output (vm, "File for writing is closed\n");
+ else if (rv == -10)
+ vlib_cli_output (vm, "Error while writing header to file\n");
+ else if (rv == -11)
+ vlib_cli_output (vm, "Error while writing trace to file\n");
+ else if (rv == -12)
+ vlib_cli_output (vm,
+ "Error while writing end of buffer trace to file\n");
+ else if (rv == -13)
+ vlib_cli_output (vm,
+ "Error while writing start of buffer trace to file\n");
+ else if (rv < 0)
+ vlib_cli_output (vm, "Unkown error while saving: %d", rv);
+ else
+ vlib_cli_output (vm, "API trace saved to %s\n", chroot_filename);
+ vec_free (chroot_filename);
+ }
+ else if (unformat (input, "dump %s", &filename))
+ {
+ vl_msg_api_process_file (vm, filename, first, last, DUMP);
+ }
+ else if (unformat (input, "custom-dump %s", &filename))
+ {
+ vl_msg_api_process_file (vm, filename, first, last, CUSTOM_DUMP);
+ }
+ else if (unformat (input, "replay %s", &filename))
+ {
+ vl_msg_api_process_file (vm, filename, first, last, REPLAY);
+ }
+ else if (unformat (input, "initializers %s", &filename))
+ {
+ vl_msg_api_process_file (vm, filename, first, last, INITIALIZERS);
+ }
+ else if (unformat (input, "tx"))
+ {
+ which = VL_API_TRACE_TX;
+ }
+ else if (unformat (input, "first %d", &first))
+ {
+ ;
+ }
+ else if (unformat (input, "last %d", &last))
+ {
+ ;
+ }
+ else if (unformat (input, "status"))
+ {
+ vlib_cli_output (vm, "%U", format_vl_msg_api_trace_status,
+ am, which);
+ }
+ else if (unformat (input, "free"))
+ {
+ vl_msg_api_trace_onoff (am, which, 0);
+ vl_msg_api_trace_free (am, which);
+ }
+ else if (unformat (input, "post-mortem-on"))
+ vl_msg_api_post_mortem_dump_enable_disable (1 /* enable */ );
+ else if (unformat (input, "post-mortem-off"))
+ vl_msg_api_post_mortem_dump_enable_disable (0 /* enable */ );
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (api_trace_command, static) = {
+ .path = "api trace",
+ .short_help =
+ "api trace [on|off][dump|save|replay <file>][status][free][post-mortem-on]",
+ .function = api_trace_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+api_config_fn (vlib_main_t * vm, unformat_input_t * input)
+{
+ u32 nitems = 256 << 10;
+ vl_api_trace_which_t which = VL_API_TRACE_RX;
+ api_main_t *am = &api_main;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "on") || unformat (input, "enable"))
+ {
+ if (unformat (input, "nitems %d", &nitems))
+ ;
+ vl_msg_api_trace_configure (am, which, nitems);
+ vl_msg_api_trace_onoff (am, which, 1 /* on */ );
+ vl_msg_api_post_mortem_dump_enable_disable (1 /* enable */ );
+ }
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ return 0;
+}
+
+VLIB_CONFIG_FUNCTION (api_config_fn, "api-trace");
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index b6b4c04a067..100ec613bc2 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -374,8 +374,7 @@ vhost_user_rx_thread_placement ()
for (i = vum->input_cpu_first_index;
i < vum->input_cpu_first_index + vum->input_cpu_count; i++)
{
- vlib_node_set_state (vlib_mains ? vlib_mains[i] : &vlib_global_main,
- vhost_user_input_node.index,
+ vlib_node_set_state (vlib_mains[i], vhost_user_input_node.index,
VLIB_NODE_STATE_DISABLED);
vec_add1 (workers, i);
}
@@ -406,9 +405,9 @@ vhost_user_rx_thread_placement ()
iaq.qid = qid;
iaq.vhost_iface_index = vui - vum->vhost_user_interfaces;
vec_add1 (vhc->rx_queues, iaq);
- vlib_node_set_state (vlib_mains ? vlib_mains[cpu_index] :
- &vlib_global_main, vhost_user_input_node.index,
- VLIB_NODE_STATE_POLLING);
+ vlib_node_set_state (vlib_mains[cpu_index],
+ vhost_user_input_node.index,
+ VLIB_NODE_STATE_POLLING);
}
});
/* *INDENT-ON* */
diff --git a/src/vpp-api-test.am b/src/vpp-api-test.am
index f0d5df62791..ceab687ceb1 100644
--- a/src/vpp-api-test.am
+++ b/src/vpp-api-test.am
@@ -34,14 +34,12 @@ vpp_json_test_SOURCES = \
vat/json_test.c
vpp_api_test_LDADD = \
- libvlib.la \
libvlibmemoryclient.la \
libsvm.la \
libvatplugin.la \
libvppinfra.la \
libvlibapi.la \
libvlibmemory.la \
- libvnet.la \
-lpthread -lm -lrt -ldl -lcrypto
vpp_api_test_LDFLAGS = -Wl,--export-dynamic
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 828394edc59..c85dc680b28 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -2143,7 +2143,6 @@ vpe_api_init (vlib_main_t * vm)
am->oam_events_registration_hash = hash_create (0, sizeof (uword));
am->bfd_events_registration_hash = hash_create (0, sizeof (uword));
- vl_api_init (vm);
vl_set_memory_region_name ("/vpe-api");
vl_enable_disable_memory_api (vm, 1 /* enable it */ );
diff --git a/src/vpp/api/gmon.c b/src/vpp/api/gmon.c
index 610f40eddbf..277be8c0af8 100644
--- a/src/vpp/api/gmon.c
+++ b/src/vpp/api/gmon.c
@@ -122,13 +122,8 @@ gmon_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
/* Initial wait for the world to settle down */
vlib_process_suspend (vm, 5.0);
- if (vec_len (vlib_mains) == 0)
- vec_add1 (gm->my_vlib_mains, &vlib_global_main);
- else
- {
- for (i = 0; i < vec_len (vlib_mains); i++)
- vec_add1 (gm->my_vlib_mains, vlib_mains[i]);
- }
+ for (i = 0; i < vec_len (vlib_mains); i++)
+ vec_add1 (gm->my_vlib_mains, vlib_mains[i]);
while (1)
{