diff mbox

[ovs-dev,1/3] ovn-northd: Fix shadowed iterators in port security functions.

Message ID 1468351162-349-1-git-send-email-jpettit@ovn.org
State Accepted
Headers show

Commit Message

Justin Pettit July 12, 2016, 7:19 p.m. UTC
Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 ovn/northd/ovn-northd.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Daniele Di Proietto July 13, 2016, 6:52 a.m. UTC | #1
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>


2016-07-12 12:19 GMT-07:00 Justin Pettit <jpettit@ovn.org>:

> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  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, ", ");
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
diff mbox

Patch

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, ", ");