summaryrefslogtreecommitdiffstats
path: root/src/plugins/tracedump/tracedump_test.c
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2023-04-11 15:45:59 +0000
committerBeno�t Ganne <bganne@cisco.com>2023-05-23 11:40:29 +0000
commit02063b985ac2fd3ce24a42fe9e27f434ea088053 (patch)
tree601ee00fac0d921105d9e190ec19efa4745ffc42 /src/plugins/tracedump/tracedump_test.c
parenteed42b0efa576a6a0efa93df7c3e96ce3296f7af (diff)
misc: fix tracedump API to match CLI behavior
When dumping packets from multiple threads using the API, first all packets from thread 0 are dumped then all ones from thread 1, etc Until we reach the limit specified by the API call, so we could never get packets trace from threads with higher ids. However, the tracedump CLI dump a maximum number of packets from all threads, which we can expect from the API to do. We also add a trace_clear_cache API so the client gets an answer when he only wants to clear its packet cache. Type: improvement Change-Id: I0d4df8f6210a298ac3f22cd651eb4d8f445e1034 Signed-off-by: Maxime Peim <mpeim@cisco.com>
Diffstat (limited to 'src/plugins/tracedump/tracedump_test.c')
-rw-r--r--src/plugins/tracedump/tracedump_test.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/plugins/tracedump/tracedump_test.c b/src/plugins/tracedump/tracedump_test.c
index 1a2c8185fe2..97fd4092d89 100644
--- a/src/plugins/tracedump/tracedump_test.c
+++ b/src/plugins/tracedump/tracedump_test.c
@@ -155,6 +155,18 @@ vl_api_trace_details_t_handler (vl_api_trace_details_t * dmp)
packet_number, vl_api_format_string, (&dmp->trace_data));
}
+static void
+vl_api_trace_v2_details_t_handler (vl_api_trace_v2_details_t *dmp)
+{
+ u32 thread_id, position;
+
+ thread_id = clib_net_to_host_u32 (dmp->thread_id);
+ position = clib_net_to_host_u32 (dmp->position);
+ fformat (stdout, "thread %d position %d more %d", thread_id, position,
+ dmp->more);
+ fformat (stdout, "Packet %d\n%U\n\n", position, vl_api_format_string,
+ (&dmp->trace_data));
+}
static void
vl_api_trace_dump_reply_t_handler (vl_api_trace_dump_reply_t * rmp)
@@ -203,7 +215,7 @@ vl_api_trace_dump_reply_t_handler (vl_api_trace_dump_reply_t * rmp)
}
static int
-api_trace_dump (vat_main_t * vam)
+api_trace_dump (vat_main_t *vam)
{
vl_api_trace_dump_t *mp;
int ret;
@@ -220,8 +232,26 @@ api_trace_dump (vat_main_t * vam)
return ret;
}
+static int
+api_trace_v2_dump (vat_main_t *vam)
+{
+ vl_api_trace_v2_dump_t *mp;
+ int ret;
+
+ M (TRACE_V2_DUMP, mp);
+ mp->clear_cache = 1;
+ mp->thread_id = ~0;
+ mp->position = 0;
+ mp->max = clib_host_to_net_u32 (10);
+
+ S (mp);
+
+ W (ret);
+ return ret;
+}
+
int
-api_trace_clear_capture (vat_main_t * vam)
+api_trace_clear_capture (vat_main_t *vam)
{
vl_api_trace_clear_capture_t *mp;
int ret;
@@ -232,8 +262,17 @@ api_trace_clear_capture (vat_main_t * vam)
return ret;
}
+static int
+api_trace_clear_cache (vat_main_t *vam)
+{
+ vl_api_trace_clear_capture_t *mp;
+ int ret;
-
+ M (TRACE_CLEAR_CACHE, mp);
+ S (mp);
+ W (ret);
+ return ret;
+}
#define vl_endianfun
#include <tracedump/tracedump.api.h>