aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lb/cli.c
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@enea.com>2017-10-30 15:44:31 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-31 08:00:36 +0000
commitb3d1b203579226ca5136b9d6a2744577d07cfcc6 (patch)
tree3831e16e224a4e3e0dc229b03675b6b684ac2b5b /src/plugins/lb/cli.c
parent5611ca711cd37058177078eb4591bb9e7338675d (diff)
lb plugin tests - wipe flowtable after each unit test
Add new cli api: "test lb flowtable flush" which flushes everything. Call this new cli function after the end of each lb unit test. Change-Id: I71d04a7bfba398f7d4dd9cc3ed24bba786943663 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src/plugins/lb/cli.c')
-rw-r--r--src/plugins/lb/cli.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/lb/cli.c b/src/plugins/lb/cli.c
index f6d65201448..a5a87fccc5f 100644
--- a/src/plugins/lb/cli.c
+++ b/src/plugins/lb/cli.c
@@ -273,3 +273,41 @@ VLIB_CLI_COMMAND (lb_show_vips_command, static) =
.short_help = "show lb vips [verbose]",
.function = lb_show_vips_command_fn,
};
+
+static clib_error_t *
+lb_flowtable_flush_command_fn (vlib_main_t * vm,
+ unformat_input_t * input, vlib_cli_command_t * cmd)
+{
+ u32 thread_index;
+ vlib_thread_main_t *tm = vlib_get_thread_main();
+ lb_main_t *lbm = &lb_main;
+
+ for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) {
+ lb_hash_t *h = lbm->per_cpu[thread_index].sticky_ht;
+ if (h != NULL) {
+ u32 i;
+ lb_hash_bucket_t *b;
+
+ lb_hash_foreach_entry(h, b, i) {
+ vlib_refcount_add(&lbm->as_refcount, thread_index, b->value[i], -1);
+ vlib_refcount_add(&lbm->as_refcount, thread_index, 0, 1);
+ }
+
+ lb_hash_free(h);
+ lbm->per_cpu[thread_index].sticky_ht = 0;
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * flush all lb flowtables
+ * This is indented for debug and unit-tests purposes only
+ */
+VLIB_CLI_COMMAND (lb_flowtable_flush_command, static) =
+{
+ .path = "test lb flowtable flush",
+ .short_help = "test lb flowtable flush",
+ .function = lb_flowtable_flush_command_fn,
+};