Improve api trace replay consistency checking
Change-Id: I2c4b9646d53e4c008ccbe6d09c6a683c776c1f60
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h
index b40ece1..2cbeb63 100644
--- a/src/vlibapi/api.h
+++ b/src/vlibapi/api.h
@@ -189,6 +189,9 @@
char *region_name;
char *root_path;
+
+ /* Replay in progress? */
+ int replay_in_progress;
} api_main_t;
extern api_main_t api_main;
diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c
index 79921af..69ba10c 100644
--- a/src/vlibapi/api_shared.c
+++ b/src/vlibapi/api_shared.c
@@ -890,6 +890,9 @@
msg += size;
}
+ if (which == REPLAY)
+ am->replay_in_progress = 1;
+
for (; i <= last_index; i++)
{
trace_cfg_t *cfgp;
@@ -914,6 +917,7 @@
vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
munmap (hp, file_size);
vec_free (tmpbuf);
+ am->replay_in_progress = 0;
return;
}
@@ -937,6 +941,7 @@
vlib_cli_output (vm, "Ugh: msg id %d no endian swap\n", msg_id);
munmap (hp, file_size);
vec_free (tmpbuf);
+ am->replay_in_progress = 0;
return;
}
endian_fp = am->msg_endian_handlers[msg_id];
@@ -1038,6 +1043,7 @@
munmap (hp, file_size);
vec_free (tmpbuf);
+ am->replay_in_progress = 0;
}
u8 *
diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c
index 231caa5..3a7415c 100644
--- a/src/vlibmemory/memory_vlib.c
+++ b/src/vlibmemory/memory_vlib.c
@@ -1249,6 +1249,8 @@
for (i = 0; i < vec_len (rp); i++)
vlib_cli_output (vm, "%U", format_api_msg_range, rp + i);
+ vec_free (rp);
+
return 0;
}
@@ -1369,9 +1371,37 @@
static void
vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t * mp)
{
- /* Do nothing. We just want to trace the message */
-}
+ api_main_t *am = &api_main;
+ vl_api_msg_range_t *rp;
+ uword *p;
+ /* Noop (except for tracing) during normal operation */
+ if (am->replay_in_progress == 0)
+ return;
+
+ p = hash_get_mem (am->msg_range_by_name, mp->plugin_name);
+ if (p == 0)
+ {
+ clib_warning ("WARNING: traced plugin '%s' not in current image",
+ mp->plugin_name);
+ return;
+ }
+
+ rp = vec_elt_at_index (am->msg_ranges, p[0]);
+ if (rp->first_msg_id != clib_net_to_host_u16 (mp->first_msg_id))
+ {
+ clib_warning ("WARNING: traced plugin '%s' first message id %d not %d",
+ mp->plugin_name, clib_net_to_host_u16 (mp->first_msg_id),
+ rp->first_msg_id);
+ }
+
+ if (rp->last_msg_id != clib_net_to_host_u16 (mp->last_msg_id))
+ {
+ clib_warning ("WARNING: traced plugin '%s' last message id %d not %d",
+ mp->plugin_name, clib_net_to_host_u16 (mp->last_msg_id),
+ rp->last_msg_id);
+ }
+}
#define foreach_rpc_api_msg \
_(RPC_CALL,rpc_call) \