diff mbox

[ovs-dev,v2] ovn-controller: Remove old address set after change.

Message ID 1467916624-12564-1-git-send-email-rmoats@us.ibm.com
State Accepted
Headers show

Commit Message

Ryan Moats July 7, 2016, 6:37 p.m. UTC
Currently, when address set value changes, ovn controller
doesn't remove the old entry from the tracking hash, it
just adds the new one, leading to multiple entries for the
same symbol.

Fix this behavior and add a smoke test to avoid a regression
in the future.

Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
---
 ovn/controller/lflow.c |  1 +
 tests/ovn.at           | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

Comments

Flaviof July 7, 2016, 6:52 p.m. UTC | #1
On Thu, Jul 7, 2016 at 2:37 PM, Ryan Moats <rmoats@us.ibm.com> wrote:

> Currently, when address set value changes, ovn controller
> doesn't remove the old entry from the tracking hash, it
> just adds the new one, leading to multiple entries for the
> same symbol.
>
> Fix this behavior and add a smoke test to avoid a regression
> in the future.
>
> Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
>


Acked-by: Flavio Fernandes <flavio@flaviof.com>




> ---
>  ovn/controller/lflow.c |  1 +
>  tests/ovn.at           | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
> index 05e1eaf..00d1d6e 100644
> --- a/ovn/controller/lflow.c
> +++ b/ovn/controller/lflow.c
> @@ -258,6 +258,7 @@ update_address_sets(struct controller_ctx *ctx)
>               * if the symtab entry needs to be updated due to a change. */
>              sset_find_and_delete(&cur_addr_set_names, addr_set_rec->name);
>              if (!address_sets_match(addr_set, addr_set_rec)) {
> +                shash_find_and_delete(&local_address_sets,
> addr_set_rec->name);
>                  expr_macros_remove(&expr_address_sets,
> addr_set_rec->name);
>                  address_set_destroy(addr_set);
>                  addr_set = NULL;
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 3436417..344d07f 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -3348,3 +3348,26 @@ done
>  OVN_CLEANUP([hv1])
>
>  AT_CLEANUP
> +
> +AT_SETUP([ovn -- address sets modification/removal smoke test])
> +AT_KEYWORDS([ovn-addr])
> +ovn_start
> +
> +net_add n1
> +
> +sim_add hv1
> +as hv1
> +ovs-vsctl add-br br-phys
> +ovn_attach n1 br-phys 192.168.0.1
> +
> +row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"`
> +ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\"
> +ovn-nbctl destroy Address_Set $row
> +
> +sleep 1
> +
> +AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore])
> +
> +OVN_CLEANUP([hv1])
> +
> +AT_CLEANUP
> --
> 2.7.4 (Apple Git-66)
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
diff mbox

Patch

diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index 05e1eaf..00d1d6e 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -258,6 +258,7 @@  update_address_sets(struct controller_ctx *ctx)
              * if the symtab entry needs to be updated due to a change. */
             sset_find_and_delete(&cur_addr_set_names, addr_set_rec->name);
             if (!address_sets_match(addr_set, addr_set_rec)) {
+                shash_find_and_delete(&local_address_sets, addr_set_rec->name);
                 expr_macros_remove(&expr_address_sets, addr_set_rec->name);
                 address_set_destroy(addr_set);
                 addr_set = NULL;
diff --git a/tests/ovn.at b/tests/ovn.at
index 3436417..344d07f 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -3348,3 +3348,26 @@  done
 OVN_CLEANUP([hv1])
 
 AT_CLEANUP
+
+AT_SETUP([ovn -- address sets modification/removal smoke test])
+AT_KEYWORDS([ovn-addr])
+ovn_start
+
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.1
+
+row=`ovn-nbctl create Address_Set name=set1 addresses=\"1.1.1.1\"`
+ovn-nbctl set Address_Set $row name=set1 addresses=\"1.1.1.1,1.1.1.2\"
+ovn-nbctl destroy Address_Set $row
+
+sleep 1
+
+AT_CHECK([ovs-appctl -t ovn-controller version], [0], [ignore])
+
+OVN_CLEANUP([hv1])
+
+AT_CLEANUP