ovn-controller: Add external-id 'ovn-remote-probe-interval'
authorHuang Lei <lhuang8@ebay.com>
Thu, 24 Mar 2016 18:18:34 +0000 (02:18 +0800)
committerBen Pfaff <blp@ovn.org>
Thu, 31 Mar 2016 00:06:31 +0000 (17:06 -0700)
Add a external-id 'ovn-remote-probe-interval' for setting the activity probe
interval of the json session from ovn-controller to the OVN southbound database.

Signed-off-by: Huang Lei <lhuang8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/ovsdb-idl.c
lib/ovsdb-idl.h
ovn/controller/ovn-controller.8.xml
ovn/controller/ovn-controller.c

index 260f068..3ab05a3 100644 (file)
@@ -582,6 +582,15 @@ ovsdb_idl_get_last_error(const struct ovsdb_idl *idl)
         return 0;
     }
 }
+
+/* Sets the "probe interval" for 'idl->session' to 'probe_interval', in
+ * milliseconds.
+ */
+void
+ovsdb_idl_set_probe_interval(const struct ovsdb_idl *idl, int probe_interval)
+{
+    jsonrpc_session_set_probe_interval(idl->session, probe_interval);
+}
 \f
 static unsigned char *
 ovsdb_idl_get_mode(struct ovsdb_idl *idl,
index 136c38c..e2e2a5e 100644 (file)
@@ -68,6 +68,8 @@ void ovsdb_idl_verify_write_only(struct ovsdb_idl *);
 
 bool ovsdb_idl_is_alive(const struct ovsdb_idl *);
 int ovsdb_idl_get_last_error(const struct ovsdb_idl *);
+
+void ovsdb_idl_set_probe_interval(const struct ovsdb_idl *, int probe_interval);
 \f
 /* Choosing columns and tables to replicate. */
 
index 69d4cc0..1ee3a6e 100644 (file)
         </p>
       </dd>
 
+      <dt><code>external_ids:ovn-remote-probe-interval</code></dt>
+      <dd>
+        <p>
+          The inactivity probe interval of the connection to the OVN database,
+          in milliseconds.
+          If the value is zero, it disables the connection keepalive feature.
+        </p>
+
+        <p>
+          If the value is nonzero, then it will be forced to a value of
+          at least 1000 ms.
+        </p>
+      </dd>
+
       <dt><code>external_ids:ovn-encap-type</code></dt>
       <dd>
         <p>
index 44ab8b3..6027011 100644 (file)
@@ -198,6 +198,32 @@ 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;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -261,6 +287,11 @@ 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);
+    }
+
     /* Initialize connection tracking zones. */
     struct simap ct_zones = SIMAP_INITIALIZER(&ct_zones);
     unsigned long ct_zone_bitmap[BITMAP_N_LONGS(MAX_CT_ZONES)];