aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/udp')
-rw-r--r--src/vnet/udp/udp_encap.c37
-rw-r--r--src/vnet/udp/udp_encap.h13
-rw-r--r--src/vnet/udp/udp_encap_node.c15
3 files changed, 65 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)
diff --git a/src/vnet/udp/udp_encap.h b/src/vnet/udp/udp_encap.h
index b8f329dcbee..185d5e7f7f9 100644
--- a/src/vnet/udp/udp_encap.h
+++ b/src/vnet/udp/udp_encap.h
@@ -125,6 +125,19 @@ extern void udp_encap_contribute_forwarding (u32 id,
dpo_proto_t proto,
dpo_id_t * dpo);
+extern void udp_encap_get_stats (index_t uei, u64 * packets, u64 * bytes);
+
+/**
+ * Callback function invoked when walking all encap objects.
+ * Return non-zero to continue the walk.
+ */
+typedef int (*udp_encap_walk_cb_t) (index_t uei, void *ctx);
+
+/**
+ * Walk each of the encap objects
+ */
+extern void udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx);
+
/**
* Pool of encaps
*/
diff --git a/src/vnet/udp/udp_encap_node.c b/src/vnet/udp/udp_encap_node.c
index 09a76b530f6..2d37d8b58dd 100644
--- a/src/vnet/udp/udp_encap_node.c
+++ b/src/vnet/udp/udp_encap_node.c
@@ -27,6 +27,8 @@ typedef struct udp6_encap_trace_t_
ip6_header_t ip;
} udp6_encap_trace_t;
+extern vlib_combined_counter_main_t udp_encap_counters;
+
static u8 *
format_udp4_encap_trace (u8 * s, va_list * args)
{
@@ -62,8 +64,10 @@ udp_encap_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame, int is_encap_v6)
{
+ vlib_combined_counter_main_t *cm = &udp_encap_counters;
u32 *from = vlib_frame_vector_args (frame);
u32 n_left_from, n_left_to_next, *to_next, next_index;
+ u32 thread_index = vlib_get_thread_index ();
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
@@ -104,6 +108,13 @@ udp_encap_inline (vlib_main_t * vm,
uei0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
uei1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
+ vlib_increment_combined_counter (cm, thread_index, uei0, 1,
+ vlib_buffer_length_in_chain (vm,
+ b0));
+ vlib_increment_combined_counter (cm, thread_index, uei1, 1,
+ vlib_buffer_length_in_chain (vm,
+ b1));
+
/* Rewrite packet header and updates lengths. */
ue0 = udp_encap_get (uei0);
ue1 = udp_encap_get (uei1);
@@ -185,6 +196,10 @@ udp_encap_inline (vlib_main_t * vm,
/* Rewrite packet header and updates lengths. */
ue0 = udp_encap_get (uei0);
+ vlib_increment_combined_counter (cm, thread_index, uei0, 1,
+ vlib_buffer_length_in_chain (vm,
+ b0));
+
/* Paint */
if (is_encap_v6)
{