summaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp_encap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/udp/udp_encap.c')
-rw-r--r--src/vnet/udp/udp_encap.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/vnet/udp/udp_encap.c b/src/vnet/udp/udp_encap.c
index 8392b391736..8005fa57e70 100644
--- a/src/vnet/udp/udp_encap.c
+++ b/src/vnet/udp/udp_encap.c
@@ -33,6 +33,11 @@ uword *udp_encap_db;
*/
udp_encap_t *udp_encap_pool;
+/**
+ * Stats for each UDP encap object
+ */
+vlib_combined_counter_main_t udp_encap_counters;
+
static udp_encap_t *
udp_encap_get_w_id (u32 id)
{
@@ -79,6 +84,9 @@ udp_encap_add_and_lock (u32 id,
pool_get (udp_encap_pool, ue);
uei = ue - udp_encap_pool;
+ vlib_validate_combined_counter (&(udp_encap_counters), uei);
+ vlib_zero_combined_counter (&(udp_encap_counters), uei);
+
hash_set (udp_encap_db, id, uei);
fib_node_init (&ue->ue_fib_node, FIB_NODE_TYPE_UDP_ENCAP);
@@ -258,6 +266,7 @@ format_udp_encap_i (u8 * s, va_list * args)
index_t uei = va_arg (*args, index_t);
u32 indent = va_arg (*args, u32);
u32 details = va_arg (*args, u32);
+ vlib_counter_t to;
udp_encap_t *ue;
ue = udp_encap_get (uei);
@@ -285,6 +294,9 @@ format_udp_encap_i (u8 * s, va_list * args)
clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.src_port),
clib_net_to_host_u16 (ue->ue_hdrs.ip6.ue_udp.dst_port));
}
+ vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
+ s = format (s, " to:[%Ld:%Ld]]", to.packets, to.bytes);
+
if (details)
{
s = format (s, " locks:%d", ue->ue_fib_node.fn_locks);
@@ -296,6 +308,17 @@ format_udp_encap_i (u8 * s, va_list * args)
return (s);
}
+void
+udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes)
+{
+ vlib_counter_t to;
+
+ vlib_get_combined_counter (&(udp_encap_counters), uei, &to);
+
+ *packets = to.packets;
+ *bytes = to.bytes;
+}
+
static u8 *
format_udp_encap_dpo (u8 * s, va_list * args)
{
@@ -568,6 +591,20 @@ done:
return error;
}
+void
+udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx)
+{
+ index_t uei;
+
+ /* *INDENT-OFF* */
+ pool_foreach_index(uei, udp_encap_pool,
+ ({
+ if (!cb(uei, ctx))
+ break;
+ }));
+ /* *INDENT-ON* */
+}
+
clib_error_t *
udp_encap_show (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)