From patchwork Thu Jul 28 06:30:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongjun X-Patchwork-Id: 653593 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 3s0MSl3Wdsz9t2W for ; Thu, 28 Jul 2016 16:31:19 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id AE0B010EA4; Wed, 27 Jul 2016 23:31:18 -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 9A6D610ADC for ; Wed, 27 Jul 2016 23:31:17 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 356FE4200E5 for ; Thu, 28 Jul 2016 00:31:17 -0600 (MDT) X-ASG-Debug-ID: 1469687472-09eadd7ae821cec0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar5.cudamail.com with ESMTP id b9LzJdE8qFcBFJRW (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 28 Jul 2016 00:31:12 -0600 (MDT) X-Barracuda-Envelope-From: dongj@dtdream.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO smtp2203-239.mail.aliyun.com) (121.197.203.239) by mx3-pf2.cudamail.com with SMTP; 28 Jul 2016 06:31:11 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at b.hichina.mail.aliyun.com designates 121.197.203.239 as permitted sender) X-Barracuda-Apparent-Source-IP: 121.197.203.239 X-Barracuda-RBL-IP: 121.197.203.239 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.1053118|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03292; MF=dongj@dtdream.com; NM=1; PH=DU; RN=2; RT=2; SR=0; TI=SMTPD_----54nLZHm_1469687440; Received: from com1.localdomain(mailfrom:dongj@dtdream.com ip:111.198.29.130) by smtp.aliyun-inc.com(10.147.40.200); Thu, 28 Jul 2016 14:30:42 +0800 X-CudaMail-Envelope-Sender: dongj@dtdream.com From: Dongjun To: dev@openvswitch.org X-CudaMail-MID: CM-V2-727000319 X-CudaMail-DTE: 072816 X-CudaMail-Originating-IP: 121.197.203.239 Date: Thu, 28 Jul 2016 14:30:38 +0800 X-ASG-Orig-Subj: [##CM-V2-727000319##][PATCH 2/2] ovn: fix lrouter flows building issue when easy SNAT configured Message-Id: <1469687438-23125-2-git-send-email-dongj@dtdream.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1469687438-23125-1-git-send-email-dongj@dtdream.com> References: <1469687438-23125-1-git-send-email-dongj@dtdream.com> X-GBUdb-Analysis: 0, 121.197.203.239, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-3982-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1469687472 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, UNPARSEABLE_RELAY X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31572 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 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 2/2] ovn: fix lrouter flows building issue when easy SNAT configured 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" The lrouter drop the traffic to it's own port IPs unless the IPs are configured for SNAT. Now these flows are still built. Signed-off-by: Dongjun --- ovn/northd/ovn-northd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 ovn/northd/ovn-northd.c diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c old mode 100644 new mode 100755 index 716f123..90394d1 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -2490,6 +2490,15 @@ op_put_networks(struct ds *ds, const struct ovn_port *op, bool add_bcast) ds_put_cstr(ds, "}"); } +static bool has_ip(ovs_be32 *ips, size_t size, ovs_be32 ip){ + for (int i = 0; i < size; i++) { + if (ip == ips[i]) { + return true; + } + } + return false; +} + static void build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, struct hmap *lflows) @@ -2689,11 +2698,8 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_put_cstr(&match, "ip4.dst == {"); bool has_drop_ips = false; for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) { - for (int j = 0; j < n_snat_ips; j++) { - /* Packets to SNAT IPs should not be dropped. */ - if (op->lrp_networks.ipv4_addrs[i].addr == snat_ips[j]) { - continue; - } + if(has_ip(snat_ips, n_snat_ips, op->lrp_networks.ipv4_addrs[i].addr)){ + continue; } ds_put_format(&match, "%s, ", op->lrp_networks.ipv4_addrs[i].addr_s);