summaryrefslogtreecommitdiffstats
path: root/src/plugins/kubeproxy/kp_cli.c
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@enea.com>2017-12-19 16:13:44 +0100
committerDave Wallace <dwallacelf@gmail.com>2017-12-20 15:57:32 +0000
commit4c8a45491dc38a1075881be225df3be14801ffe9 (patch)
treeb77a69034616309a174a2c5e8b5eda0b74487088 /src/plugins/kubeproxy/kp_cli.c
parent7b929793feba7d966c34b1ddb31dc818174f3a57 (diff)
fix kubeproxy some tests
* NAT46: fix test cleanup, missing del keyword * NAT66: fix kube-proxy vip, is ipv6 * add some missing kp_put_writer_lock * wipe flowtable after each unit test * Add new cli api: "test kube-proxy flowtable flush" to flushes everything * Call this new cli function after the end of each kube-proxy unit test. * same as commit b3d1b203579226ca5136b9d6a2744577d07cfcc6 for the lb plugin Change-Id: I4146f44841328ec96eb66729e3bae3d40f33e4aa Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src/plugins/kubeproxy/kp_cli.c')
-rw-r--r--src/plugins/kubeproxy/kp_cli.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/kubeproxy/kp_cli.c b/src/plugins/kubeproxy/kp_cli.c
index 6a18834274e..43c5c51ae53 100644
--- a/src/plugins/kubeproxy/kp_cli.c
+++ b/src/plugins/kubeproxy/kp_cli.c
@@ -345,3 +345,38 @@ VLIB_CLI_COMMAND (kp_set_interface_nat4_command, static) = {
.short_help = "kube-proxy set interface nat4 in <intfc> [del]",
};
+static clib_error_t *
+kp_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();
+ kp_main_t *kpm = &kp_main;
+
+ for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) {
+ kp_hash_t *h = kpm->per_cpu[thread_index].sticky_ht;
+ if (h != NULL) {
+ kp_hash_bucket_t *b;
+ u32 i;
+ kp_hash_foreach_entry(h, b, i) {
+ vlib_refcount_add(&kpm->pod_refcount, thread_index, b->value[i], -1);
+ vlib_refcount_add(&kpm->pod_refcount, thread_index, 0, 1);
+ }
+
+ kp_hash_free(h);
+ kpm->per_cpu[thread_index].sticky_ht = NULL;
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * flush all kube-proxy flowtables
+ * This is indented for debug and unit-tests purposes only
+ */
+VLIB_CLI_COMMAND (kp_flowtable_flush_command, static) = {
+ .path = "test kube-proxy flowtable flush",
+ .short_help = "test kube-proxy flowtable flush",
+ .function = kp_flowtable_flush_command_fn,
+};