summaryrefslogtreecommitdiffstats
path: root/src/vnet/policer/policer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/policer/policer.c')
-rw-r--r--src/vnet/policer/policer.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index fb2ce7598fa..678e5884cdd 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -165,6 +165,38 @@ policer_bind_worker (u8 *name, u32 worker, bool bind)
return 0;
}
+int
+policer_input (u8 *name, u32 sw_if_index, bool apply)
+{
+ vnet_policer_main_t *pm = &vnet_policer_main;
+ policer_t *policer;
+ u32 policer_index;
+ uword *p;
+
+ p = hash_get_mem (pm->policer_index_by_name, name);
+ if (p == 0)
+ {
+ return VNET_API_ERROR_NO_SUCH_ENTRY;
+ }
+
+ policer = &pm->policers[p[0]];
+ policer_index = policer - pm->policers;
+
+ if (apply)
+ {
+ vec_validate (pm->policer_index_by_sw_if_index, sw_if_index);
+ pm->policer_index_by_sw_if_index[sw_if_index] = policer_index;
+ }
+ else
+ {
+ pm->policer_index_by_sw_if_index[sw_if_index] = ~0;
+ }
+
+ vnet_feature_enable_disable ("device-input", "policer-input", sw_if_index,
+ apply, 0, 0);
+ return 0;
+}
+
u8 *
format_policer_instance (u8 * s, va_list * va)
{