Skip to content

Commit

Permalink
northd: add connection-status command for ovn{nb, sb}_idl.
Browse files Browse the repository at this point in the history
Move ovn_controller_conn_show in ovn-util.c and rename it in
ovn_conn_show in order to be reused adding connection-status command for
ovn-northd.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
LorenzoBianconi authored and numansiddique committed May 28, 2020
1 parent 526f920 commit d5a903f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
16 changes: 1 addition & 15 deletions controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static unixctl_cb_func ovn_controller_exit;
static unixctl_cb_func ct_zone_list;
static unixctl_cb_func extend_table_list;
static unixctl_cb_func inject_pkt;
static unixctl_cb_func ovn_controller_conn_show;
static unixctl_cb_func engine_recompute_cmd;

#define DEFAULT_BRIDGE_NAME "br-int"
Expand Down Expand Up @@ -1776,7 +1775,7 @@ main(int argc, char *argv[])
ovsdb_idl_set_leader_only(ovnsb_idl_loop.idl, false);

unixctl_command_register("connection-status", "", 0, 0,
ovn_controller_conn_show, ovnsb_idl_loop.idl);
ovn_conn_show, ovnsb_idl_loop.idl);

struct ovsdb_idl_index *sbrec_chassis_by_name
= chassis_index_create(ovnsb_idl_loop.idl);
Expand Down Expand Up @@ -2442,19 +2441,6 @@ inject_pkt(struct unixctl_conn *conn, int argc OVS_UNUSED,
pending_pkt->flow_s = xstrdup(argv[1]);
}

static void
ovn_controller_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_)
{
const char *result = "not connected";
const struct ovsdb_idl *idl = idl_;

if (ovsdb_idl_is_connected(idl)) {
result = "connected";
}
unixctl_command_reply(conn, result);
}

static void
engine_recompute_cmd(struct unixctl_conn *conn OVS_UNUSED, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *arg OVS_UNUSED)
Expand Down
11 changes: 11 additions & 0 deletions lib/ovn-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@
#include "openvswitch/ofp-parse.h"
#include "ovn-nb-idl.h"
#include "ovn-sb-idl.h"
#include "unixctl.h"
#include <ctype.h>

VLOG_DEFINE_THIS_MODULE(ovn_util);

void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_)
{
const struct ovsdb_idl *idl = idl_;

unixctl_command_reply(
conn,
ovsdb_idl_is_connected(idl) ? "connected": "not connected");
}

static void
add_ipv4_netaddr(struct lport_addresses *laddrs, ovs_be32 addr,
unsigned int plen)
Expand Down
3 changes: 3 additions & 0 deletions lib/ovn-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct uuid;
struct eth_addr;
struct sbrec_port_binding;
struct sbrec_datapath_binding;
struct unixctl_conn;

struct ipv4_netaddr {
ovs_be32 addr; /* 192.168.10.123 */
Expand Down Expand Up @@ -97,6 +98,8 @@ uint32_t ovn_logical_flow_hash(const struct uuid *logical_datapath,
uint16_t priority,
const char *match, const char *actions);
bool datapath_is_switch(const struct sbrec_datapath_binding *);
void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[] OVS_UNUSED, void *idl_);

#define OVN_MAX_DP_KEY ((1u << 24) - 1)
#define OVN_MAX_DP_GLOBAL_NUM ((1u << 16) - 1)
Expand Down
6 changes: 6 additions & 0 deletions northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11795,6 +11795,9 @@ main(int argc, char *argv[])
ovsdb_idl_omit_alert(ovnnb_idl_loop.idl, &nbrec_nb_global_col_sb_cfg);
ovsdb_idl_omit_alert(ovnnb_idl_loop.idl, &nbrec_nb_global_col_hv_cfg);

unixctl_command_register("nb-connection-status", "", 0, 0,
ovn_conn_show, ovnnb_idl_loop.idl);

/* We want to detect only selected changes to the ovn-sb db. */
struct ovsdb_idl_loop ovnsb_idl_loop = OVSDB_IDL_LOOP_INITIALIZER(
ovsdb_idl_create(ovnsb_db, &sbrec_idl_class, false, true));
Expand Down Expand Up @@ -11990,6 +11993,9 @@ main(int argc, char *argv[])
struct ovsdb_idl_index *sbrec_ip_mcast_by_dp
= ip_mcast_index_create(ovnsb_idl_loop.idl);

unixctl_command_register("sb-connection-status", "", 0, 0,
ovn_conn_show, ovnsb_idl_loop.idl);

/* Main loop. */
exiting = false;
state.had_lock = false;
Expand Down

0 comments on commit d5a903f

Please sign in to comment.