api: call api reaper callbacks for socket clients 70/27970/2
authorDave Barach <dave@barachs.net>
Fri, 17 Jul 2020 21:16:34 +0000 (17:16 -0400)
committerDamjan Marion <dmarion@me.com>
Sun, 19 Jul 2020 13:06:06 +0000 (13:06 +0000)
Add a callback to clear the per-client packet trace buffer cache.

Save the packet trace dump pg setup script.

Type: improvement
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I252be911b5f937ece0da5dca152263ece3d52963

src/plugins/tracedump/setup.pg [new file with mode: 0644]
src/plugins/tracedump/tracedump.c
src/vlibmemory/memory_api.c
src/vlibmemory/socket_api.c

diff --git a/src/plugins/tracedump/setup.pg b/src/plugins/tracedump/setup.pg
new file mode 100644 (file)
index 0000000..91d5ebe
--- /dev/null
@@ -0,0 +1,34 @@
+set term pag off
+
+packet-generator new {
+    name worker0
+    worker 0
+    limit 12
+    rate 1.2e7
+    size 128-128
+    interface local0
+    node ethernet-input
+    data { IP4: 1.2.40 -> 3cfd.fed0.b6c8
+           UDP: 192.168.40.1 - 192.168.40.100 -> 192.168.50.10
+           UDP: 1234 -> 2345
+           incrementing 114
+    }
+}
+
+packet-generator new {
+    name worker1
+    worker 1
+    limit 12
+    rate 1.2e7
+    size 128-128
+    interface local0
+    node ethernet-input
+    data { IP4: 1.2.4 -> 3cfd.fed0.b6c9
+           UDP: 192.168.41.1 - 192.168.41.100 -> 192.168.51.10
+           UDP: 1234 -> 2345
+           incrementing 114
+    }
+}
+
+trace add pg-input 20
+pa en
index 87e6cf6..21a0c3d 100644 (file)
@@ -61,6 +61,23 @@ toss_client_cache (tracedump_main_t * tdmp, u32 client_index,
   tdmp->traces[client_index] = client_trace_cache;
 }
 
+static clib_error_t *
+tracedump_cache_reaper (u32 client_index)
+{
+  tracedump_main_t *tdmp = &tracedump_main;
+  vlib_trace_header_t ***client_trace_cache;
+
+  /* Its likely that we won't have a cache entry */
+  if (client_index >= vec_len (tdmp->traces))
+    return 0;
+
+  client_trace_cache = tdmp->traces[client_index];
+  toss_client_cache (tdmp, client_index, client_trace_cache);
+  return 0;
+}
+
+VL_MSG_API_REAPER_FUNCTION (tracedump_cache_reaper);
+
 /* API message handler */
 static void
 vl_api_trace_dump_t_handler (vl_api_trace_dump_t * mp)
index b5f3fae..18a87b3 100644 (file)
@@ -231,7 +231,7 @@ vl_api_memclnt_create_t_handler (vl_api_memclnt_create_t * mp)
   vl_msg_api_send_shmem (q, (u8 *) & rp);
 }
 
-int
+void
 vl_api_call_reaper_functions (u32 client_index)
 {
   clib_error_t *error = 0;
@@ -245,7 +245,6 @@ vl_api_call_reaper_functions (u32 client_index)
        clib_error_report (error);
       i = i->next_init_function;
     }
-  return 0;
 }
 
 /*
@@ -263,8 +262,7 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
 
   handle = mp->index;
 
-  if (vl_api_call_reaper_functions (handle))
-    return;
+  vl_api_call_reaper_functions (handle);
 
   epoch = vl_msg_api_handle_get_epoch (handle);
   client_index = vl_msg_api_handle_get_index (handle);
@@ -616,7 +614,7 @@ vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
 
              handle = vl_msg_api_handle_from_index_and_epoch
                (dead_indices[i], shm->application_restarts);
-             (void) vl_api_call_reaper_functions (handle);
+             vl_api_call_reaper_functions (handle);
            }
        }
 
index 6238746..566305f 100644 (file)
@@ -170,6 +170,8 @@ vl_socket_free_registration_index (u32 pool_index)
 {
   int i;
   vl_api_registration_t *rp;
+  void vl_api_call_reaper_functions (u32 client_index);
+
   if (pool_is_free_index (socket_main.registration_pool, pool_index))
     {
       clib_warning ("main pool index %d already free", pool_index);
@@ -177,6 +179,8 @@ vl_socket_free_registration_index (u32 pool_index)
     }
   rp = pool_elt_at_index (socket_main.registration_pool, pool_index);
 
+  vl_api_call_reaper_functions (pool_index);
+
   ASSERT (rp->registration_type != REGISTRATION_TYPE_FREE);
   for (i = 0; i < vec_len (rp->additional_fds_to_close); i++)
     if (close (rp->additional_fds_to_close[i]) < 0)