[ovs-dev,v3,12/19] keepalive: Add support to query keepalive status.

Message ID 1501834086-31829-13-git-send-email-bhanuprakash.bodireddy@intel.com
State Superseded
Headers show

Commit Message

Bodireddy, Bhanuprakash Aug. 4, 2017, 8:07 a.m.
This commit adds support to query if keepalive status is
enabled/disabled.

  $ ovs-appctl keepalive/status
    keepAlive Status: Enabled

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/keepalive.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch

diff --git a/lib/keepalive.c b/lib/keepalive.c
index a2f0314..43f8f11 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -429,6 +429,19 @@  out:
     ds_destroy(&ds);
 }
 
+static void
+ka_unixctl_status(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                  const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+    struct ds ds = DS_EMPTY_INITIALIZER;
+
+    ds_put_format(&ds, "keepAlive Status: %s",
+                  ka_is_enabled() ? "Enabled" : "Disabled");
+
+    unixctl_command_reply(conn, ds_cstr(&ds));
+    ds_destroy(&ds);
+}
+
 static int
 ka_init__(void)
 {
@@ -473,6 +486,8 @@  ka_init(const struct smap *ovs_other_config)
 
         unixctl_command_register("keepalive/pmd-health-show", "", 0, 0,
                                   ka_unixctl_pmd_health_show, ka_info);
+        unixctl_command_register("keepalive/status", "", 0, 0,
+                                      ka_unixctl_status, NULL);
 
         ovsthread_once_done(&once_enable);
     }