From patchwork Thu Apr 14 07:24:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nirapada Ghosh X-Patchwork-Id: 610382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3qlsck2z7Mz9ssM for ; Thu, 14 Apr 2016 17:24:37 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 8740610665; Thu, 14 Apr 2016 00:24:36 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 11AE210663 for ; Thu, 14 Apr 2016 00:24:36 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 606B442027A for ; Thu, 14 Apr 2016 01:24:35 -0600 (MDT) X-ASG-Debug-ID: 1460618673-09eadd699805770001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id btDXWB6VHUyuZdRF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Apr 2016 01:24:33 -0600 (MDT) X-Barracuda-Envelope-From: nirapada@host.local.domain X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO e06smtp05.uk.ibm.com) (195.75.94.101) by mx3-pf3.cudamail.com with ESMTPS (AES256-SHA encrypted); 14 Apr 2016 07:24:32 -0000 Received-SPF: none (mx3-pf3.cudamail.com: domain at host.local.domain does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 195.75.94.101 X-Barracuda-RBL-IP: 195.75.94.101 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Apr 2016 08:24:29 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Apr 2016 08:24:28 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: nirapada@host.local.domain X-IBM-RcptTo: dev@openvswitch.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id A30481B0806E for ; Thu, 14 Apr 2016 08:25:08 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3E7OQa864880684 for ; Thu, 14 Apr 2016 07:24:26 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3E7OQ0c012257 for ; Thu, 14 Apr 2016 01:24:26 -0600 Received: from host.local.domain ([9.80.218.167]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3E7OODP012109 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 14 Apr 2016 01:24:26 -0600 Received: by host.local.domain (Postfix, from userid 501) id 19A461161C35; Thu, 14 Apr 2016 00:24:25 -0700 (PDT) X-CudaMail-Envelope-Sender: nirapada@host.local.domain From: nghosh@us.ibm.com To: dev@openvswitch.org X-CudaMail-MID: CM-V3-413001287 X-CudaMail-DTE: 041416 X-CudaMail-Originating-IP: 195.75.94.101 Date: Thu, 14 Apr 2016 00:24:03 -0700 X-ASG-Orig-Subj: [##CM-V3-413001287##][PATCH V4] ovn-controller: reload configured SB probe timer Message-Id: <1460618643-41761-1-git-send-email-nghosh@us.ibm.com> X-Mailer: git-send-email 2.6.4 (Apple Git-63) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041407-0021-0000-0000-000013211D0F X-GBUdb-Analysis: 0, 195.75.94.101, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-15373-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1460618673 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.28724 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH V4] ovn-controller: reload configured SB probe timer X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 one [SB] of them 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. For the local ovsdb connection, probe timer is already disabled. For the last two connections, they do not need probe_timer as they are over unix domain socket. This patch takes care of that as well. 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. Also, by making sure from ovn-controller's log file that there is no more reconnect happening due to probe under heavy load. Author: Nirapada Ghosh Date: Wed Mar 30 19:03:10 2016 -0700 Signed-off-by: Nirapada Ghosh diff --git a/lib/rconn.c b/lib/rconn.c index 6de4c63..54f3745 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -339,6 +339,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 (!stream_or_pstream_needs_probes()) { + rc->probe_interval =0; + } reconnect(rc); ovs_mutex_unlock(&rc->mutex); } diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 7c68c9d..92e9543 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -56,6 +56,13 @@ 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 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); static void parse_options(int argc, char *argv[]); OVS_NO_RETURN static void usage(void); @@ -217,32 +224,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; -} - int main(int argc, char *argv[]) { @@ -306,10 +287,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; + } + set_probe_timer_if_changed(cfg,ovnsb_idl_loop.idl); /* Initialize connection tracking zones. */ struct simap ct_zones = SIMAP_INITIALIZER(&ct_zones); @@ -327,6 +310,7 @@ main(int argc, char *argv[]) .ovnsb_idl = ovnsb_idl_loop.idl, .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), }; + set_probe_timer_if_changed(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. */ @@ -561,3 +545,55 @@ ct_zone_list(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, ds_cstr(&ds)); ds_destroy(&ds); } + +/* If SB probe timer is changed using ovs-vsctl command, this function + * will set that probe timer value for the session. + * cfg: Holding the external-id values read from southbound DB. + * sb_idl: pointer to the ovs_idl connection to OVN southbound. + */ +static void +set_probe_timer_if_changed(const struct ovsrec_open_vswitch *cfg, + const struct ovsdb_idl *sb_idl) +{ + static int probe_int_sb = DEFAULT_PROBE_INTERVAL * 1000; + int probe_int_sb_new = probe_int_sb; + + extract_probe_timer(cfg, "ovn-remote-probe-interval", &probe_int_sb_new); + if (probe_int_sb_new != probe_int_sb) { + ovsdb_idl_set_probe_interval(sb_idl, probe_int_sb_new); + VLOG_INFO("OVN SB probe interval changed %d->%d ", + probe_int_sb, + probe_int_sb_new); + probe_int_sb = probe_int_sb_new; + } +} + +/* 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 to 0, + * which is a valid value of probe_timer. */ + 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; +}