Skip to content

Commit

Permalink
controller, northd: move inactivity probe configuration to lib/
Browse files Browse the repository at this point in the history
ovn-northd and ovn-controller had similar code to configure inactivity
probe interval.  This patch moves common logic to lib/ovn-util module.

Signed-off-by: Vladislav Odintsov <odivlad@gmail.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
odivlad authored and numansiddique committed Mar 23, 2023
1 parent e3bc68c commit c3f577e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
8 changes: 2 additions & 6 deletions controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions lib/ovn-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
{
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/ovn-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
30 changes: 5 additions & 25 deletions northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit c3f577e

Please sign in to comment.