Add transport_opts to connect_sock bapi
[vpp.git] / src / vnet / session / application.c
index 37eb1cb..3095787 100644 (file)
@@ -282,10 +282,9 @@ app_listener_cleanup (app_listener_t * al)
   app_listener_free (app, al);
 }
 
-app_worker_t *
-app_listener_select_worker (app_listener_t * al)
+static app_worker_t *
+app_listener_select_worker (application_t * app, app_listener_t * al)
 {
-  application_t *app;
   u32 wrk_index;
 
   app = application_get (al->app_index);
@@ -505,7 +504,7 @@ static int
 application_alloc_and_init (app_init_args_t * a)
 {
   ssvm_segment_type_t seg_type = SSVM_SEGMENT_MEMFD;
-  segment_manager_properties_t *props;
+  segment_manager_props_t *props;
   vl_api_registration_t *reg;
   application_t *app;
   u64 *options;
@@ -554,8 +553,8 @@ application_alloc_and_init (app_init_args_t * a)
     app->flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
 
   props = application_segment_manager_properties (app);
-  segment_manager_properties_init (props);
-  props->segment_size = options[APP_OPTIONS_ADD_SEGMENT_SIZE];
+  segment_manager_props_init (props);
+  props->segment_size = options[APP_OPTIONS_SEGMENT_SIZE];
   props->prealloc_fifos = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
   if (options[APP_OPTIONS_ADD_SEGMENT_SIZE])
     {
@@ -583,7 +582,7 @@ application_alloc_and_init (app_init_args_t * a)
   a->app_index = app->app_index;
 
   APP_DBG ("New app name: %v api index: %u index %u", app->name,
-          app->api_client_index, app->app_index);
+          a->api_client_index, app->app_index);
 
   return 0;
 }
@@ -598,8 +597,7 @@ application_free (application_t * app)
    * The app event queue allocated in first segment is cleared with
    * the segment manager. No need to explicitly free it.
    */
-  APP_DBG ("Delete app name %v api index: %d index: %d", app->name,
-          app->api_client_index, app->app_index);
+  APP_DBG ("Delete app name %v index: %d", app->name, app->app_index);
 
   if (application_is_proxy (app))
     application_remove_proxy (app);
@@ -642,7 +640,7 @@ application_detach_process (application_t * app, u32 api_client_index)
     }
 
   APP_DBG ("Detaching for app %v index %u api client index %u", app->name,
-          app->app_index, app->api_client_index);
+          app->app_index, api_client_index);
 
   /* *INDENT-OFF* */
   pool_foreach (wrk_map, app->worker_maps, ({
@@ -696,10 +694,12 @@ application_n_workers (application_t * app)
 app_worker_t *
 application_listener_select_worker (session_t * ls)
 {
+  application_t *app;
   app_listener_t *al;
 
-  al = app_listener_get_w_session (ls);
-  return app_listener_select_worker (al);
+  app = application_get (ls->app_index);
+  al = app_listener_get (app, ls->al_index);
+  return app_listener_select_worker (app, al);
 }
 
 int
@@ -718,7 +718,7 @@ application_alloc_worker_and_init (application_t * app, app_worker_t ** wrk)
   /*
    * Setup first segment manager
    */
-  sm = segment_manager_new ();
+  sm = segment_manager_alloc ();
   sm->app_wrk_index = app_wrk->wrk_index;
 
   if ((rv = segment_manager_init (sm, app->sm_properties.segment_size,
@@ -745,7 +745,7 @@ application_alloc_worker_and_init (application_t * app, app_worker_t ** wrk)
 int
 vnet_app_worker_add_del (vnet_app_worker_add_del_args_t * a)
 {
-  svm_fifo_segment_private_t *fs;
+  fifo_segment_t *fs;
   app_worker_map_t *wrk_map;
   app_worker_t *app_wrk;
   segment_manager_t *sm;
@@ -820,11 +820,11 @@ app_name_from_api_index (u32 api_client_index)
   vl_api_registration_t *regp;
   regp = vl_api_client_index_to_registration (api_client_index);
   if (regp)
-    return format (0, "%s%c", regp->name, 0);
+    return format (0, "%s", regp->name);
 
   clib_warning ("api client index %u does not have an api registration!",
                api_client_index);
-  return format (0, "unknown%c", 0);
+  return format (0, "unknown");
 }
 
 /**
@@ -837,7 +837,7 @@ app_name_from_api_index (u32 api_client_index)
 int
 vnet_application_attach (vnet_app_attach_args_t * a)
 {
-  svm_fifo_segment_private_t *fs;
+  fifo_segment_t *fs;
   application_t *app = 0;
   app_worker_t *app_wrk;
   segment_manager_t *sm;
@@ -1206,7 +1206,7 @@ application_start_stop_proxy_fib_proto (application_t * app, u8 fib_proto,
 
          app_worker_start_listen (app_wrk, al);
          s = listen_session_get (al->session_index);
-         s->enqueue_epoch = SESSION_PROXY_LISTENER_INDEX;
+         s->flags |= SESSION_F_PROXY;
        }
     }
   else
@@ -1312,13 +1312,13 @@ application_remove_proxy (application_t * app)
   /* *INDENT-ON* */
 }
 
-segment_manager_properties_t *
+segment_manager_props_t *
 application_segment_manager_properties (application_t * app)
 {
   return &app->sm_properties;
 }
 
-segment_manager_properties_t *
+segment_manager_props_t *
 application_get_segment_manager_properties (u32 app_index)
 {
   application_t *app = application_get (app_index);
@@ -1403,7 +1403,7 @@ format_application (u8 * s, va_list * args)
 {
   application_t *app = va_arg (*args, application_t *);
   CLIB_UNUSED (int verbose) = va_arg (*args, int);
-  segment_manager_properties_t *props;
+  segment_manager_props_t *props;
   const u8 *app_ns_name, *app_name;
   app_worker_map_t *wrk_map;
   app_worker_t *app_wrk;
@@ -1420,12 +1420,12 @@ format_application (u8 * s, va_list * args)
   props = application_segment_manager_properties (app);
   if (!verbose)
     {
-      s = format (s, "%-10u%-20s%-40s", app->app_index, app_name,
+      s = format (s, "%-10u%-20v%-40s", app->app_index, app_name,
                  app_ns_name);
       return s;
     }
 
-  s = format (s, "app-name %s app-index %u ns-index %u seg-size %U\n",
+  s = format (s, "app-name %v app-index %u ns-index %u seg-size %U\n",
              app_name, app->app_index, app->ns_index,
              format_memory_size, props->add_segment_size);
   s = format (s, "rx-fifo-size %U tx-fifo-size %U workers:\n",