diff options
author | Mohammed Hawari <mohammed@hawari.fr> | 2023-05-26 14:52:50 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2023-06-30 11:35:44 +0000 |
commit | 52fa5f21b911aaf1c50feb560dd3683b83625d2f (patch) | |
tree | f29e6ba9e62b6102284988d5bde7494c93e23407 /src/plugins/tracedump/tracedump.c | |
parent | 60527bd6df4772bb4215403f2eea1b61b8b10157 (diff) |
vlib: introduce trace filter functions
Change-Id: I7a988fafe98599e4fcf7cdaa307a69b9d76650f0
Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
Type: improvement
Diffstat (limited to 'src/plugins/tracedump/tracedump.c')
-rw-r--r-- | src/plugins/tracedump/tracedump.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/plugins/tracedump/tracedump.c b/src/plugins/tracedump/tracedump.c index 10107ac799e..6510a948c57 100644 --- a/src/plugins/tracedump/tracedump.c +++ b/src/plugins/tracedump/tracedump.c @@ -473,6 +473,61 @@ vl_api_trace_clear_cache_t_handler (vl_api_trace_clear_cache_t *mp) REPLY_MACRO (VL_API_TRACE_CLEAR_CACHE_REPLY); } +static void +vl_api_trace_set_filter_function_t_handler ( + vl_api_trace_set_filter_function_t *mp) +{ + vl_api_trace_set_filter_function_reply_t *rmp; + tracedump_main_t *tdmp = &tracedump_main; + unformat_input_t input = { 0 }; + vlib_is_packet_traced_fn_t *f; + char *filter_name; + int rv = 0; + filter_name = vl_api_from_api_to_new_c_string (&mp->filter_function_name); + unformat_init_cstring (&input, filter_name); + if (unformat (&input, "%U", unformat_vlib_trace_filter_function, &f) == 0) + { + rv = -1; + goto done; + } + vlib_set_trace_filter_function (f); +done: + unformat_free (&input); + vec_free (filter_name); + REPLY_MACRO (VL_API_TRACE_SET_FILTER_FUNCTION_REPLY); +} + +static void +vl_api_trace_filter_function_dump_t_handler ( + vl_api_trace_filter_function_dump_t *mp) +{ + vl_api_registration_t *rp; + vl_api_trace_filter_function_details_t *dmp; + tracedump_main_t *tdmp = &tracedump_main; + vlib_trace_filter_main_t *tfm = &vlib_trace_filter_main; + vlib_trace_filter_function_registration_t *reg = + tfm->trace_filter_registration; + vlib_main_t *vm = vlib_get_main (); + vlib_is_packet_traced_fn_t *current = + vm->trace_main.current_trace_filter_function; + rp = vl_api_client_index_to_registration (mp->client_index); + + if (rp == 0) + return; + + while (reg) + { + dmp = vl_msg_api_alloc (sizeof (*dmp) + strlen (reg->name)); + dmp->_vl_msg_id = + htons (VL_API_TRACE_FILTER_FUNCTION_DETAILS + (tdmp->msg_id_base)); + dmp->context = mp->context; + vl_api_c_string_to_api_string (reg->name, &dmp->name); + dmp->selected = current == reg->function; + vl_api_send_msg (rp, (u8 *) dmp); + reg = reg->next; + } +} + /* API definitions */ #include <tracedump/tracedump.api.c> |