summaryrefslogtreecommitdiffstats
path: root/src/vlib/error.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-03-03 17:37:25 +0100
committerDave Barach <openvpp@barachs.net>2021-04-22 11:12:59 +0000
commit5cfe45211ac7977ab9bf07b817fe9a5d00226eb3 (patch)
tree1154a67367b5cbd8343ecdc48518746bdcc8642a /src/vlib/error.c
parentd06e2eb1a1d570367b4076772ac66bc95e3a7bd8 (diff)
misc: add filter for specific error for pcap trace
Type: feature Change-Id: I325257454df1cc22833fa6a1dedd4739d4d5a558 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlib/error.c')
-rw-r--r--src/vlib/error.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/vlib/error.c b/src/vlib/error.c
index 99664c618a9..1a84e7e6801 100644
--- a/src/vlib/error.c
+++ b/src/vlib/error.c
@@ -210,6 +210,37 @@ vlib_register_errors (vlib_main_t * vm,
}
}
+uword
+unformat_vlib_error (unformat_input_t *input, va_list *args)
+{
+ vlib_main_t *vm = va_arg (*args, vlib_main_t *);
+ const vlib_error_main_t *em = &vm->error_main;
+ vlib_error_t *error_index = va_arg (*args, vlib_error_t *);
+ const vlib_node_t *node;
+ char *error_name;
+ u32 node_index;
+ vlib_error_t i;
+
+ if (!unformat (input, "%U.%s", unformat_vlib_node, vm, &node_index,
+ &error_name))
+ return 0;
+
+ node = vlib_get_node (vm, node_index);
+ for (i = 0; i < node->n_errors; i++)
+ {
+ vlib_error_t ei = node->error_heap_index + i;
+ if (strcmp (em->counters_heap[ei].name, error_name) == 0)
+ {
+ *error_index = ei;
+ vec_free (error_name);
+ return 1;
+ }
+ }
+
+ vec_free (error_name);
+ return 0;
+}
+
static char *
sev2str (enum vl_counter_severity_e s)
{