This commit allows vswitchd thread to update the OVSDB with the
status of all registered PMD threads. The status can be monitored
using ovsdb-client and the sample output is below.

$ ovsdb-client monitor Open_vSwitch Open_vSwitch keepalive

    row                            action keepalive
7b746190-ee71-4dcc-becf-f8cb9c7cb909 old  {
"pmd62"="ALIVE,0,9226457935188922"
                                            "pmd63"="ALIVE,1,1503333678618"
                                            "pmd64"="ALIVE,2,1503333678618"
                                            "pmd65"="ALIVE,3,1503333678618"}

                                     new  {
"pmd62"="ALIVE,0,9226460230167364"
                                            "pmd63"="ALIVE,1,1503333679619"
                                            "pmd64"="ALIVE,2,1503333679619"
                                            "pmd65"="ALIVE,3,1503333679619""}

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com>
---
 lib/keepalive.c   | 15 +++++++++++++++
 lib/keepalive.h   |  1 +
 vswitchd/bridge.c | 26 ++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/lib/keepalive.c b/lib/keepalive.c
index 9fd71b2..2497f00 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -280,6 +280,21 @@ get_ka_stats(void)
     ovs_mutex_unlock(&mutex);
 }
 
+struct smap *
+ka_stats_run(void)
+{
+    struct smap *ka_stats = NULL;
+
+    ovs_mutex_lock(&mutex);
+    if (keepalive_stats) {
+        ka_stats = keepalive_stats;
+        keepalive_stats = NULL;
+    }
+    ovs_mutex_unlock(&mutex);
+
+    return ka_stats;
+}
+
 /* Dispatch heartbeats. */
 void
 dispatch_heartbeats(void)
diff --git a/lib/keepalive.h b/lib/keepalive.h
index f5da460..34f1c13 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -101,6 +101,7 @@ int get_ka_init_status(void);
 int ka_alloc_portstats(unsigned, int);
 void ka_destroy_portstats(void);
 void get_ka_stats(void);
+struct smap *ka_stats_run(void);
 
 void dispatch_heartbeats(void);
 #endif /* keepalive.h */
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index aaa8d9b..9890c4f 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -286,6 +286,7 @@ static bool port_is_synthetic(const struct port *);
 
 static void reconfigure_system_stats(const struct ovsrec_open_vswitch *);
 static void run_system_stats(void);
+static void run_keepalive_stats(void);
 
 static void bridge_configure_mirrors(struct bridge *);
 static struct mirror *mirror_create(struct bridge *,
@@ -403,6 +404,7 @@ bridge_init(const char *remote)
 
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_cur_cfg);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_statistics);
+    ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_keepalive);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_datapath_types);
     ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_iface_types);
     ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_external_ids);
@@ -2686,6 +2688,29 @@ run_system_stats(void)
     }
 }
 
+void
+run_keepalive_stats(void)
+{
+    struct smap *ka_stats;
+    const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(idl);
+
+    ka_stats = ka_stats_run();
+    if (ka_stats && cfg) {
+        struct ovsdb_idl_txn *txn;
+        struct ovsdb_datum datum;
+
+        txn = ovsdb_idl_txn_create(idl);
+        ovsdb_datum_from_smap(&datum, ka_stats);
+        smap_destroy(ka_stats);
+        ovsdb_idl_txn_write(&cfg->header_, &ovsrec_open_vswitch_col_keepalive,
+                            &datum);
+        ovsdb_idl_txn_commit(txn);
+        ovsdb_idl_txn_destroy(txn);
+
+        free(ka_stats);
+    }
+}
+
 static const char *
 ofp12_controller_role_to_str(enum ofp12_controller_role role)
 {
@@ -3033,6 +3058,7 @@ bridge_run(void)
     run_stats_update();
     run_status_update();
     run_system_stats();
+    run_keepalive_stats();
 }
 
 void
-- 
2.4.11

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to