aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/policer/policer.c
diff options
context:
space:
mode:
authorBrian Russell <brian@graphiant.com>2021-02-17 15:51:45 +0000
committerNeale Ranns <neale@graphiant.com>2021-02-19 10:46:58 +0000
commitb046830173a95b9f2d72865b3389174b7b7ff5d9 (patch)
tree83521ea1fd26e0f4de8d35d3ac0bfe28dcd0e754 /src/vnet/policer/policer.c
parent15c18e3e40d3bf754e5b6969c7478ad9f1d5e95b (diff)
policer: add api to configure input policing
Add a new API to apply a policer to an input interface. Type: improvement Signed-off-by: Brian Russell <brian@graphiant.com> Change-Id: Ie8aff9120149b63d85363a9a5afdcaed60a93700
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)
{