Skip to content

Commit

Permalink
ovn-controller: Expose address sets to the main loop.
Browse files Browse the repository at this point in the history
Other functions in the main loop will need access to address sets in a
future commit.

Signed-off-by: Justin Pettit <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
justinpettit committed Jan 5, 2017
1 parent b34e898 commit d49a357
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
41 changes: 10 additions & 31 deletions ovn/controller/lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@ lflow_init(void)
{
ovn_init_symtab(&symtab);
}

/* Iterate address sets in the southbound database. Create and update the
* corresponding symtab entries as necessary. */
static void
update_address_sets(struct controller_ctx *ctx,
struct shash *expr_address_sets_p)

{
const struct sbrec_address_set *as;
SBREC_ADDRESS_SET_FOR_EACH (as, ctx->ovnsb_idl) {
expr_addr_sets_add(expr_address_sets_p, as->name,
(const char *const *) as->addresses,
as->n_addresses);
}
}

struct lookup_port_aux {
const struct lport_index *lports;
Expand All @@ -74,8 +59,8 @@ static void consider_logical_flow(const struct lport_index *lports,
struct hmap *dhcp_opts_p,
struct hmap *dhcpv6_opts_p,
uint32_t *conj_id_ofs_p,
struct hmap *flow_table,
struct shash *expr_address_sets_p);
const struct shash *addr_sets,
struct hmap *flow_table);

static bool
lookup_port_cb(const void *aux_, const char *port_name, unsigned int *portp)
Expand Down Expand Up @@ -113,8 +98,8 @@ add_logical_flows(struct controller_ctx *ctx, const struct lport_index *lports,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
struct hmap *flow_table,
struct shash *expr_address_sets_p)
const struct shash *addr_sets,
struct hmap *flow_table)
{
uint32_t conj_id_ofs = 1;
const struct sbrec_logical_flow *lflow;
Expand All @@ -138,7 +123,7 @@ add_logical_flows(struct controller_ctx *ctx, const struct lport_index *lports,
consider_logical_flow(lports, mcgroups, lflow, local_datapaths,
group_table, ct_zones,
&dhcp_opts, &dhcpv6_opts, &conj_id_ofs,
flow_table, expr_address_sets_p);
addr_sets, flow_table);
}

dhcp_opts_destroy(&dhcp_opts);
Expand All @@ -155,8 +140,8 @@ consider_logical_flow(const struct lport_index *lports,
struct hmap *dhcp_opts_p,
struct hmap *dhcpv6_opts_p,
uint32_t *conj_id_ofs_p,
struct hmap *flow_table,
struct shash *expr_address_sets_p)
const struct shash *addr_sets,
struct hmap *flow_table)
{
/* Determine translation of logical table IDs to physical table IDs. */
bool ingress = !strcmp(lflow->pipeline, "ingress");
Expand Down Expand Up @@ -232,8 +217,7 @@ consider_logical_flow(const struct lport_index *lports,
struct hmap matches;
struct expr *expr;

expr = expr_parse_string(lflow->match, &symtab,
expr_address_sets_p, &error);
expr = expr_parse_string(lflow->match, &symtab, addr_sets, &error);
if (!error) {
if (prereqs) {
expr = expr_combine(EXPR_T_AND, expr, prereqs);
Expand Down Expand Up @@ -377,17 +361,12 @@ lflow_run(struct controller_ctx *ctx, const struct lport_index *lports,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
const struct shash *addr_sets,
struct hmap *flow_table)
{
struct shash expr_address_sets = SHASH_INITIALIZER(&expr_address_sets);

update_address_sets(ctx, &expr_address_sets);
add_logical_flows(ctx, lports, mcgroups, local_datapaths,
group_table, ct_zones, flow_table, &expr_address_sets);
group_table, ct_zones, addr_sets, flow_table);
add_neighbor_flows(ctx, lports, flow_table);

expr_addr_sets_destroy(&expr_address_sets);
shash_destroy(&expr_address_sets);
}

void
Expand Down
1 change: 1 addition & 0 deletions ovn/controller/lflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void lflow_run(struct controller_ctx *, const struct lport_index *,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
const struct shash *addr_sets,
struct hmap *flow_table);
void lflow_destroy(void);

Expand Down
22 changes: 21 additions & 1 deletion ovn/controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,19 @@ get_chassis_id(const struct ovsdb_idl *ovs_idl)
return chassis_id;
}

/* Iterate address sets in the southbound database. Create and update the
* corresponding symtab entries as necessary. */
static void
addr_sets_init(struct controller_ctx *ctx, struct shash *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,
(const char *const *) as->addresses,
as->n_addresses);
}
}

/* Retrieves the OVN Southbound remote location from the
* "external-ids:ovn-remote" key in 'ovs_idl' and returns a copy of it. */
static char *
Expand Down Expand Up @@ -589,11 +602,14 @@ 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) {
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);
lflow_run(&ctx, &lports, &mcgroups, &local_datapaths,
&group_table, &ct_zones, &flow_table);
&group_table, &ct_zones, &addr_sets, &flow_table);

physical_run(&ctx, mff_ovn_geneve,
br_int, chassis, &ct_zones, &lports,
Expand All @@ -602,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) {
Expand Down

0 comments on commit d49a357

Please sign in to comment.