From patchwork Thu Jul 28 19:54:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Moats X-Patchwork-Id: 653870 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 3s0jJL1Ljjz9t29 for ; Fri, 29 Jul 2016 05:55:13 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2A28A11372; Thu, 28 Jul 2016 12:55:13 -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 27EF8112D3 for ; Thu, 28 Jul 2016 12:55:12 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id B0B1C1E02D7 for ; Thu, 28 Jul 2016 13:55:11 -0600 (MDT) X-ASG-Debug-ID: 1469735706-09eadd7ae92fff60001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id MvFqzDHXAjyiy4Q6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 28 Jul 2016 13:55:06 -0600 (MDT) X-Barracuda-Envelope-From: stack@tombstone-01.cloud.svl.ibm.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by mx1-pf1.cudamail.com with ESMTPS (AES256-SHA encrypted); 28 Jul 2016 19:55:05 -0000 Received-SPF: none (mx1-pf1.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 (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6SJsFx2096261 for ; Thu, 28 Jul 2016 15:55:03 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 24fdrqpmdw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Jul 2016 15:55:03 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Jul 2016 13:55:01 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Jul 2016 13:54:42 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: stack@tombstone-01.cloud.svl.ibm.com Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 276D21FF0043 for ; Thu, 28 Jul 2016 13:54:24 -0600 (MDT) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6SJshXG39780528; Thu, 28 Jul 2016 19:54:43 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E42DBAE052; Thu, 28 Jul 2016 15:54:40 -0400 (EDT) Received: from localhost (unknown [9.30.183.40]) by b01ledav005.gho.pok.ibm.com (Postfix) with SMTP id 97926AE034; Thu, 28 Jul 2016 15:54:40 -0400 (EDT) Received: by localhost (Postfix, from userid 1000) id E2EF2601AA; Thu, 28 Jul 2016 19:54:32 +0000 (UTC) X-CudaMail-Envelope-Sender: stack@tombstone-01.cloud.svl.ibm.com From: Ryan Moats To: dev@openvswitch.org X-CudaMail-MID: CM-E1-727062351 X-CudaMail-DTE: 072816 X-CudaMail-Originating-IP: 148.163.156.1 Date: Thu, 28 Jul 2016 19:54:30 +0000 X-ASG-Orig-Subj: [##CM-E1-727062351##][PATCH] ovn-controller: Remove flows created for now deleted SB database rows. X-Mailer: git-send-email 1.9.1 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072819-0004-0000-0000-000010046780 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005537; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000177; SDB=6.00736771; UDB=6.00346050; IPR=6.00509363; BA=6.00004629; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012096; XFM=3.00000011; UTC=2016-07-28 19:55:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072819-0005-0000-0000-000077840584 Message-Id: <1469735670-26307-1-git-send-email-rmoats@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-28_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607280198 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1469735706 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 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.31586 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: Remove flows created for now deleted SB database rows. 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" Ensure that rows created for deleted port binding and multicast group rows are cleared when doing full processing. Signed-off-by: Ryan Moats --- ovn/controller/physical.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index 2e9fb73..9e9343d 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -58,6 +58,10 @@ static struct simap localvif_to_ofport = SIMAP_INITIALIZER(&localvif_to_ofport); static struct hmap tunnels = HMAP_INITIALIZER(&tunnels); +static struct sset port_binding_uuids = SSET_INITIALIZER(&port_binding_uuids); +static struct sset multicast_group_uuids = + SSET_INITIALIZER(&multicast_group_uuids); + /* UUID to identify OF flows not associated with ovsdb rows. */ static struct uuid *hc_uuid = NULL; static bool full_binding_processing = false; @@ -594,6 +598,27 @@ consider_mc_group(enum mf_field_id mff_ovn_geneve, sset_destroy(&remote_chassis); } +static void +rationalize_ssets_and_delete_flows(struct sset *old, struct sset *new) +{ + const char *uuid_s, *next_uuid; + SSET_FOR_EACH_SAFE (uuid_s, next_uuid, old) { + if (!sset_find(new, uuid_s)) { + struct uuid uuid; + if (uuid_from_string(&uuid, uuid_s)) { + ofctrl_remove_flows(&uuid); + } + sset_find_and_delete(old, uuid_s); + } + } + SSET_FOR_EACH_SAFE (uuid_s, next_uuid, new) { + if (!sset_find(old, uuid_s)) { + sset_add(old, uuid_s); + } + sset_find_and_delete(new, uuid_s); + } +} + void physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, const struct ovsrec_bridge *br_int, const char *this_chassis_id, @@ -750,6 +775,8 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, * 64 for logical-to-physical translation. */ const struct sbrec_port_binding *binding; if (full_binding_processing) { + struct sset new_port_binding_uuids = + SSET_INITIALIZER(&new_port_binding_uuids); SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) { /* Because it is possible in the above code to enter this * for loop without having cleared the flow table first, we @@ -757,7 +784,12 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, ofctrl_remove_flows(&binding->header_.uuid); consider_port_binding(mff_ovn_geneve, ct_zones, local_datapaths, patched_datapaths, binding, &ofpacts); + sset_add(&new_port_binding_uuids, + xasprintf(UUID_FMT, UUID_ARGS(&binding->header_.uuid))); } + rationalize_ssets_and_delete_flows(&port_binding_uuids, + &new_port_binding_uuids); + sset_destroy(&new_port_binding_uuids); full_binding_processing = false; } else { SBREC_PORT_BINDING_FOR_EACH_TRACKED (binding, ctx->ovnsb_idl) { @@ -777,6 +809,8 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, const struct sbrec_multicast_group *mc; struct ofpbuf remote_ofpacts; ofpbuf_init(&remote_ofpacts, 0); + struct sset new_multicast_group_uuids = + SSET_INITIALIZER(&new_multicast_group_uuids); SBREC_MULTICAST_GROUP_FOR_EACH (mc, ctx->ovnsb_idl) { /* As multicast groups are always reprocessed each time, * the first step is to clean the old flows for the group @@ -784,7 +818,12 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, ofctrl_remove_flows(&mc->header_.uuid); consider_mc_group(mff_ovn_geneve, ct_zones, local_datapaths, mc, &ofpacts, &remote_ofpacts); + sset_add(&new_multicast_group_uuids, + xasprintf(UUID_FMT, UUID_ARGS(&mc->header_.uuid))); } + rationalize_ssets_and_delete_flows(&multicast_group_uuids, + &new_multicast_group_uuids); + sset_destroy(&new_multicast_group_uuids); ofpbuf_uninit(&remote_ofpacts);