Re: [ovs-dev] [PATCH V3] Configure ovn-controller SB probe_timer on the fly and disable other unix domain socket based connections

2016-04-11 Thread Ben Pfaff
Please limit the subject to about 65 characters.  This is mentioned in
CONTRIBUTING.md.

Please don't indent the commit message.

On Fri, Apr 01, 2016 at 03:28:11PM -0700, ngh...@us.ibm.com wrote:
> Configure ovn-controller SB probe_timer on the fly and disable other unix 
> domain socket based connections
> 
> There are four sessions established from ovn-controller to the following:
> OVN Southbound — JSONRPC based
> Local ovsdb — JSONRPC based
> Local vswitchd — openflow based from ofctrl
> Local vswitchd — openflow based from pinctrl
> 
> All of these sessions have their own probe_interval, and currently only 
> one
> [SB] of them can be configured using ovn-vsctl command, and that is not
> effective on the fly —in other words, ovn-controller has to be restarted 
> to
> use that probe_timer value. For the rest, probe timers need to be disabled
> as they are over unix domain socket. ovsdb was already doing that.
> 
> This patch will take care of disabling probe timer for ofctrl and pinctrl,
> and make sure SB timer changes take effect on the fly.
> 
> Using NB database’s external-id, SB timer settings are stored, here is 
> how to
> set it:
> ovs-vsctl --no-wait set open_vswitch . \
>external-ids:ovn-remote-probe-interval=7000
> 
> Signed-off-by: Nirapada Ghosh 

This function should not exist.  Instead, use the existing function
stream_or_pstream_needs_probes():
> +/* For unix domain socket, target starts with "unix:", the following 
> function returns
> + * True when the argument indicates that it is unix domain socket
> + */
> +static inline bool
> +unix_domain_socket(const char *target)
> +{
> +   return (!(strncmp(target,"unix:",5)));
> +}
> +

There is no need log for this, it just pollutes the log:

> +VLOG_INFO("connected with probe-interval %d", rc->probe_interval);

Please read CodingStyle.md carefully and adjust the code that you write
to honor the style described there.  I see several inconsistencies that
distract the reader.

Thanks,

Ben.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH V3] Configure ovn-controller SB probe_timer on the fly and disable other unix domain socket based connections

2016-04-01 Thread nghosh
Configure ovn-controller SB probe_timer on the fly and disable other unix 
domain socket based connections

There are four sessions established from ovn-controller to the following:
OVN Southbound — JSONRPC based
Local ovsdb — JSONRPC based
Local vswitchd — openflow based from ofctrl
Local vswitchd — openflow based from pinctrl

All of these sessions have their own probe_interval, and currently only one
[SB] of them can be configured using ovn-vsctl command, and that is not
effective on the fly —in other words, ovn-controller has to be restarted to
use that probe_timer value. For the rest, probe timers need to be disabled
as they are over unix domain socket. ovsdb was already doing that.

This patch will take care of disabling probe timer for ofctrl and pinctrl,
and make sure SB timer changes take effect on the fly.

Using NB database’s external-id, SB timer settings are stored, here is how 
to
set it:
ovs-vsctl --no-wait set open_vswitch . \
   external-ids:ovn-remote-probe-interval=7000

Signed-off-by: Nirapada Ghosh 

diff --git a/lib/rconn.c b/lib/rconn.c
index 6de4c63..3ebe0e8 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -324,6 +324,15 @@ rconn_get_probe_interval(const struct rconn *rc)
 return rc->probe_interval;
 }
 
+/* For unix domain socket, target starts with "unix:", the following function 
returns
+ * True when the argument indicates that it is unix domain socket
+ */
+static inline bool
+unix_domain_socket(const char *target)
+{
+   return (!(strncmp(target,"unix:",5)));
+}
+
 /* Drops any existing connection on 'rc', then sets up 'rc' to connect to
  * 'target' and reconnect as needed.  'target' should be a remote OpenFlow
  * target in a form acceptable to vconn_open().
@@ -339,6 +348,9 @@ rconn_connect(struct rconn *rc, const char *target, const 
char *name)
 rconn_disconnect__(rc);
 rconn_set_target__(rc, target, name);
 rc->reliable = true;
+if (unix_domain_socket(target)) {
+   rc->probe_interval =0; /* we do not need probe_timer for unix domain 
sockets */
+}
 reconnect(rc);
 ovs_mutex_unlock(&rc->mutex);
 }
@@ -461,6 +473,7 @@ reconnect(struct rconn *rc)
 if (!retval) {
 rc->backoff_deadline = time_now() + rc->backoff;
 state_transition(rc, S_CONNECTING);
+VLOG_INFO("connected with probe-interval %d", rc->probe_interval);
 } else {
 VLOG_WARN("%s: connection failed (%s)",
   rc->name, ovs_strerror(retval));
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 6027011..9751e13 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -52,16 +52,52 @@
 
 VLOG_DEFINE_THIS_MODULE(main);
 
+static void set_probe_timer_if_changed(const struct ovsrec_open_vswitch *cfg,
+   const struct ovsdb_idl *sb_idl);
+static bool extract_probe_timer(const struct ovsrec_open_vswitch *cfg,
+char *key_name,
+int *ret_value_ptr);
+
 static unixctl_cb_func ovn_controller_exit;
 static unixctl_cb_func ct_zone_list;
 
 #define DEFAULT_BRIDGE_NAME "br-int"
+#define DEFAULT_PROBE_INTERVAL 5
 
 static void parse_options(int argc, char *argv[]);
 OVS_NO_RETURN static void usage(void);
 
 static char *ovs_remote;
 
+/* Given key_name, the following function retrieves probe_timer value from the
+ * configuration passed, this configuration comes from the "external-ids"
+ * which were configured via ovs-vsctl command.
+ *
+ * cfg: Holding the external-id values read from NB database.
+ * keyname: Name to extract the value for.
+ * ret_value_ptr: Pointer to integer location where the value read
+ * should be copied.
+ * The function returns true if success, keeps the original
+ * value of ret_value_ptr intact in case of a failure.
+ */
+static bool
+extract_probe_timer(const struct ovsrec_open_vswitch *cfg,
+char *key_name,
+int *ret_value_ptr)
+{
+const char *probe_interval= smap_get(&cfg->external_ids, key_name);
+int ret_value_temp=0; /* Temporary location to hold the value, in case of
+   * failure, str_to_int() sets the ret_value_temp to 
0,
+   * which is a valid value for us */
+if ((!probe_interval) ||  (!str_to_int(probe_interval, 10, 
&ret_value_temp)))  {
+VLOG_WARN("OVN OVSDB invalid remote probe interval:%s for %s",
+ probe_interval, key_name);
+return false;
+}
+*ret_value_ptr = ret_value_temp;
+return true;
+}
+
 const struct sbrec_chassis *
 get_chassis(struct ovsdb_idl *ovnsb_idl, const char *chassis_id)
 {
@@ -198,30 +234,27 @@ 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 'o