summaryrefslogtreecommitdiffstats
path: root/src/vlib
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
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')
-rw-r--r--src/vlib/error.c31
-rw-r--r--src/vlib/error.h4
2 files changed, 35 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)
{
diff --git a/src/vlib/error.h b/src/vlib/error.h
index 11757e05f67..2bffc6b9367 100644
--- a/src/vlib/error.h
+++ b/src/vlib/error.h
@@ -40,6 +40,8 @@
#ifndef included_vlib_error_h
#define included_vlib_error_h
+#include <vppinfra/format.h>
+
typedef u16 vlib_error_t;
enum vl_counter_severity_e
@@ -75,6 +77,8 @@ void vlib_register_errors (struct vlib_main_t *vm,
u32 n_errors, char *error_strings[],
vl_counter_t counters[]);
+unformat_function_t unformat_vlib_error;
+
#endif /* included_vlib_error_h */
/*