aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/srv6-as
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/srv6-as')
-rw-r--r--src/plugins/srv6-as/as.c29
-rw-r--r--src/plugins/srv6-as/as.h37
-rw-r--r--src/plugins/srv6-as/node.c27
3 files changed, 72 insertions, 21 deletions
diff --git a/src/plugins/srv6-as/as.c b/src/plugins/srv6-as/as.c
index b8ce68c981a..5cd5226a462 100644
--- a/src/plugins/srv6-as/as.c
+++ b/src/plugins/srv6-as/as.c
@@ -212,6 +212,18 @@ srv6_as_localsid_creation_fn (ip6_sr_localsid_t * localsid)
sm->sw_iface_localsid6[ls_mem->sw_if_index_in] = localsid_index;
}
+ /* Step 3: Initialize rewrite counters */
+ srv6_as_localsid_t **ls_p;
+ pool_get (sm->sids, ls_p);
+ *ls_p = ls_mem;
+ ls_mem->index = ls_p - sm->sids;
+
+ vlib_validate_combined_counter (&(sm->valid_counters), ls_mem->index);
+ vlib_validate_combined_counter (&(sm->invalid_counters), ls_mem->index);
+
+ vlib_zero_combined_counter (&(sm->valid_counters), ls_mem->index);
+ vlib_zero_combined_counter (&(sm->invalid_counters), ls_mem->index);
+
return 0;
}
@@ -250,6 +262,9 @@ srv6_as_localsid_removal_fn (ip6_sr_localsid_t * localsid)
/* Unlock (OIF, NHOP) adjacency (from sr_localsid.c:103) */
adj_unlock (ls_mem->nh_adj);
+ /* Delete SID entry */
+ pool_put (sm->sids, pool_elt_at_index (sm->sids, ls_mem->index));
+
/* Clean up local SID memory */
free_ls_mem (ls_mem);
@@ -268,6 +283,7 @@ format_srv6_as_localsid (u8 * s, va_list * args)
srv6_as_localsid_t *ls_mem = va_arg (*args, void *);
vnet_main_t *vnm = vnet_get_main ();
+ srv6_as_main_t *sm = &srv6_as_main;
if (ls_mem->ip_version == DA_IP4)
{
@@ -295,7 +311,18 @@ format_srv6_as_localsid (u8 * s, va_list * args)
{
s = format (s, "%U, ", format_ip6_address, addr);
}
- s = format (s, "\b\b > ");
+ s = format (s, "\b\b >\n");
+
+ vlib_counter_t valid, invalid;
+ vlib_get_combined_counter (&(sm->valid_counters), ls_mem->index, &valid);
+ vlib_get_combined_counter (&(sm->invalid_counters), ls_mem->index,
+ &invalid);
+ s =
+ format (s, "\tGood rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
+ valid.packets, valid.bytes);
+ s =
+ format (s, "\tBad rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
+ invalid.packets, invalid.bytes);
return s;
}
diff --git a/src/plugins/srv6-as/as.h b/src/plugins/srv6-as/as.h
index 8f059187151..5cb3e4cb784 100644
--- a/src/plugins/srv6-as/as.h
+++ b/src/plugins/srv6-as/as.h
@@ -26,21 +26,6 @@
#define DA_IP4 4
#define DA_IP6 6
-typedef struct
-{
- u16 msg_id_base; /**< API message ID base */
-
- vlib_main_t *vlib_main; /**< [convenience] vlib main */
- vnet_main_t *vnet_main; /**< [convenience] vnet main */
-
- dpo_type_t srv6_as_dpo_type; /**< DPO type */
-
- u32 srv6_localsid_behavior_id; /**< SRv6 LocalSID behavior number */
-
- u32 *sw_iface_localsid4; /**< Retrieve local SID from iface */
- u32 *sw_iface_localsid6; /**< Retrieve local SID from iface */
-} srv6_as_main_t;
-
/*
* This is the memory that will be stored per each localsid
* the user instantiates
@@ -57,8 +42,30 @@ typedef struct
ip6_address_t src_addr; /**< Source address to be restored */
ip6_address_t *sid_list; /**< SID list to be restored */
char *sid_list_str;
+
+ u32 index;
} srv6_as_localsid_t;
+typedef struct
+{
+ u16 msg_id_base; /**< API message ID base */
+
+ vlib_main_t *vlib_main; /**< [convenience] vlib main */
+ vnet_main_t *vnet_main; /**< [convenience] vnet main */
+
+ dpo_type_t srv6_as_dpo_type; /**< DPO type */
+
+ u32 srv6_localsid_behavior_id; /**< SRv6 LocalSID behavior number */
+
+ u32 *sw_iface_localsid4; /**< Retrieve local SID from iface */
+ u32 *sw_iface_localsid6; /**< Retrieve local SID from iface */
+
+ srv6_as_localsid_t **sids; /**< Pool of AS SID pointers */
+
+ vlib_combined_counter_main_t valid_counters; /**< Valid rewrite counters */
+ vlib_combined_counter_main_t invalid_counters;/**< Invalid rewrite counters */
+} srv6_as_main_t;
+
srv6_as_main_t srv6_as_main;
format_function_t format_srv6_as_localsid;
diff --git a/src/plugins/srv6-as/node.c b/src/plugins/srv6-as/node.c
index 4685c23dae0..0e5a16e5e7b 100644
--- a/src/plugins/srv6-as/node.c
+++ b/src/plugins/srv6-as/node.c
@@ -163,8 +163,6 @@ srv6_as_localsid_fn (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- u32 thread_index = vlib_get_thread_index ();
-
while (n_left_from > 0)
{
u32 n_left_to_next;
@@ -210,9 +208,10 @@ srv6_as_localsid_fn (vlib_main_t * vm,
SRV6_AS_LOCALSID_NEXT_ERROR) ?
&(sm->sr_ls_invalid_counters) :
&(sm->sr_ls_valid_counters)),
- thread_index, ls0 - sm->localsids,
- 1, vlib_buffer_length_in_chain (vm,
- b0));
+ vm->thread_index,
+ ls0 - sm->localsids, 1,
+ vlib_buffer_length_in_chain (vm,
+ b0));
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
@@ -344,6 +343,15 @@ srv6_as4_rewrite_fn (vlib_main_t * vm,
}
}
+ /* Increment per-SID AS rewrite counters */
+ vlib_increment_combined_counter (((next0 ==
+ SRV6_AS_LOCALSID_NEXT_ERROR) ?
+ &(sm->invalid_counters) :
+ &(sm->valid_counters)),
+ vm->thread_index, ls0_mem->index,
+ 1, vlib_buffer_length_in_chain (vm,
+ b0));
+
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
@@ -473,6 +481,15 @@ srv6_as6_rewrite_fn (vlib_main_t * vm,
}
}
+ /* Increment per-SID AS rewrite counters */
+ vlib_increment_combined_counter (((next0 ==
+ SRV6_AS_LOCALSID_NEXT_ERROR) ?
+ &(sm->invalid_counters) :
+ &(sm->valid_counters)),
+ vm->thread_index, ls0_mem->index,
+ 1, vlib_buffer_length_in_chain (vm,
+ b0));
+
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);