api: vat2 and json autogeneration for api messages
[vpp.git] / src / vcl / vcl_bapi.c
index 8131177..e245c4d 100644 (file)
@@ -79,8 +79,6 @@ vl_api_app_attach_reply_t_handler (vl_api_app_attach_reply_t * mp)
 
   wrk->app_event_queue = uword_to_pointer (mp->app_mq, svm_msg_q_t *);
   ctrl_mq = uword_to_pointer (mp->vpp_ctrl_mq, svm_msg_q_t *);
-  vec_validate (wrk->vpp_event_queues, mp->vpp_ctrl_mq_thread);
-  wrk->vpp_event_queues[mp->vpp_ctrl_mq_thread] = ctrl_mq;
   vcm->ctrl_mq = wrk->ctrl_mq = ctrl_mq;
   segment_handle = clib_net_to_host_u64 (mp->segment_handle);
   if (segment_handle == VCL_INVALID_SEGMENT_HANDLE)
@@ -466,54 +464,37 @@ vcl_bapi_connect_to_vpp (void)
   api_main_t *am;
   u8 *wrk_name;
 
-  wrk_name = format (0, "%s-wrk-%u%c", vcm->app_name, wrk->wrk_index, 0);
+  wrk_name = format (0, "%v-wrk-%u%c", vcm->app_name, wrk->wrk_index, 0);
 
   /* Make sure api is cleaned up in case this is a connect from a
    * forked worker */
   vcl_bapi_cleanup ();
 
   vlibapi_set_main (&wrk->bapi_api_ctx);
-  vlibapi_set_memory_client_main (&wrk->bapi_shm_ctx);
   vcl_bapi_hookup ();
 
-  if (vcl_cfg->vpp_bapi_socket_name)
+  if (!vcl_cfg->vpp_bapi_socket_name)
     {
-      if (vl_socket_client_connect2 (&wrk->bapi_sock_ctx,
-                                    (char *) vcl_cfg->vpp_bapi_socket_name,
-                                    (char *) wrk_name,
-                                    0 /* default rx/tx buffer */ ))
-       {
-         VERR ("app (%s) socket connect failed!", wrk_name);
-         rv = VPPCOM_ECONNREFUSED;
-         goto error;
-       }
-
-      if (vl_socket_client_init_shm2 (&wrk->bapi_sock_ctx, 0,
-                                     1 /* want_pthread */ ))
-       {
-         VERR ("app (%s) init shm failed!", wrk_name);
-         rv = VPPCOM_ECONNREFUSED;
-         goto error;
-       }
+      rv = VPPCOM_EINVAL;
+      goto error;
     }
-  else
-    {
-      if (!vcl_cfg->vpp_bapi_filename)
-       vcl_cfg->vpp_bapi_filename = format (0, "/vpe-api%c", 0);
-
-      vl_set_memory_root_path ((char *) vcl_cfg->vpp_bapi_chroot);
 
-      VDBG (0, "app (%s) connecting to VPP api (%s)...",
-           wrk_name, vcl_cfg->vpp_bapi_filename);
+  if (vl_socket_client_connect2 (&wrk->bapi_sock_ctx,
+                                (char *) vcl_cfg->vpp_bapi_socket_name,
+                                (char *) wrk_name,
+                                0 /* default rx/tx buffer */ ))
+    {
+      VERR ("app (%s) socket connect failed!", wrk_name);
+      rv = VPPCOM_ECONNREFUSED;
+      goto error;
+    }
 
-      if (vl_client_connect_to_vlib ((char *) vcl_cfg->vpp_bapi_filename,
-                                    (char *) wrk_name,
-                                    vcm->cfg.vpp_api_q_length) < 0)
-       {
-         VERR ("app (%s) connect failed!", wrk_name);
-         rv = VPPCOM_ECONNREFUSED;
-         goto error;
-       }
+  if (vl_socket_client_init_shm2 (&wrk->bapi_sock_ctx, 0,
+                                 1 /* want_pthread */ ))
+    {
+      VERR ("app (%s) init shm failed!", wrk_name);
+      rv = VPPCOM_ECONNREFUSED;
+      goto error;
     }
 
   am = vlibapi_get_main ();