session: cli to add/del collector to app 35/43235/2
authorFlorin Coras <[email protected]>
Sat, 21 Jun 2025 05:12:48 +0000 (22:12 -0700)
committerFlorin Coras <[email protected]>
Thu, 3 Jul 2025 00:51:08 +0000 (00:51 +0000)
Type: improvement

Change-Id: Ie1ec27eab7d297f20ec7cad46d2e90b9965f896a
Signed-off-by: Florin Coras <[email protected]>
src/vnet/session/application.c
src/vnet/session/application_eventing.c
src/vnet/session/application_interface.h

index 1bfce79..a550aec 100644 (file)
@@ -856,7 +856,7 @@ application_alloc_and_init (app_init_args_t *a)
     props->pct_first_alloc = opts[APP_OPTIONS_PCT_FIRST_ALLOC];
   props->segment_type = seg_type;
 
-  if (opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_LOG_COLLECTOR)
+  if (opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_COLLECTOR)
     app->cb_fns.app_evt_callback = app_evt_collector_get_cb_fn ();
 
   /* Add app to lookup by api_client_index table */
index e698d1c..9ce8f4d 100644 (file)
@@ -518,6 +518,7 @@ app_evt_collector_enable_command_fn (vlib_main_t *vm, unformat_input_t *input,
   u8 *collector_uri = 0, is_enable = 0, is_add = 1;
   app_evt_main_t *alm = &app_evt_main;
   clib_error_t *error = 0;
+  u32 app_index = ~0;
   u64 tmp64 = 0;
 
   if (!unformat_user (input, unformat_line_input, line_input))
@@ -542,6 +543,8 @@ app_evt_collector_enable_command_fn (vlib_main_t *vm, unformat_input_t *input,
        alm->segment_size = tmp64;
       else if (unformat (line_input, "uri %s", &collector_uri))
        vec_add1 (collector_uri, 0);
+      else if (unformat (line_input, "app %d", &app_index))
+       ;
       else if (unformat (line_input, "add"))
        ;
       else if (unformat (line_input, "del"))
@@ -592,6 +595,23 @@ app_evt_collector_enable_command_fn (vlib_main_t *vm, unformat_input_t *input,
        }
     }
 
+  if (app_index != ~0)
+    {
+      application_t *app = application_get (app_index);
+      if (!app)
+       {
+         error = clib_error_return (0, "Invalid app index %u", app_index);
+         goto done;
+       }
+      if (!is_add)
+       {
+         app->evt_collector_index = APP_INVALID_INDEX;
+         app->cb_fns.app_evt_callback = 0;
+         goto done;
+       }
+      app->cb_fns.app_evt_callback = app_evt_collector_get_cb_fn ();
+    }
+
 done:
   unformat_free (line_input);
   vec_free (collector_uri);
@@ -601,7 +621,7 @@ done:
 VLIB_CLI_COMMAND (app_evt_collector_command, static) = {
   .path = "app evt-collector",
   .short_help = "app evt-collector [enable] [segment-size <nn>[k|m]] "
-               "[fifo-size <nn>[k|m]] [add|del] uri <uri>",
+               "[fifo-size <nn>[k|m]] [add|del] [uri <uri>] [app <index>] ",
   .function = app_evt_collector_enable_command_fn,
 };
 
index a8ca422..4d53eec 100644 (file)
@@ -246,7 +246,7 @@ typedef enum
   _ (MEMFD_FOR_BUILTIN, "Use memfd for builtin app segs")                     \
   _ (USE_HUGE_PAGE, "Use huge page for FIFO")                                 \
   _ (GET_ORIGINAL_DST, "Get original dst enabled")                            \
-  _ (LOG_COLLECTOR, "App requests log collector")
+  _ (EVT_COLLECTOR, "App requests event collector")
 
 typedef enum _app_options
 {