summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/policer/policer.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index cd754e29be9..5a7b7711661 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -33,13 +33,26 @@ policer_add_del (vlib_main_t * vm,
if (is_add == 0)
{
+ /* free policer config and template */
if (p == 0)
{
vec_free (name);
return clib_error_return (0, "No such policer configuration");
}
+ pool_put_index (pm->configs, p[0]);
+ pool_put_index (pm->policer_templates, p[0]);
hash_unset_mem (pm->policer_config_by_name, name);
+
+ /* free policer */
+ p = hash_get_mem (pm->policer_index_by_name, name);
+ if (p == 0)
+ {
+ vec_free (name);
+ return clib_error_return (0, "No such policer");
+ }
+ pool_put_index (pm->policers, p[0]);
hash_unset_mem (pm->policer_index_by_name, name);
+
vec_free (name);
return 0;
}
@@ -500,6 +513,27 @@ VLIB_CLI_COMMAND (show_policer_command, static) = {
};
/* *INDENT-ON* */
+static clib_error_t *
+show_policer_pools_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ vnet_policer_main_t *pm = &vnet_policer_main;
+
+ vlib_cli_output (vm, "pool sizes: configs=%d templates=%d policers=%d",
+ pool_elts (pm->configs),
+ pool_elts (pm->policer_templates),
+ pool_elts (pm->policers));
+ return 0;
+}
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_policer_pools_command, static) = {
+ .path = "show policer pools",
+ .short_help = "show policer pools",
+ .function = show_policer_pools_command_fn,
+};
+/* *INDENT-ON* */
+
clib_error_t *
policer_init (vlib_main_t * vm)
{