X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fsrv6-as%2Fas.c;h=5cd5226a4623b6cef652885d44d5edf86c09e49d;hb=151b32249245880fbe4060769b7edc02026fe566;hp=d027656b6fcde039a412e7db9d3e7a9c611587ee;hpb=ba7992aa62523d014b55802463fb3357c7099b70;p=vpp.git diff --git a/src/plugins/srv6-as/as.c b/src/plugins/srv6-as/as.c index d027656b6fc..5cd5226a462 100644 --- a/src/plugins/srv6-as/as.c +++ b/src/plugins/srv6-as/as.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #define SID_CREATE_IFACE_FEATURE_ERROR -1 @@ -211,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; } @@ -249,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); @@ -267,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) { @@ -294,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; } @@ -488,7 +516,7 @@ VNET_FEATURE_INIT (srv6_as6_rewrite, static) = VLIB_INIT_FUNCTION (srv6_as_init); VLIB_PLUGIN_REGISTER () = { - .version = "1.0", + .version = VPP_BUILD_VER, .description = "Static SRv6 proxy", }; /* *INDENT-ON* */