Message ID | 1465501348-40737-1-git-send-email-nghosh@us.ibm.com |
---|---|
State | Superseded |
Headers | show |
"dev" <dev-bounces@openvswitch.org> wrote on 06/09/2016 02:42:28 PM: > From: Nirapada Ghosh/San Jose/IBM@IBMUS > To: dev@openvswitch.org > Date: 06/09/2016 02:42 PM > Subject: [ovs-dev] [PATCH V7] ovn-controller: reload configured SB probe timer > Sent by: "dev" <dev-bounces@openvswitch.org> > > The probe timer between ovn-controller and OVN Southbound > can be configured using ovn-vsctl command, but that is not > effective on the fly. In other words, ovn-controller has > to be restarted to use that probe_timer value, this patch > takes care of that. > > This change has been tested putting logs in several places like in > ovn-controller.c, lib/rconn.c to make sure the right probe_timer > values are in effect. > > Signed-off-by: Nirapada Ghosh <nghosh@us.ibm.com> > > --- One nit: when I apply this patch, I get a whitespace error > ovn/controller/ovn-controller.c | 57 ++++++++++++++++++ > +---------------------- > 1 file changed, 27 insertions(+), 30 deletions(-) > > diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c > index 356a94b..aa3ad2c 100644 > --- a/ovn/controller/ovn-controller.c > +++ b/ovn/controller/ovn-controller.c > @@ -60,7 +60,10 @@ static unixctl_cb_func ovn_controller_exit; > static unixctl_cb_func ct_zone_list; > > #define DEFAULT_BRIDGE_NAME "br-int" > +#define DEFAULT_PROBE_INTERVAL_MSEC 5000 > > +static void update_probe_interval(const struct ovsrec_open_vswitch *cfg, > + const struct ovsdb_idl *sb_idl); Nit: Please fix the indentation of the continuation line > static void parse_options(int argc, char *argv[]); > OVS_NO_RETURN static void usage(void); > > @@ -228,32 +231,6 @@ get_ovnsb_remote(struct ovsdb_idl *ovs_idl) > } > } > > -/* Retrieves the OVN Southbound remote's json session probe interval from the > - * "external-ids:ovn-remote-probe-interval" key in 'ovs_idl' and returns it. > - * > - * This function must be called after get_ovnsb_remote(). */ > -static bool > -get_ovnsb_remote_probe_interval(struct ovsdb_idl *ovs_idl, int *value) > -{ > - const struct ovsrec_open_vswitch *cfg = > ovsrec_open_vswitch_first(ovs_idl); > - if (!cfg) { > - return false; > - } > - > - const char *probe_interval = > - smap_get(&cfg->external_ids, "ovn-remote-probe-interval"); > - if (probe_interval) { > - if (str_to_int(probe_interval, 10, value)) { > - return true; > - } > - > - VLOG_WARN("Invalid value for OVN remote probe interval: %s", > - probe_interval); > - } > - > - return false; > -} > - > static void > update_ct_zones(struct sset *lports, struct hmap *patched_datapaths, > struct simap *ct_zones, unsigned long *ct_zone_bitmap) > @@ -385,10 +362,12 @@ main(int argc, char *argv[]) > ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class, true, true)); > ovsdb_idl_get_initial_snapshot(ovnsb_idl_loop.idl); > > - int probe_interval = 0; > - if (get_ovnsb_remote_probe_interval(ovs_idl_loop.idl, &probe_interval)) { > - ovsdb_idl_set_probe_interval(ovnsb_idl_loop.idl, probe_interval); > - } > + const struct ovsrec_open_vswitch *cfg = > + ovsrec_open_vswitch_first(ovs_idl_loop.idl); > + if (!cfg) { > + return false; > + } Wait, I'm exiting the main loop if the open fails? I don't think I like that... > + update_probe_interval(cfg, ovnsb_idl_loop.idl); Why is this call here, when I'm making the same call in each loop below? > > /* Initialize connection tracking zones. */ > struct simap ct_zones = SIMAP_INITIALIZER(&ct_zones); > @@ -417,6 +396,7 @@ main(int argc, char *argv[]) > .ovnsb_idl = ovnsb_idl_loop.idl, > .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), > }; > + update_probe_interval(cfg, ovnsb_idl_loop.idl); I'm wondering if setting cfg to NULL initially and then replacing this with something like the following wouldn't be cleaner: if (!cfg) { cfg = ovsrec_open_vswitch_first(ovs_idl_loop.idl); } if (cfg) { update_probe_interval(cfg, ovnsb_idl_loop.idl); } > /* Contains "struct local_datpath" nodes whose hash values are the > * tunnel_key of datapaths with at least one local port binding. */ > @@ -657,3 +637,20 @@ ct_zone_list(struct unixctl_conn *conn, int > argc OVS_UNUSED, > unixctl_command_reply(conn, ds_cstr(&ds)); > ds_destroy(&ds); > } > + > +/* This function will set the SB probe timer value for the session. > + * Arguments: > + * 'cfg': Holding the external-id values read from southbound DB. > + * 'sb_idl': pointer to the ovs_idl connection to OVN southbound. > + */ > +static void > +update_probe_interval(const struct ovsrec_open_vswitch *cfg, > + const struct ovsdb_idl *sb_idl) > +{ > + int interval = smap_get_int(&cfg->external_ids, > + "ovn-remote-probe-interval", 0); > + ovsdb_idl_set_probe_interval(sb_idl, (interval >= 0 > + ? interval > + : DEFAULT_PROBE_INTERVAL_MSEC)); > +} > + Ryan Moats
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 356a94b..aa3ad2c 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -60,7 +60,10 @@ static unixctl_cb_func ovn_controller_exit; static unixctl_cb_func ct_zone_list; #define DEFAULT_BRIDGE_NAME "br-int" +#define DEFAULT_PROBE_INTERVAL_MSEC 5000 +static void update_probe_interval(const struct ovsrec_open_vswitch *cfg, + const struct ovsdb_idl *sb_idl); static void parse_options(int argc, char *argv[]); OVS_NO_RETURN static void usage(void); @@ -228,32 +231,6 @@ get_ovnsb_remote(struct ovsdb_idl *ovs_idl) } } -/* Retrieves the OVN Southbound remote's json session probe interval from the - * "external-ids:ovn-remote-probe-interval" key in 'ovs_idl' and returns it. - * - * This function must be called after get_ovnsb_remote(). */ -static bool -get_ovnsb_remote_probe_interval(struct ovsdb_idl *ovs_idl, int *value) -{ - const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl); - if (!cfg) { - return false; - } - - const char *probe_interval = - smap_get(&cfg->external_ids, "ovn-remote-probe-interval"); - if (probe_interval) { - if (str_to_int(probe_interval, 10, value)) { - return true; - } - - VLOG_WARN("Invalid value for OVN remote probe interval: %s", - probe_interval); - } - - return false; -} - static void update_ct_zones(struct sset *lports, struct hmap *patched_datapaths, struct simap *ct_zones, unsigned long *ct_zone_bitmap) @@ -385,10 +362,12 @@ main(int argc, char *argv[]) ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class, true, true)); ovsdb_idl_get_initial_snapshot(ovnsb_idl_loop.idl); - int probe_interval = 0; - if (get_ovnsb_remote_probe_interval(ovs_idl_loop.idl, &probe_interval)) { - ovsdb_idl_set_probe_interval(ovnsb_idl_loop.idl, probe_interval); - } + const struct ovsrec_open_vswitch *cfg = + ovsrec_open_vswitch_first(ovs_idl_loop.idl); + if (!cfg) { + return false; + } + update_probe_interval(cfg, ovnsb_idl_loop.idl); /* Initialize connection tracking zones. */ struct simap ct_zones = SIMAP_INITIALIZER(&ct_zones); @@ -417,6 +396,7 @@ main(int argc, char *argv[]) .ovnsb_idl = ovnsb_idl_loop.idl, .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), }; + update_probe_interval(cfg, ovnsb_idl_loop.idl); /* Contains "struct local_datpath" nodes whose hash values are the * tunnel_key of datapaths with at least one local port binding. */ @@ -657,3 +637,20 @@ ct_zone_list(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, ds_cstr(&ds)); ds_destroy(&ds); } + +/* This function will set the SB probe timer value for the session. + * Arguments: + * 'cfg': Holding the external-id values read from southbound DB. + * 'sb_idl': pointer to the ovs_idl connection to OVN southbound. + */ +static void +update_probe_interval(const struct ovsrec_open_vswitch *cfg, + const struct ovsdb_idl *sb_idl) +{ + int interval = smap_get_int(&cfg->external_ids, + "ovn-remote-probe-interval", 0); + ovsdb_idl_set_probe_interval(sb_idl, (interval >= 0 + ? interval + : DEFAULT_PROBE_INTERVAL_MSEC)); +} +
The probe timer between ovn-controller and OVN Southbound can be configured using ovn-vsctl command, but that is not effective on the fly. In other words, ovn-controller has to be restarted to use that probe_timer value, this patch takes care of that. This change has been tested putting logs in several places like in ovn-controller.c, lib/rconn.c to make sure the right probe_timer values are in effect. Signed-off-by: Nirapada Ghosh <nghosh@us.ibm.com> --- ovn/controller/ovn-controller.c | 57 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-)