From patchwork Tue Jul 12 19:19:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 647616 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 3rptjy0Pgdz9s9G for ; Wed, 13 Jul 2016 06:24:54 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 1841210898; Tue, 12 Jul 2016 13:24:53 -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 7C7D21088E for ; Tue, 12 Jul 2016 13:24:52 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id DD78E1E05CF for ; Tue, 12 Jul 2016 14:24:51 -0600 (MDT) X-ASG-Debug-ID: 1468355090-09eadd303232ac0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id YsH7xnefdHePqtTQ (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 12 Jul 2016 14:24:50 -0600 (MDT) X-Barracuda-Envelope-From: jpettit@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO relay4-d.mail.gandi.net) (217.70.183.196) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 12 Jul 2016 20:24:50 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.196 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.196 X-Barracuda-RBL-IP: 217.70.183.196 Received: from mfilter26-d.gandi.net (mfilter26-d.gandi.net [217.70.178.154]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 3262F1720BE for ; Tue, 12 Jul 2016 22:24:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter26-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter26-d.gandi.net (mfilter26-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id j8tY7pWoHr7H for ; Tue, 12 Jul 2016 22:24:47 +0200 (CEST) X-Originating-IP: 208.91.2.4 Received: from localhost.localdomain (unknown [208.91.2.4]) (Authenticated sender: jpettit@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2E6791720A1 for ; Tue, 12 Jul 2016 22:24:46 +0200 (CEST) X-CudaMail-Envelope-Sender: jpettit@ovn.org From: Justin Pettit To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-711069094 X-CudaMail-DTE: 071216 X-CudaMail-Originating-IP: 217.70.183.196 Date: Tue, 12 Jul 2016 12:19:20 -0700 X-ASG-Orig-Subj: [##CM-E1-711069094##][PATCH 1/3] ovn-northd: Fix shadowed iterators in port security functions. Message-Id: <1468351162-349-1-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 1.9.1 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1468355090 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 1/3] ovn-northd: Fix shadowed iterators in port security functions. 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" Signed-off-by: Justin Pettit Acked-by: Daniele Di Proietto --- ovn/northd/ovn-northd.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index f4b4435..3fb4063 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -1137,18 +1137,18 @@ build_port_security_nd(struct ovn_port *op, struct hmap *lflows) if (ps.n_ipv4_addrs) { ds_put_cstr(&match, " && ("); - for (size_t i = 0; i < ps.n_ipv4_addrs; i++) { + for (size_t j = 0; j < ps.n_ipv4_addrs; j++) { ds_put_cstr(&match, "arp.spa == "); - ovs_be32 mask = be32_prefix_mask(ps.ipv4_addrs[i].plen); + ovs_be32 mask = be32_prefix_mask(ps.ipv4_addrs[j].plen); /* When the netmask is applied, if the host portion is * non-zero, the host can only use the specified * address in the arp.spa. If zero, the host is allowed * to use any address in the subnet. */ - if (ps.ipv4_addrs[i].addr & ~mask) { + if (ps.ipv4_addrs[j].addr & ~mask) { ds_put_format(&match, IP_FMT, - IP_ARGS(ps.ipv4_addrs[i].addr)); + IP_ARGS(ps.ipv4_addrs[j].addr)); } else { - ip_format_masked(ps.ipv4_addrs[i].addr & mask, mask, + ip_format_masked(ps.ipv4_addrs[j].addr & mask, mask, &match); } ds_put_cstr(&match, " || "); @@ -1245,26 +1245,26 @@ build_port_security_ip(enum ovn_pipeline pipeline, struct ovn_port *op, op->json_key, ETH_ADDR_ARGS(ps.ea)); } - for (int i = 0; i < ps.n_ipv4_addrs; i++) { - ovs_be32 mask = be32_prefix_mask(ps.ipv4_addrs[i].plen); + for (int j = 0; j < ps.n_ipv4_addrs; j++) { + ovs_be32 mask = be32_prefix_mask(ps.ipv4_addrs[j].plen); /* When the netmask is applied, if the host portion is * non-zero, the host can only use the specified * address. If zero, the host is allowed to use any * address in the subnet. * */ - if (ps.ipv4_addrs[i].addr & ~mask) { + if (ps.ipv4_addrs[j].addr & ~mask) { ds_put_format(&match, IP_FMT, - IP_ARGS(ps.ipv4_addrs[i].addr)); - if (pipeline == P_OUT && ps.ipv4_addrs[i].plen != 32) { + IP_ARGS(ps.ipv4_addrs[j].addr)); + if (pipeline == P_OUT && ps.ipv4_addrs[j].plen != 32) { /* Host is also allowed to receive packets to the * broadcast address in the specified subnet. */ ds_put_format(&match, ", "IP_FMT, - IP_ARGS(ps.ipv4_addrs[i].addr | ~mask)); + IP_ARGS(ps.ipv4_addrs[j].addr | ~mask)); } } else { /* host portion is zero */ - ip_format_masked(ps.ipv4_addrs[i].addr & mask, mask, + ip_format_masked(ps.ipv4_addrs[j].addr & mask, mask, &match); } ds_put_cstr(&match, ", ");