Message ID | 24c7c4d36f973c34a8d0bd95c5cd1f3c9f2dc104.1588890027.git.lorenzo.bianconi@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,ovn] northd: add connection-status command for ovn{nb, sb}_idl | expand |
On Fri, May 8, 2020 at 3:52 AM Lorenzo Bianconi <lorenzo.bianconi@redhat.com> wrote: > 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> > Hi Lorenzo, I applied this patch to master with the below change. *** diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 8fc0a1b94..f09fdaffe 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -30,13 +30,11 @@ 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 char *result = "not connected"; const struct ovsdb_idl *idl = idl_; - if (ovsdb_idl_is_connected(idl)) { - result = "connected"; - } - unixctl_command_reply(conn, result); + unixctl_command_reply( + conn, + ovsdb_idl_is_connected(idl) ? "connected": "not connected"); } **** Thanks Numan --- > controller/ovn-controller.c | 16 +--------------- > lib/ovn-util.c | 13 +++++++++++++ > lib/ovn-util.h | 3 +++ > northd/ovn-northd.c | 6 ++++++ > 4 files changed, 23 insertions(+), 15 deletions(-) > > diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c > index c0a97a265..f32555f46 100644 > --- a/controller/ovn-controller.c > +++ b/controller/ovn-controller.c > @@ -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" > @@ -1775,7 +1774,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); > @@ -2439,19 +2438,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) > diff --git a/lib/ovn-util.c b/lib/ovn-util.c > index 3482edb8d..8fc0a1b94 100644 > --- a/lib/ovn-util.c > +++ b/lib/ovn-util.c > @@ -22,10 +22,23 @@ > #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 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 > 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 ec5f2cf5a..e13cf4d78 100644 > --- a/lib/ovn-util.h > +++ b/lib/ovn-util.h > @@ -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 */ > @@ -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) > diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c > index 83e6134b0..93bb57b54 100644 > --- a/northd/ovn-northd.c > +++ b/northd/ovn-northd.c > @@ -11821,6 +11821,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)); > @@ -12016,6 +12019,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; > -- > 2.26.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > >
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index c0a97a265..f32555f46 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -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" @@ -1775,7 +1774,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); @@ -2439,19 +2438,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) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 3482edb8d..8fc0a1b94 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -22,10 +22,23 @@ #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 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 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 ec5f2cf5a..e13cf4d78 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -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 */ @@ -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) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 83e6134b0..93bb57b54 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -11821,6 +11821,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)); @@ -12016,6 +12019,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;
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> --- controller/ovn-controller.c | 16 +--------------- lib/ovn-util.c | 13 +++++++++++++ lib/ovn-util.h | 3 +++ northd/ovn-northd.c | 6 ++++++ 4 files changed, 23 insertions(+), 15 deletions(-)