summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2020-10-07 18:05:37 +0200
committerNeale Ranns <nranns@cisco.com>2020-10-13 11:42:58 +0000
commit148c7b768721231325a349fa82db693190513b53 (patch)
tree94e0a9768eda3bc4923b1b3cc727dc637d877381 /src/plugins
parente7c8396982607634b4c747870499671ffa53868e (diff)
stats: counters data model
This adds a new data model for counters. Specifying the errors severity and unit. A later patch will update vpp_get_stats to take advantage of this. Only the map plugin is updates as an example. New .api language: A new "counters" keyword to define counter sets. counters map { none { severity info; type counter64; units "packets"; description "valid MAP packets"; }; bad_protocol { severity error; type counter64; units "packets"; description "bad protocol"; }; }; Each counter has 4 keywords. severity, which is one of error, info or warn. A type, which is one of counter64 or gauge64. units, which is a text field using units from YANG. paths { "/err/ip4-map" "map"; "/err/ip6-map" "map"; "/err/ip4-t-map" "map"; "/err/ip6-t-map" "map"; }; A new paths keyword that maps the counter-set to a path in the stats segment KV store. Updated VPP CLI to include severity so user can see error counter severity. DBGvpp# show errors Count Node Reason Severity 13 ethernet-input no error error Type: feature Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Ib2177543f49d4c3aef4d7fa72476cff2068f7771 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cdp/test/test_cdp.py24
-rw-r--r--src/plugins/map/ip4_map.c9
-rw-r--r--src/plugins/map/ip4_map_t.c14
-rw-r--r--src/plugins/map/ip6_map.c12
-rw-r--r--src/plugins/map/ip6_map_t.c14
-rw-r--r--src/plugins/map/map.api114
-rw-r--r--src/plugins/map/map.h33
7 files changed, 131 insertions, 89 deletions
diff --git a/src/plugins/cdp/test/test_cdp.py b/src/plugins/cdp/test/test_cdp.py
index 1bc67c45c3e..46751e81d86 100644
--- a/src/plugins/cdp/test/test_cdp.py
+++ b/src/plugins/cdp/test/test_cdp.py
@@ -108,18 +108,9 @@ class TestCDP(VppTestCase):
self.logger.info(self.vapi.cdp_enable_disable(enable_disable=1))
self.send_packet(self.create_bad_packet(l, v))
- errors = list(self.show_errors())
- self.assertTrue(errors)
-
- expected_errors = False
- for count, node, reason in errors:
- if (node == u'cdp-input' and
- reason == u'cdp packets with bad TLVs' and
- int(count) >= 1):
-
- expected_errors = True
- break
- self.assertTrue(expected_errors, "CDP didn't drop bad packet")
+ err = self.statistics.get_err_counter(
+ '/err/cdp-input/cdp packets with bad TLVs')
+ self.assertTrue(err >= 1, "CDP didn't drop bad packet")
def send_packet(self, packet):
self.logger.debug(ppp("Sending packet:", packet))
@@ -162,12 +153,3 @@ class TestCDP(VppTestCase):
pass
else:
yield port, system
-
- def show_errors(self):
- for pack in self.process_cli("show errors", self.err_ptr):
- try:
- count, node, reason = pack
- except ValueError:
- pass
- else:
- yield count, node, reason
diff --git a/src/plugins/map/ip4_map.c b/src/plugins/map/ip4_map.c
index a4889627f0b..1ab5cc2dc4f 100644
--- a/src/plugins/map/ip4_map.c
+++ b/src/plugins/map/ip4_map.c
@@ -325,13 +325,6 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
return frame->n_vectors;
}
-static char *map_error_strings[] = {
-#define _(sym,string) string,
- foreach_map_error
-#undef _
-};
-
-
/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip4_map_feature, static) =
{
@@ -349,7 +342,7 @@ VLIB_REGISTER_NODE(ip4_map_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP4_MAP_N_NEXT,
.next_nodes = {
diff --git a/src/plugins/map/ip4_map_t.c b/src/plugins/map/ip4_map_t.c
index 7d16d7aa455..8ae76f331f6 100644
--- a/src/plugins/map/ip4_map_t.c
+++ b/src/plugins/map/ip4_map_t.c
@@ -684,12 +684,6 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
return frame->n_vectors;
}
-static char *map_t_error_strings[] = {
-#define _(sym,string) string,
- foreach_map_error
-#undef _
-};
-
/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip4_map_t_feature, static) = {
.arc_name = "ip4-unicast",
@@ -706,7 +700,7 @@ VLIB_REGISTER_NODE(ip4_map_t_fragmented_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP4_MAPT_FRAGMENTED_N_NEXT,
.next_nodes = {
@@ -727,7 +721,7 @@ VLIB_REGISTER_NODE(ip4_map_t_icmp_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP4_MAPT_ICMP_N_NEXT,
.next_nodes = {
@@ -748,7 +742,7 @@ VLIB_REGISTER_NODE(ip4_map_t_tcp_udp_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP4_MAPT_TCP_UDP_N_NEXT,
.next_nodes = {
@@ -769,7 +763,7 @@ VLIB_REGISTER_NODE(ip4_map_t_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP4_MAPT_N_NEXT,
.next_nodes = {
diff --git a/src/plugins/map/ip6_map.c b/src/plugins/map/ip6_map.c
index 136f548db50..1193dda0a80 100644
--- a/src/plugins/map/ip6_map.c
+++ b/src/plugins/map/ip6_map.c
@@ -803,12 +803,6 @@ ip6_map_icmp_relay (vlib_main_t * vm,
}
-static char *map_error_strings[] = {
-#define _(sym,string) string,
- foreach_map_error
-#undef _
-};
-
/* *INDENT-OFF* */
VNET_FEATURE_INIT (ip6_map_feature, static) =
{
@@ -826,7 +820,7 @@ VLIB_REGISTER_NODE(ip6_map_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAP_N_NEXT,
.next_nodes = {
@@ -852,7 +846,7 @@ VLIB_REGISTER_NODE(ip6_map_post_ip4_reass_node) = {
.format_trace = format_ip6_map_post_ip4_reass_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAP_POST_IP4_REASS_N_NEXT,
.next_nodes = {
[IP6_MAP_POST_IP4_REASS_NEXT_IP4_LOOKUP] = "ip4-lookup",
@@ -870,7 +864,7 @@ VLIB_REGISTER_NODE(ip6_map_icmp_relay_node, static) = {
.format_trace = format_map_trace, //FIXME
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_ICMP_RELAY_N_NEXT,
.next_nodes = {
[IP6_ICMP_RELAY_NEXT_IP4_LOOKUP] = "ip4-lookup",
diff --git a/src/plugins/map/ip6_map_t.c b/src/plugins/map/ip6_map_t.c
index 874a14c99ed..861c049b0f4 100644
--- a/src/plugins/map/ip6_map_t.c
+++ b/src/plugins/map/ip6_map_t.c
@@ -687,12 +687,6 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
return frame->n_vectors;
}
-static char *map_t_error_strings[] = {
-#define _(sym, string) string,
- foreach_map_error
-#undef _
-};
-
/* *INDENT-OFF* */
VLIB_REGISTER_NODE(ip6_map_t_fragmented_node) = {
.function = ip6_map_t_fragmented,
@@ -702,7 +696,7 @@ VLIB_REGISTER_NODE(ip6_map_t_fragmented_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAPT_FRAGMENTED_N_NEXT,
.next_nodes =
@@ -724,7 +718,7 @@ VLIB_REGISTER_NODE(ip6_map_t_icmp_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAPT_ICMP_N_NEXT,
.next_nodes =
@@ -746,7 +740,7 @@ VLIB_REGISTER_NODE(ip6_map_t_tcp_udp_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAPT_TCP_UDP_N_NEXT,
.next_nodes =
@@ -775,7 +769,7 @@ VLIB_REGISTER_NODE(ip6_map_t_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = MAP_N_ERROR,
- .error_strings = map_t_error_strings,
+ .error_counters = map_error_counters,
.n_next_nodes = IP6_MAPT_N_NEXT,
.next_nodes =
diff --git a/src/plugins/map/map.api b/src/plugins/map/map.api
index fa32978591c..dfe255bf349 100644
--- a/src/plugins/map/map.api
+++ b/src/plugins/map/map.api
@@ -349,3 +349,117 @@ define map_param_get_reply
bool tc_copy;
u8 tc_class;
};
+
+/*
+ * MAP Error counters/messages
+ */
+counters map {
+ none {
+ severity info;
+ type counter64;
+ units "packets";
+ description "valid MAP packets";
+ };
+ bad_protocol {
+ severity error;
+ type counter64;
+ units "packets";
+ description "bad protocol";
+ };
+ sec_check {
+ severity error;
+ type counter64;
+ units "packets";
+ description "security check failed";
+ };
+ encap_sec_check {
+ severity error;
+ type counter64;
+ units "packets";
+ description "encap security check failed";
+ };
+ decap_sec_check {
+ severity error;
+ type counter64;
+ units "packets";
+ description "decap security check failed";
+ };
+ icmp {
+ severity error;
+ type counter64;
+ units "packets";
+ description "unable to translate ICMP";
+ };
+ icmp_relay {
+ severity error;
+ type counter64;
+ units "packets";
+ description "unable to relay ICMP";
+ };
+ unknown {
+ severity error;
+ type counter64;
+ units "packets";
+ description "unknown";
+ };
+ no_binding {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no binding";
+ };
+ no_domain {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no domain";
+ };
+ fragmented {
+ severity error;
+ type counter64;
+ units "packets";
+ description "packet is a fragment";
+ };
+ fragment_memory {
+ severity error;
+ type counter64;
+ units "packets";
+ description "could not cache fragment";
+ };
+ fragment_malformed {
+ severity error;
+ type counter64;
+ units "packets";
+ description "fragment has unexpected format";
+ };
+ fragment_dropped {
+ severity error;
+ type counter64;
+ units "packets";
+ description "dropped cached fragment";
+ };
+ malformed {
+ severity error;
+ type counter64;
+ units "packets";
+ description "malformed packet";
+ };
+ df_set {
+ severity error;
+ type counter64;
+ units "packets";
+ description "can't fragment, DF set";
+ };
+ time_exceeded {
+ severity error;
+ type counter64;
+ units "packets";
+ description "time exceeded";
+ };
+};
+paths {
+ "/err/ip4-map" "map";
+ "/err/ip6-map" "map";
+ "/err/ip4-t-map" "map";
+ "/err/ip6-t-map" "map";
+};
diff --git a/src/plugins/map/map.h b/src/plugins/map/map.h
index 16fc60478b5..215a832f431 100644
--- a/src/plugins/map/map.h
+++ b/src/plugins/map/map.h
@@ -23,6 +23,7 @@
#include <vnet/dpo/load_balance.h>
#include "lpm.h"
#include <vppinfra/lock.h>
+#include <map/map.api_enum.h>
#define MAP_SKIP_IP6_LOOKUP 1
@@ -205,37 +206,7 @@ typedef struct
uword ip4_sv_reass_custom_next_index;
} map_main_t;
-/*
- * MAP Error counters/messages
- */
-#define foreach_map_error \
- /* Must be first. */ \
- _(NONE, "valid MAP packets") \
- _(BAD_PROTOCOL, "bad protocol") \
- _(SEC_CHECK, "security check failed") \
- _(ENCAP_SEC_CHECK, "encap security check failed") \
- _(DECAP_SEC_CHECK, "decap security check failed") \
- _(ICMP, "unable to translate ICMP") \
- _(ICMP_RELAY, "unable to relay ICMP") \
- _(UNKNOWN, "unknown") \
- _(NO_BINDING, "no binding") \
- _(NO_DOMAIN, "no domain") \
- _(FRAGMENTED, "packet is a fragment") \
- _(FRAGMENT_MEMORY, "could not cache fragment") \
- _(FRAGMENT_MALFORMED, "fragment has unexpected format")\
- _(FRAGMENT_DROPPED, "dropped cached fragment") \
- _(MALFORMED, "malformed packet") \
- _(DF_SET, "can't fragment, DF set") \
- _(TIME_EXCEEDED, "time exceeded") \
-
-typedef enum
-{
-#define _(sym,str) MAP_ERROR_##sym,
- foreach_map_error
-#undef _
- MAP_N_ERROR,
-} map_error_t;
-
+typedef vl_counter_map_enum_t map_error_t;
u64 map_error_counter_get (u32 node_index, map_error_t map_error);
typedef struct