[ovs-dev] [PATCH 2/9] ovn-controller: Expose address sets to the main loop.
Ben Pfaff
blp at ovn.org
Thu Jan 5 15:34:56 UTC 2017
On Wed, Jan 04, 2017 at 06:13:04PM -0800, Justin Pettit wrote:
> Other functions in the main loop will need access to address sets in a
> future commit.
>
> Signed-off-by: Justin Pettit <jpettit at ovn.org>
I'd prefer to limit the actual scope of the data structure, because that
makes it clear where the data is actually up-to-date. Like this, for
example.
--8<--------------------------cut here-------------------------->8--
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 2533899..16d1ce2 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -261,11 +261,8 @@ get_chassis_id(const struct ovsdb_idl *ovs_idl)
/* Iterate address sets in the southbound database. Create and update the
* corresponding symtab entries as necessary. */
static void
-update_addr_sets(struct controller_ctx *ctx, struct shash *addr_sets)
-
+addr_sets_init(struct controller_ctx *ctx, struct shash *addr_sets)
{
- expr_addr_sets_destroy(addr_sets);
-
const struct sbrec_address_set *as;
SBREC_ADDRESS_SET_FOR_EACH (as, ctx->ovnsb_idl) {
expr_addr_sets_add(addr_sets, as->name,
@@ -545,8 +542,6 @@ main(int argc, char *argv[])
unixctl_command_register("ct-zone-list", "", 0, 0,
ct_zone_list, &ct_zones);
- struct shash addr_sets = SHASH_INITIALIZER(&addr_sets);
-
/* Main loop. */
exiting = false;
while (!exiting) {
@@ -607,7 +602,9 @@ main(int argc, char *argv[])
update_ct_zones(&local_lports, &local_datapaths, &ct_zones,
ct_zone_bitmap, &pending_ct_zones);
if (ctx.ovs_idl_txn) {
- update_addr_sets(&ctx, &addr_sets);
+ struct shash addr_sets = SHASH_INITIALIZER(&addr_sets);
+ addr_sets_init(&ctx, &addr_sets);
+
commit_ct_zones(br_int, &pending_ct_zones);
struct hmap flow_table = HMAP_INITIALIZER(&flow_table);
@@ -621,6 +618,10 @@ main(int argc, char *argv[])
ofctrl_put(&flow_table, &pending_ct_zones,
get_nb_cfg(ctx.ovnsb_idl));
hmap_destroy(&flow_table);
+
+ expr_addr_sets_destroy(&addr_sets);
+ shash_destroy(&addr_sets);
+
if (ctx.ovnsb_idl_txn) {
int64_t cur_cfg = ofctrl_get_cur_cfg();
if (cur_cfg && cur_cfg != chassis->nb_cfg) {
@@ -710,7 +711,6 @@ main(int argc, char *argv[])
pinctrl_destroy();
simap_destroy(&ct_zones);
- shash_destroy(&addr_sets);
bitmap_free(group_table.group_ids);
hmap_destroy(&group_table.desired_groups);
More information about the dev
mailing list