ovn-northd and ovn-controller had similar code to configure inactivity
probe interval. This patch moves common logic to lib/ovn-util module.
---
controller/ovn-controller.c | 8 ++------
lib/ovn-util.c | 22 ++++++++++++++++++++++
lib/ovn-util.h | 4 ++++
northd/ovn-northd.c | 30 +++++-------------------------
4 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 7dcbfd252..2c09551cf 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -104,7 +104,6 @@ static unixctl_cb_func debug_ignore_startup_delay;
#define DEFAULT_BRIDGE_NAME "br-int"
#define DEFAULT_DATAPATH "system"
-#define DEFAULT_PROBE_INTERVAL_MSEC 5000
#define OFCTRL_DEFAULT_PROBE_INTERVAL_SEC 0
#define CONTROLLER_LOOP_STOPWATCH_NAME "flow-generation"
@@ -595,13 +594,10 @@ update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl
*ovnsb_idl,
ovsdb_idl_set_remote(ovnsb_idl, remote, true);
/* Set probe interval, based on user configuration and the remote. */
- int default_interval = (remote && !stream_or_pstream_needs_probes(remote)
- ? 0 : DEFAULT_PROBE_INTERVAL_MSEC);
int interval =
get_chassis_external_id_value_int(
- &cfg->external_ids, chassis_id,
- "ovn-remote-probe-interval", default_interval);
- ovsdb_idl_set_probe_interval(ovnsb_idl, interval);
+ &cfg->external_ids, chassis_id, "ovn-remote-probe-interval", -1);
+ set_idl_probe_interval(ovnsb_idl, remote, interval);
bool monitor_all =
get_chassis_external_id_value_bool(
diff --git a/lib/ovn-util.c b/lib/ovn-util.c
index 561e82093..13ae0dcce 100644
--- a/lib/ovn-util.c
+++ b/lib/ovn-util.c
@@ -27,12 +27,16 @@
#include "ovn-dirs.h"
#include "ovn-nb-idl.h"
#include "ovn-sb-idl.h"
+#include "ovsdb-idl.h"
#include "socket-util.h"
+#include "stream.h"
#include "svec.h"
#include "unixctl.h"
VLOG_DEFINE_THIS_MODULE(ovn_util);
+#define DEFAULT_PROBE_INTERVAL_MSEC 5000
+
void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_)
{
@@ -43,6 +47,24 @@ void ovn_conn_show(struct unixctl_conn *conn, int argc
OVS_UNUSED,
ovsdb_idl_is_connected(idl) ? "connected": "not connected");
}
+/* Set inactivity probe interval for 'idl' and 'remote' to 'interval'.
+ * If 'interval' < 0 (no preference from daemon settings), set it to 5000ms;
+ * if 'remote' needs probing, disable otherwise.
+ * 'interval' value of 0 disables probing.
+ */
+void set_idl_probe_interval(struct ovsdb_idl *idl, const char *remote,
+ int interval)
+{
+ if (interval < 0) {
+ interval = (remote && !stream_or_pstream_needs_probes(remote)
+ ? 0 : DEFAULT_PROBE_INTERVAL_MSEC);
+ } else if (interval > 0 && interval < 1000) {
+ interval = 1000;
+ }
+
+ ovsdb_idl_set_probe_interval(idl, interval);
+}
+
static void
add_ipv4_netaddr(struct lport_addresses *laddrs, ovs_be32 addr,
unsigned int plen)
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index a1a418a24..7cf861dbc 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -16,6 +16,7 @@
#ifndef OVN_UTIL_H
#define OVN_UTIL_H 1
+#include "ovsdb-idl.h"
#include "lib/packets.h"
#include "include/ovn/version.h"
@@ -140,6 +141,9 @@ uint32_t ovn_logical_flow_hash_datapath(const struct uuid
*logical_datapath,
void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_);
+void set_idl_probe_interval(struct ovsdb_idl *idl, const char *remote,
+ int interval);
+
#define OVN_MAX_DP_KEY ((1u << 24) - 1)
#define OVN_MAX_DP_GLOBAL_NUM ((1u << 16) - 1)
#define OVN_MIN_DP_KEY_LOCAL 1
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 5f895b053..116b6e801 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -71,11 +71,6 @@ static const char *ssl_private_key_file;
static const char *ssl_certificate_file;
static const char *ssl_ca_cert_file;
-/* Default probe interval for NB and SB DB connections. */
-#define DEFAULT_PROBE_INTERVAL_MSEC 5000
-static int northd_probe_interval_nb = 0;
-static int northd_probe_interval_sb = 0;
-
static const char *rbac_chassis_auth[] =
{"name"};
static const char *rbac_chassis_update[] =
@@ -684,20 +679,6 @@ update_ssl_config(void)
}
}
-static int
-get_probe_interval(const char *db, const struct nbrec_nb_global *nb)
-{
- int default_interval = (db && !stream_or_pstream_needs_probes(db)
- ? 0 : DEFAULT_PROBE_INTERVAL_MSEC);
- int interval = smap_get_int(&nb->options,
- "northd_probe_interval", default_interval);
-
- if (interval > 0 && interval < 1000) {
- interval = 1000;
- }
- return interval;
-}
-
static struct ovsdb_idl_txn *
run_idl_loop(struct ovsdb_idl_loop *idl_loop, const char *name)
{
@@ -1014,14 +995,13 @@ main(int argc, char *argv[])
const struct nbrec_nb_global *nb =
nbrec_nb_global_first(ovnnb_idl_loop.idl);
/* Update the probe interval. */
+ int interval = -1;
if (nb) {
- northd_probe_interval_nb = get_probe_interval(ovnnb_db, nb);
- northd_probe_interval_sb = get_probe_interval(ovnsb_db, nb);
+ interval = smap_get_int(&nb->options, "northd_probe_interval",
+ interval);
}
- ovsdb_idl_set_probe_interval(ovnnb_idl_loop.idl,
- northd_probe_interval_nb);
- ovsdb_idl_set_probe_interval(ovnsb_idl_loop.idl,
- northd_probe_interval_sb);
+ set_idl_probe_interval(ovnnb_idl_loop.idl, ovnnb_db, interval);
+ set_idl_probe_interval(ovnsb_idl_loop.idl, ovnsb_db, interval);
if (reset_ovnsb_idl_min_index) {
VLOG_INFO("Resetting southbound database cluster state");
--
2.36.1
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev