From patchwork Fri Jun 24 20:39:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Moats X-Patchwork-Id: 640417 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 3rbqvF0Gztz9sDC for ; Sat, 25 Jun 2016 06:39:36 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 3607D10C93; Fri, 24 Jun 2016 13:39:36 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 0753E1015E for ; Fri, 24 Jun 2016 13:39:35 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 8D0CB1E045A for ; Fri, 24 Jun 2016 14:39:34 -0600 (MDT) X-ASG-Debug-ID: 1466800773-09eadd24bc23db80001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id gvuHoAYIsQPDnvxK (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 24 Jun 2016 14:39:33 -0600 (MDT) X-Barracuda-Envelope-From: rmoats@oc7146733065.ibm.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO fed1rmfepo202.cox.net) (68.230.241.147) by mx3-pf3.cudamail.com with SMTP; 24 Jun 2016 20:39:32 -0000 Received-SPF: none (mx3-pf3.cudamail.com: domain at oc7146733065.ibm.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 68.230.241.147 X-Barracuda-RBL-IP: 68.230.241.147 Received: from fed1rmimpo209.cox.net ([68.230.241.160]) by fed1rmfepo202.cox.net (InterMail vM.8.01.05.28 201-2260-151-171-20160122) with ESMTP id <20160624203931.NYB2415.fed1rmfepo202.cox.net@fed1rmimpo209.cox.net> for ; Fri, 24 Jun 2016 16:39:31 -0400 Received: from oc7146733065.ibm.com ([68.13.99.247]) by fed1rmimpo209.cox.net with cox id AkfW1t00g5LF6cs01kfXl5; Fri, 24 Jun 2016 16:39:31 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020206.576D9A83.017E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.1 cv=H/J7u7si c=1 sm=1 tr=0 a=Jmqd6mthTashISSy/JkQqg==:117 a=Jmqd6mthTashISSy/JkQqg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=pD_ry4oyNxEA:10 a=VnNF1IyMAAAA:8 a=n9GDAZO01WkMfZVwuXIA:9 a=skCgnbhlp52w9zbo2JeP:22 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: by oc7146733065.ibm.com (Postfix, from userid 500) id 2AE8B188036A; Fri, 24 Jun 2016 15:39:30 -0500 (CDT) X-CudaMail-Envelope-Sender: rmoats@oc7146733065.ibm.com From: Ryan Moats To: dev@openvswitch.org X-CudaMail-MID: CM-V3-623043101 X-CudaMail-DTE: 062416 X-CudaMail-Originating-IP: 68.230.241.147 Date: Fri, 24 Jun 2016 15:39:28 -0500 X-ASG-Orig-Subj: [##CM-V3-623043101##][PATCH] Fix port binding update on OVS port delete events Message-Id: <1466800768-6618-1-git-send-email-rmoats@us.ibm.com> X-Mailer: git-send-email 1.7.1 X-GBUdb-Analysis: 0, 68.230.241.147, Ugly c=0.226425 p=-0.333333 Source Normal X-MessageSniffer-Rules: 0-0-0-9647-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1466800773 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.30732 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] Fix port binding update on OVS port delete events 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" Patch "Convert binding_run to incremental processing." introduced a bug where the port binding table is not correctly updated when an OVS port is deleted. Fix this by - persisting the lport shash used to record OVS ports - change get_local_iface_ids to return a bool indicating if the persisted lport shash has changed - change port binding table processing from incremental to full if the persisted lport shash has changed Signed-off-by: Ryan Moats --- ovn/controller/binding.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 9921a49..fd01c71 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -59,10 +59,15 @@ binding_register_ovs_idl(struct ovsdb_idl *ovs_idl) &ovsrec_interface_col_ingress_policing_burst); } -static void +static bool get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports) { int i; + bool changed = false; + + /* A local copy of ports that we can use to compare with the persisted + * list. */ + struct shash local_ports = SHASH_INITIALIZER(&local_ports); for (i = 0; i < br_int->n_ports; i++) { const struct ovsrec_port *port_rec = br_int->ports[i]; @@ -81,13 +86,26 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports) if (!iface_id) { continue; } - shash_add(lports, iface_id, iface_rec); + shash_add(&local_ports, iface_id, iface_rec); + if (!shash_find(lports, iface_id)) { + shash_add(lports, iface_id, iface_rec); + changed = true; + } if (!sset_find(&all_lports, iface_id)) { sset_add(&all_lports, iface_id); binding_reset_processing(); } } } + struct shash_node *iter, *next; + SHASH_FOR_EACH_SAFE(iter, next, lports) { + if (!shash_find_and_delete(&local_ports, iter->name)) { + shash_delete(lports, iter); + changed = true; + } + } + shash_destroy(&local_ports); + return changed; } /* Contains "struct local_datpath" nodes whose hash values are the @@ -176,7 +194,7 @@ consider_local_datapath(struct controller_ctx *ctx, struct shash *lports, struct hmap *local_datapaths) { const struct ovsrec_interface *iface_rec - = shash_find_and_delete(lports, binding_rec->logical_port); + = shash_find_data(lports, binding_rec->logical_port); if (iface_rec || (binding_rec->parent_port && binding_rec->parent_port[0] && sset_contains(&all_lports, binding_rec->parent_port))) { @@ -221,6 +239,10 @@ consider_local_datapath(struct controller_ctx *ctx, struct shash *lports, } } +/* We persist lports because we need to know when it changes to + * handle ports going away correctly in the binding record. */ +static struct shash lports = SHASH_INITIALIZER(&lports); + void binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, const char *chassis_id, struct hmap *local_datapaths) @@ -233,12 +255,14 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, return; } - struct shash lports = SHASH_INITIALIZER(&lports); if (br_int) { - get_local_iface_ids(br_int, &lports); + if (get_local_iface_ids(br_int, &lports)) { + process_full_binding = true; + } } else { /* We have no integration bridge, therefore no local logical ports. * We'll remove our chassis from all port binding records below. */ + process_full_binding = true; } /* Run through each binding record to see if it is resident on this @@ -274,8 +298,6 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, } } } - - shash_destroy(&lports); } /* Returns true if the database is all cleaned up, false if more work is