From patchwork Mon Jul 25 16:28:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Moats X-Patchwork-Id: 652341 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 3rymt51x1Fz9ssM for ; Tue, 26 Jul 2016 02:29:17 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2929B1090A; Mon, 25 Jul 2016 09:29:16 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id A4D2C10907 for ; Mon, 25 Jul 2016 09:29:14 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 3A1C41628A3 for ; Mon, 25 Jul 2016 10:29:14 -0600 (MDT) X-ASG-Debug-ID: 1469464148-0b323703f94765e0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id duKmxvzkQc1c2l4n (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 25 Jul 2016 10:29:08 -0600 (MDT) X-Barracuda-Envelope-From: stack@tombstone-01.cloud.svl.ibm.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by mx1-pf2.cudamail.com with ESMTPS (AES256-SHA encrypted); 25 Jul 2016 16:29:07 -0000 Received-SPF: none (mx1-pf2.cudamail.com: domain at tombstone-01.cloud.svl.ibm.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 148.163.156.1 X-Barracuda-RBL-IP: 148.163.156.1 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6PGSpWG145943 for ; Mon, 25 Jul 2016 12:29:07 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 24c4nrbaq0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 25 Jul 2016 12:29:06 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jul 2016 12:29:05 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 25 Jul 2016 12:29:04 -0400 X-IBM-Helo: d01dlp01.pok.ibm.com X-IBM-MailFrom: stack@tombstone-01.cloud.svl.ibm.com Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 5EDE238C8041 for ; Mon, 25 Jul 2016 12:29:03 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6PGT6Oo56885404; Mon, 25 Jul 2016 16:29:07 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA4A1AE03B; Mon, 25 Jul 2016 12:29:02 -0400 (EDT) Received: from localhost (unknown [9.30.183.40]) by b01ledav005.gho.pok.ibm.com (Postfix) with SMTP id 6B982AE043; Mon, 25 Jul 2016 12:29:02 -0400 (EDT) Received: by localhost (Postfix, from userid 1000) id 9AB8A601AA; Mon, 25 Jul 2016 16:28:55 +0000 (UTC) X-CudaMail-Envelope-Sender: stack@tombstone-01.cloud.svl.ibm.com From: Ryan Moats To: dev@openvswitch.org X-CudaMail-MID: CM-E2-724035326 X-CudaMail-DTE: 072516 X-CudaMail-Originating-IP: 148.163.156.1 Date: Mon, 25 Jul 2016 16:28:52 +0000 X-ASG-Orig-Subj: [##CM-E2-724035326##][PATCH ovn-controller] Physical: persist tunnels X-Mailer: git-send-email 1.9.1 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072516-0040-0000-0000-000000E4E68D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072516-0041-0000-0000-000004BF3106 Message-Id: <1469464132-7697-1-git-send-email-rmoats@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-25_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607250191 X-GBUdb-Analysis: 0, 148.163.156.1, Ugly c=0.444918 p=-0.466667 Source Normal X-MessageSniffer-Rules: 0-0-0-14138-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1469464148 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 global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31509 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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 ovn-controller] Physical: persist tunnels 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: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" While commit ab39371d68842b7e4000cc5d8718e6fc04e92795 (ovn-controller: Handle physical changes correctly) addressed unit test failures, it did so at the cost of performance: [1] notes that ovn-controller cpu usage is now pegged at 100%. Root cause of this is that while the storage for tunnels is persisted, their creation is not (which the above changed incorrectly assumed was the case). This patch persists tunneled data across invocations of physical_run. A side effect is that renaming of localfvif_map_changed variable to physical_map_changed and extending its scope to include tunnel changes. [1] http://openvswitch.org/pipermail/dev/2016-July/076058.html Signed-off-by: Ryan Moats Acked-by: Flavio Fernandes Tested-by: Flavio Fernandes Acked-by: Liran Schour Tested-by: Liran Schour Acked-by: Hui Kang Tested-by: Hui Kang --- ovn/controller/physical.c | 59 +++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index a104e33..e788fe5 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -605,8 +605,13 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, uuid_generate(hc_uuid); } + /* This bool tracks physical mapping changes. */ + bool physical_map_changed = false; + struct simap new_localvif_to_ofport = SIMAP_INITIALIZER(&new_localvif_to_ofport); + struct simap new_tunnel_to_ofport = + SIMAP_INITIALIZER(&new_tunnel_to_ofport); for (int i = 0; i < br_int->n_ports; i++) { const struct ovsrec_port *port_rec = br_int->ports[i]; if (!strcmp(port_rec->name, br_int->name)) { @@ -668,18 +673,23 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, continue; } - struct chassis_tunnel *tun = xmalloc(sizeof *tun); - hmap_insert(&tunnels, &tun->hmap_node, - hash_string(chassis_id, 0)); - tun->chassis_id = chassis_id; - tun->ofport = u16_to_ofp(ofport); - tun->type = tunnel_type; - full_binding_processing = true; - binding_reset_processing(); - - /* Reprocess logical flow table immediately. */ - lflow_reset_processing(); - poll_immediate_wake(); + simap_put(&new_tunnel_to_ofport, chassis_id, ofport); + struct chassis_tunnel *tun; + if ((tun = chassis_tunnel_find(chassis_id))) { + /* If the tunnel's ofport has changed, update. */ + if (tun->ofport != u16_to_ofp(ofport)) { + tun->ofport = u16_to_ofp(ofport); + physical_map_changed = true; + } + } else { + tun = xmalloc(sizeof *tun); + hmap_insert(&tunnels, &tun->hmap_node, + hash_string(chassis_id, 0)); + tun->chassis_id = chassis_id; + tun->ofport = u16_to_ofp(ofport); + tun->type = tunnel_type; + physical_map_changed = true; + } break; } else { const char *iface_id = smap_get(&iface_rec->external_ids, @@ -691,29 +701,38 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, } } + /* Remove tunnels that are no longer here. */ + struct chassis_tunnel *tun, *tun_next; + HMAP_FOR_EACH_SAFE (tun, tun_next, hmap_node, &tunnels) { + if (!simap_find(&new_tunnel_to_ofport, tun->chassis_id)) { + hmap_remove(&tunnels, &tun->hmap_node); + physical_map_changed = true; + free(tun); + } + } + /* Capture changed or removed openflow ports. */ - bool localvif_map_changed = false; struct simap_node *vif_name, *vif_name_next; SIMAP_FOR_EACH_SAFE (vif_name, vif_name_next, &localvif_to_ofport) { int newport; if ((newport = simap_get(&new_localvif_to_ofport, vif_name->name))) { if (newport != simap_get(&localvif_to_ofport, vif_name->name)) { simap_put(&localvif_to_ofport, vif_name->name, newport); - localvif_map_changed = true; + physical_map_changed = true; } } else { simap_find_and_delete(&localvif_to_ofport, vif_name->name); - localvif_map_changed = true; + physical_map_changed = true; } } SIMAP_FOR_EACH (vif_name, &new_localvif_to_ofport) { if (!simap_get(&localvif_to_ofport, vif_name->name)) { simap_put(&localvif_to_ofport, vif_name->name, simap_get(&new_localvif_to_ofport, vif_name->name)); - localvif_map_changed = true; + physical_map_changed = true; } } - if (localvif_map_changed) { + if (physical_map_changed) { full_binding_processing = true; /* Reprocess logical flow table immediately. */ @@ -769,7 +788,6 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, * ports. We set MFF_LOG_DATAPATH, MFF_LOG_INPORT, and * MFF_LOG_OUTPORT from the tunnel key data, then resubmit to table * 33 to handle packets to the local hypervisor. */ - struct chassis_tunnel *tun; HMAP_FOR_EACH (tun, hmap_node, &tunnels) { struct match match = MATCH_CATCHALL_INITIALIZER; match_set_in_port(&match, tun->ofport); @@ -858,10 +876,7 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, ofctrl_add_flow(OFTABLE_DROP_LOOPBACK, 0, &match, &ofpacts, hc_uuid); ofpbuf_uninit(&ofpacts); - HMAP_FOR_EACH_POP (tun, hmap_node, &tunnels) { - free(tun); - } - hmap_clear(&tunnels); simap_destroy(&new_localvif_to_ofport); + simap_destroy(&new_tunnel_to_ofport); }