aboutsummaryrefslogtreecommitdiffstats
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 2c05ae21515..8146d4bb0c3 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -13,6 +13,7 @@
* limitations under the License.
*/
#include <stdint.h>
+#include <stdbool.h>
#include <vnet/policer/policer.h>
#include <vnet/policer/police_inlines.h>
#include <vnet/classify/vnet_classify.h>
@@ -133,6 +134,37 @@ policer_add_del (vlib_main_t *vm, u8 *name, qos_pol_cfg_params_st *cfg,
return 0;
}
+int
+policer_bind_worker (u8 *name, u32 worker, bool bind)
+{
+ vnet_policer_main_t *pm = &vnet_policer_main;
+ policer_read_response_type_st *policer;
+ 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]];
+
+ if (bind)
+ {
+ if (worker >= vlib_num_workers ())
+ {
+ return VNET_API_ERROR_INVALID_WORKER;
+ }
+
+ policer->thread_index = vlib_get_worker_thread_index (worker);
+ }
+ else
+ {
+ policer->thread_index = ~0;
+ }
+ return 0;
+}
+
u8 *
format_policer_instance (u8 * s, va_list * va)
{