summaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-01-24 01:34:25 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2017-01-25 20:53:26 +0000
commit044183faacc5eb8a055658f9deebefb56b254adc (patch)
tree5d9af96930941b5344b1653e057b7008a75f081e /src/vat
parentf3dc11a9d71a30ac89e7ceb523abdb1ff13f0ac3 (diff)
[re]Enable per-Adjacency/neighbour counters
Change-Id: I953b3888bbc6d8a5f53f684a5edc8742b382f323 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/api_format.c124
-rw-r--r--src/vat/vat.h18
2 files changed, 142 insertions, 0 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 653cf79f3db..839bcdaab1d 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2042,6 +2042,42 @@ static void vl_api_vnet_ip4_fib_counters_t_handler_json
}
}
+static void vl_api_vnet_ip4_nbr_counters_t_handler
+ (vl_api_vnet_ip4_nbr_counters_t * mp)
+{
+ /* not supported */
+}
+
+static void vl_api_vnet_ip4_nbr_counters_t_handler_json
+ (vl_api_vnet_ip4_nbr_counters_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vl_api_ip4_nbr_counter_t *v;
+ ip4_nbr_counter_t *counter;
+ u32 sw_if_index;
+ u32 count;
+ int i;
+
+ sw_if_index = ntohl (mp->sw_if_index);
+ count = ntohl (mp->count);
+ vec_validate (vam->ip4_nbr_counters, sw_if_index);
+
+ if (mp->begin)
+ vec_free (vam->ip4_nbr_counters[sw_if_index]);
+
+ v = (vl_api_ip4_nbr_counter_t *) & mp->c;
+ for (i = 0; i < count; i++)
+ {
+ vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
+ counter = &vam->ip4_nbr_counters[sw_if_index][i];
+ counter->address.s_addr = v->address;
+ counter->packets = clib_net_to_host_u64 (v->packets);
+ counter->bytes = clib_net_to_host_u64 (v->bytes);
+ counter->linkt = v->link_type;
+ v++;
+ }
+}
+
static void vl_api_vnet_ip6_fib_counters_t_handler
(vl_api_vnet_ip6_fib_counters_t * mp)
{
@@ -2087,6 +2123,43 @@ static void vl_api_vnet_ip6_fib_counters_t_handler_json
}
}
+static void vl_api_vnet_ip6_nbr_counters_t_handler
+ (vl_api_vnet_ip6_nbr_counters_t * mp)
+{
+ /* not supported */
+}
+
+static void vl_api_vnet_ip6_nbr_counters_t_handler_json
+ (vl_api_vnet_ip6_nbr_counters_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vl_api_ip6_nbr_counter_t *v;
+ ip6_nbr_counter_t *counter;
+ struct in6_addr ip6;
+ u32 sw_if_index;
+ u32 count;
+ int i;
+
+ sw_if_index = ntohl (mp->sw_if_index);
+ count = ntohl (mp->count);
+ vec_validate (vam->ip6_nbr_counters, sw_if_index);
+
+ if (mp->begin)
+ vec_free (vam->ip6_nbr_counters[sw_if_index]);
+
+ v = (vl_api_ip6_nbr_counter_t *) & mp->c;
+ for (i = 0; i < count; i++)
+ {
+ vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
+ counter = &vam->ip6_nbr_counters[sw_if_index][i];
+ clib_memcpy (&ip6, &v->address, sizeof (ip6));
+ counter->address = ip6;
+ counter->packets = clib_net_to_host_u64 (v->packets);
+ counter->bytes = clib_net_to_host_u64 (v->bytes);
+ v++;
+ }
+}
+
static void vl_api_get_first_msg_id_reply_t_handler
(vl_api_get_first_msg_id_reply_t * mp)
{
@@ -3490,6 +3563,10 @@ static void vl_api_flow_classify_details_t_handler_json
#define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
#define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
#define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
+#define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
+#define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
+#define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
+#define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
#define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
#define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
@@ -3799,6 +3876,8 @@ _(DHCP_COMPL_EVENT, dhcp_compl_event) \
_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
_(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
_(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
+_(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
+_(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
_(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
_(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
_(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
@@ -4131,6 +4210,8 @@ dump_stats_table (vat_main_t * vam)
u64 packets;
ip4_fib_counter_t *c4;
ip6_fib_counter_t *c6;
+ ip4_nbr_counter_t *n4;
+ ip6_nbr_counter_t *n6;
int i, j;
if (!vam->json_output)
@@ -4226,6 +4307,49 @@ dump_stats_table (vat_main_t * vam)
}
}
+ /* ip4 nbr counters */
+ msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
+ vat_json_init_array (msg_array);
+ for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
+ {
+ msg = vat_json_array_add (msg_array);
+ vat_json_init_object (msg);
+ vat_json_object_add_uint (msg, "sw_if_index", i);
+ counter_array = vat_json_object_add (msg, "c");
+ vat_json_init_array (counter_array);
+ for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
+ {
+ counter = vat_json_array_add (counter_array);
+ vat_json_init_object (counter);
+ n4 = &vam->ip4_nbr_counters[i][j];
+ vat_json_object_add_ip4 (counter, "address", n4->address);
+ vat_json_object_add_uint (counter, "link-type", n4->linkt);
+ vat_json_object_add_uint (counter, "packets", n4->packets);
+ vat_json_object_add_uint (counter, "bytes", n4->bytes);
+ }
+ }
+
+ /* ip6 nbr counters */
+ msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
+ vat_json_init_array (msg_array);
+ for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
+ {
+ msg = vat_json_array_add (msg_array);
+ vat_json_init_object (msg);
+ vat_json_object_add_uint (msg, "sw_if_index", i);
+ counter_array = vat_json_object_add (msg, "c");
+ vat_json_init_array (counter_array);
+ for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
+ {
+ counter = vat_json_array_add (counter_array);
+ vat_json_init_object (counter);
+ n6 = &vam->ip6_nbr_counters[i][j];
+ vat_json_object_add_ip6 (counter, "address", n6->address);
+ vat_json_object_add_uint (counter, "packets", n6->packets);
+ vat_json_object_add_uint (counter, "bytes", n6->bytes);
+ }
+ }
+
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
diff --git a/src/vat/vat.h b/src/vat/vat.h
index 3d7d96ae566..831bdf50d9d 100644
--- a/src/vat/vat.h
+++ b/src/vat/vat.h
@@ -97,6 +97,22 @@ typedef struct
typedef struct
{
+ struct in_addr address;
+ vnet_link_t linkt;
+ u64 packets;
+ u64 bytes;
+} ip4_nbr_counter_t;
+
+typedef struct
+{
+ struct in6_addr address;
+ vnet_link_t linkt;
+ u64 packets;
+ u64 bytes;
+} ip6_nbr_counter_t;
+
+typedef struct
+{
/* vpe input queue */
unix_shared_memory_queue_t *vl_input_queue;
@@ -185,6 +201,8 @@ typedef struct
u32 *ip4_fib_counters_vrf_id_by_index;
ip6_fib_counter_t **ip6_fib_counters;
u32 *ip6_fib_counters_vrf_id_by_index;
+ ip4_nbr_counter_t **ip4_nbr_counters;
+ ip6_nbr_counter_t **ip6_nbr_counters;
/* Convenience */
vlib_main_t *vlib_main;