@@ -24,8 +24,10 @@
#include "dpdk.h"
#include "keepalive.h"
#include "lib/vswitch-idl.h"
+#include "openvswitch/dynamic-string.h"
#include "openvswitch/vlog.h"
#include "ovs-thread.h"
+#include "unixctl.h"
VLOG_DEFINE_THIS_MODULE(keepalive);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
@@ -279,6 +281,79 @@ ka_stats_run(void)
return ka_stats;
}
+static void
+ka_unixctl_pmd_health_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *ka_shm_)
+{
+ struct ds ds = DS_EMPTY_INITIALIZER;
+ ds_put_format(&ds,
+ "\t\tKeepalive status\n");
+
+ ds_put_format(&ds, "keepalive status : %s\n",
+ is_ka_enabled() ? "Enabled" : "Disabled");
+
+ if (!is_ka_enabled()) {
+ goto out;
+ }
+
+ ds_put_format(&ds, "keepalive interval: %"PRIu32" ms\n",
+ get_ka_interval());
+
+ struct keepalive_shm *ka_shm = (struct keepalive_shm *)ka_shm_;
+ if (!ka_shm) {
+ ds_put_format(&ds, "KeepAlive: Invalid shared memory block\n");
+ goto out;
+ }
+
+ ds_put_format(&ds,
+ "\nCORE\tSTATE\tLAST SEEN TIMESTAMP\n");
+
+ int datapath_failure = 0;
+ for (int idx_core = 0; idx_core < KEEPALIVE_MAXCORES; idx_core++) {
+ char *state = NULL;
+ if (ka_shm->core_state[idx_core] == KA_STATE_UNUSED ||
+ ka_shm->core_state[idx_core] == KA_STATE_SLEEP)
+ continue;
+
+ switch (ka_shm->core_state[idx_core]) {
+ case KA_STATE_ALIVE:
+ state = "ALIVE";
+ break;
+ case KA_STATE_MISSING:
+ state = "MISSING";
+ break;
+ case KA_STATE_DEAD:
+ state = "DEAD";
+ break;
+ case KA_STATE_GONE:
+ state = "GONE";
+ datapath_failure++;
+ break;
+ case KA_STATE_DOZING:
+ state = "DOZING";
+ break;
+ case KA_STATE_SLEEP:
+ state = "SLEEP";
+ break;
+ case KA_STATE_CHECK:
+ state = "HEALTH_CHECK_RUNNING";
+ break;
+ case KA_STATE_UNUSED:
+ break;
+ }
+ ds_put_format(&ds, "%2d\t%s\t%"PRIu64"\n",
+ idx_core, state, ka_shm->core_last_seen_times[idx_core]);
+ }
+
+ ds_put_format(&ds, "\n");
+ ds_put_format(&ds, "Datapath Status : %s\n",
+ datapath_failure ? "BAD" : "HEALTHY");
+
+out:
+ unixctl_command_reply(conn, ds_cstr(&ds));
+ ds_destroy(&ds);
+}
+
static int
ka_init__(void)
{
@@ -320,6 +395,9 @@ ka_init(const struct smap *ovs_other_config)
VLOG_INFO("OvS Keepalive disabled.");
}
+ unixctl_command_register("keepalive/pmd-health-show", "", 0, 0,
+ ka_unixctl_pmd_health_show, ka_shm);
+
ovsthread_once_done(&once_enable);
}
}
This commit adds support to query keepalive statistics stored in posix shared memory block. Datapath health status can be retrieved as follows: $ ovs-appctl keepalive/pmd-health-show Keepalive status keepalive status : Enabled keepalive interval: 1000 ms CORE STATE LAST SEEN TIMESTAMP 0 ALIVE 8632183482028293 1 ALIVE 8632183482028425 2 ALIVE 8632190191004294 3 ALIVE 8632183482028525 4 GONE 8612183482028117 5 ALIVE 8632190191004984 6 ALIVE 8632190191005713 7 ALIVE 8632190191006555 Datapath status : BAD Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> --- lib/keepalive.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)