This commit allows vswitchd thread to update the OVSDB with the datapath status along with the status of all registered PMD threads. The status can be monitored using ovsdb-client.
$ ovsdb-client monitor Open_vSwitch Open_vSwitch keepalive row action keepalive 7b746190-ee71-4dcc-becf-f8cb9c7cb909 old { "CORE_0"="ALIVE,9226457935188922" "CORE_1"="ALIVE,9226457935189628" "CORE_2"="ALIVE,9226457935189897" "CORE_3"="ALIVE,9226457935190127" "Datapath status"=HEALTHY} new { "CORE_0"="ALIVE,9226460230167364" "CORE_1"="ALIVE,9226460230168100" "CORE_2"="ALIVE,9226460230168905" "CORE_3"="ALIVE,9226460230169632" "Datapath status"=HEALTHY} 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 2d3f176..ff9ce2b 100644 --- a/lib/keepalive.c +++ b/lib/keepalive.c @@ -264,6 +264,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; +} + static int ka_init__(void) { diff --git a/lib/keepalive.h b/lib/keepalive.h index b4af936..6e0a1c6 100644 --- a/lib/keepalive.h +++ b/lib/keepalive.h @@ -66,5 +66,6 @@ bool is_ka_enabled(void); uint32_t get_ka_interval(void); int get_ka_init_status(void); void get_ka_stats(void); +struct smap *ka_stats_run(void); #endif /* keepalive.h */ diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index d40879d..ef62b6c 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); @@ -2689,6 +2691,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) { @@ -3037,6 +3062,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