Acked-by: Mark Michelson <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
---
v3:
- change lflow_cache_get_stats() to populate an output string.
- document lflow-cache/show-stats command.
---
controller/lflow-cache.c | 27 +++++++++++++++++++++++++++
controller/lflow-cache.h | 2 ++
controller/ovn-controller.8.xml | 6 ++++++
controller/ovn-controller.c | 17 +++++++++++++++++
4 files changed, 52 insertions(+)
diff --git a/controller/lflow-cache.c b/controller/lflow-cache.c
index e12c69d..185f540 100644
--- a/controller/lflow-cache.c
+++ b/controller/lflow-cache.c
@@ -21,6 +21,12 @@
#include "lib/uuid.h"
#include "ovn/expr.h"
+static const char *lflow_cache_type_names[LCACHE_T_MAX] = {
+ [LCACHE_T_CONJ_ID] = "cache-conj-id",
+ [LCACHE_T_EXPR] = "cache-expr",
+ [LCACHE_T_MATCHES] = "cache-matches",
+};
+
struct lflow_cache {
struct hmap entries[LCACHE_T_MAX];
bool enabled;
@@ -103,6 +109,27 @@ lflow_cache_is_enabled(const struct lflow_cache *lc)
}
void
+lflow_cache_get_stats(const struct lflow_cache *lc, struct ds *output)
+{
+ if (!output) {
+ return;
+ }
+
+ if (!lc) {
+ ds_put_cstr(output, "Invalid arguments.");
+ return;
+ }
+
+ ds_put_format(output, "Enabled: %s\n",
+ lflow_cache_is_enabled(lc) ? "true" : "false");
+ for (size_t i = 0; i < LCACHE_T_MAX; i++) {
+ ds_put_format(output, "%-16s: %"PRIuSIZE"\n",
+ lflow_cache_type_names[i],
+ hmap_count(&lc->entries[i]));
+ }
+}
+
+void
lflow_cache_add_conj_id(struct lflow_cache *lc, const struct uuid *lflow_uuid,
uint32_t conj_id_ofs)
{
diff --git a/controller/lflow-cache.h b/controller/lflow-cache.h
index dce8341..03a64f6 100644
--- a/controller/lflow-cache.h
+++ b/controller/lflow-cache.h
@@ -18,6 +18,7 @@
#ifndef LFLOW_CACHE_H
#define LFLOW_CACHE_H 1
+#include "openvswitch/dynamic-string.h"
#include "openvswitch/hmap.h"
#include "openvswitch/uuid.h"
@@ -56,6 +57,7 @@ void lflow_cache_flush(struct lflow_cache *);
void lflow_cache_destroy(struct lflow_cache *);
void lflow_cache_enable(struct lflow_cache *, bool enabled);
bool lflow_cache_is_enabled(const struct lflow_cache *);
+void lflow_cache_get_stats(const struct lflow_cache *, struct ds *output);
void lflow_cache_add_conj_id(struct lflow_cache *,
const struct uuid *lflow_uuid,
diff --git a/controller/ovn-controller.8.xml b/controller/ovn-controller.8.xml
index 23ceb86..1fa7af4 100644
--- a/controller/ovn-controller.8.xml
+++ b/controller/ovn-controller.8.xml
@@ -549,6 +549,12 @@
<dd>
Flushes the <code>ovn-controller</code> logical flow cache.
</dd>
+
+ <dt><code>lflow-cache/show-stats</code></dt>
+ <dd>
+ Displays logical flow cache statistics: enabled/disabled, per cache
+ type entry counts.
+ </dd>
</dl>
</p>
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index ae458f0..c77cfcd 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -82,6 +82,7 @@ static unixctl_cb_func debug_pause_execution;
static unixctl_cb_func debug_resume_execution;
static unixctl_cb_func debug_status_execution;
static unixctl_cb_func lflow_cache_flush_cmd;
+static unixctl_cb_func lflow_cache_show_stats_cmd;
static unixctl_cb_func debug_delay_nb_cfg_report;
#define DEFAULT_BRIDGE_NAME "br-int"
@@ -2666,6 +2667,9 @@ main(int argc, char *argv[])
unixctl_command_register("flush-lflow-cache", "[deprecated]", 0, 0,
lflow_cache_flush_cmd,
&flow_output_data->pd);
+ unixctl_command_register("lflow-cache/show-stats", "", 0, 0,
+ lflow_cache_show_stats_cmd,
+ &flow_output_data->pd);
bool reset_ovnsb_idl_min_index = false;
unixctl_command_register("sb-cluster-state-reset", "", 0, 0,
@@ -3274,6 +3278,19 @@ lflow_cache_flush_cmd(struct unixctl_conn *conn
OVS_UNUSED,
}
static void
+lflow_cache_show_stats_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *arg_)
+{
+ struct flow_output_persistent_data *fo_pd = arg_;
+ struct lflow_cache *lc = fo_pd->lflow_cache;
+ struct ds ds = DS_EMPTY_INITIALIZER;
+
+ lflow_cache_get_stats(lc, &ds);
+ unixctl_command_reply(conn, ds_cstr(&ds));
+ ds_destroy(&ds);
+}
+
+static void
cluster_state_reset_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_reset_)
{
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev