Skip to content

Commit

Permalink
ovn-northd: Fix shadowed iterators in port security functions.
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Pettit <[email protected]>
Acked-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
justinpettit committed Jul 13, 2016
1 parent 34a88a4 commit f95523c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ovn/northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,18 +1144,18 @@ build_port_security_nd(struct ovn_port *op, struct hmap *lflows)

if (ps->n_ipv4_addrs) {
ds_put_cstr(&match, " && arp.spa == {");
for (size_t i = 0; i < ps->n_ipv4_addrs; i++) {
for (size_t j = 0; j < ps->n_ipv4_addrs; j++) {
/* 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].plen == 32
|| ps->ipv4_addrs[i].addr & ~ps->ipv4_addrs[i].mask) {
ds_put_cstr(&match, ps->ipv4_addrs[i].addr_s);
if (ps->ipv4_addrs[j].plen == 32
|| ps->ipv4_addrs[j].addr & ~ps->ipv4_addrs[j].mask) {
ds_put_cstr(&match, ps->ipv4_addrs[j].addr_s);
} else {
ds_put_format(&match, "%s/%d",
ps->ipv4_addrs[i].network_s,
ps->ipv4_addrs[i].plen);
ps->ipv4_addrs[j].network_s,
ps->ipv4_addrs[j].plen);
}
ds_put_cstr(&match, ", ");
}
Expand Down Expand Up @@ -1244,26 +1244,26 @@ build_port_security_ip(enum ovn_pipeline pipeline, struct ovn_port *op,
op->json_key, ps->ea_s);
}

for (int i = 0; i < ps->n_ipv4_addrs; i++) {
ovs_be32 mask = ps->ipv4_addrs[i].mask;
for (int j = 0; j < ps->n_ipv4_addrs; j++) {
ovs_be32 mask = ps->ipv4_addrs[j].mask;
/* 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].plen == 32
|| ps->ipv4_addrs[i].addr & ~mask) {
ds_put_format(&match, "%s", ps->ipv4_addrs[i].addr_s);
if (pipeline == P_OUT && ps->ipv4_addrs[i].plen != 32) {
if (ps->ipv4_addrs[j].plen == 32
|| ps->ipv4_addrs[j].addr & ~mask) {
ds_put_format(&match, "%s", ps->ipv4_addrs[j].addr_s);
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, ", %s",
ps->ipv4_addrs[i].bcast_s);
ps->ipv4_addrs[j].bcast_s);
}
} else {
/* host portion is zero */
ds_put_format(&match, "%s/%d", ps->ipv4_addrs[i].network_s,
ps->ipv4_addrs[i].plen);
ds_put_format(&match, "%s/%d", ps->ipv4_addrs[j].network_s,
ps->ipv4_addrs[j].plen);
}
ds_put_cstr(&match, ", ");
}
Expand Down

0 comments on commit f95523c

Please sign in to comment.