vlib_mains == 0 special cases be gone 81/5681/4
authorDave Barach <dave@barachs.net>
Thu, 9 Mar 2017 00:08:56 +0000 (19:08 -0500)
committerOle Trøan <otroan@employees.org>
Thu, 9 Mar 2017 19:07:17 +0000 (19:07 +0000)
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>
16 files changed:
src/plugins/dpdk/ipsec/ipsec.c
src/vlib-api.am
src/vlib/buffer.c
src/vlib/global_funcs.h
src/vlib/node_cli.c
src/vlib/node_funcs.h
src/vlib/threads.c
src/vlib/threads.h
src/vlibapi/api.h
src/vlibapi/api_shared.c
src/vlibapi/node_serialize.c
src/vlibmemory/memory_vlib.c
src/vnet/devices/virtio/vhost-user.c
src/vpp-api-test.am
src/vpp/api/api.c
src/vpp/api/gmon.c

index 16bec20..b0aaaae 100644 (file)
@@ -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 */
 
index c05929b..4e1dae9 100644 (file)
@@ -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                           \
index 9f26bec..6ba8258 100644 (file)
@@ -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* */
index bbdbdef..f51ec38 100644 (file)
@@ -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;
 }
index 05d0f0b..62ab2e6 100644 (file)
@@ -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);
index f49a8d6..8ccfc43 100644 (file)
@@ -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;
index e3ea3c9..4676be9 100644 (file)
@@ -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)
index 75a5a28..a032311 100644 (file)
@@ -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 \
index 2cbeb63..87a5612 100644 (file)
@@ -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);
index 69ba10c..6774e3d 100644 (file)
 #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>
 #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)
 {
index 4dc1a7d..50e5c41 100644 (file)
@@ -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,
index 3a7415c..d2e0596 100644 (file)
@@ -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
  *
index b6b4c04..100ec61 100644 (file)
@@ -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* */
index f0d5df6..ceab687 100644 (file)
@@ -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
index 828394e..c85dc68 100644 (file)
@@ -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 */ );
 
index 610f40e..277be8c 100644 (file)
@@ -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)
     {