Skip to content

Commit

Permalink
ovn: add is_chassis_resident match expression component
Browse files Browse the repository at this point in the history
This patch introduces a new match expression component
is_chassis_resident().  Unlike match expression comparisons,
is_chassis_resident is not pushed down to OpenFlow.  It is a
conditional that is evaluated in the controller during expr_simplify(),
when it is replaced by a boolean expression.  The is_chassis_resident
conditional evaluates to "true" when the specified string identifies a
port name that is resident on this controller chassis, i.e., the
corresponding southbound database Port_Binding has a chassis column
that matches this chassis.  Otherwise it evaluates to "false".

This allows higher level features to specify flows that are only
installed on some chassis rather than on all chassis with the
corresponding datapath.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Mickey Spiegel <mickeys.dev@gmail.com>
Acked-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
emspiegel authored and blp committed Jan 19, 2017
1 parent 3afefab commit ba8d381
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 17 deletions.
22 changes: 21 additions & 1 deletion include/ovn/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ enum expr_type {
EXPR_T_AND, /* Logical AND of 2 or more subexpressions. */
EXPR_T_OR, /* Logical OR of 2 or more subexpressions. */
EXPR_T_BOOLEAN, /* True or false constant. */
EXPR_T_CONDITION, /* Conditional to be evaluated in the
* controller during expr_simplify(),
* prior to constructing OpenFlow matches. */
};

/* Expression condition type. */
enum expr_cond_type {
EXPR_COND_CHASSIS_RESIDENT, /* Check if specified logical port name is
* resident on the controller chassis. */
};

/* Relational operator. */
Expand Down Expand Up @@ -349,6 +358,14 @@ struct expr {

/* EXPR_T_BOOLEAN. */
bool boolean;

/* EXPR_T_CONDITION. */
struct {
enum expr_cond_type type;
bool not;
/* XXX Should arguments for conditions be generic? */
char *string;
} cond;
};
};

Expand All @@ -375,7 +392,10 @@ void expr_destroy(struct expr *);

struct expr *expr_annotate(struct expr *, const struct shash *symtab,
char **errorp);
struct expr *expr_simplify(struct expr *);
struct expr *expr_simplify(struct expr *,
bool (*is_chassis_resident)(const void *c_aux,
const char *port_name),
const void *c_aux);
struct expr *expr_normalize(struct expr *);

bool expr_honors_invariants(const struct expr *);
Expand Down
31 changes: 26 additions & 5 deletions ovn/controller/lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ struct lookup_port_aux {
const struct sbrec_datapath_binding *dp;
};

struct condition_aux {
const struct lport_index *lports;
const struct sbrec_chassis *chassis;
};

static void consider_logical_flow(const struct lport_index *lports,
const struct mcgroup_index *mcgroups,
const struct sbrec_logical_flow *lflow,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
const struct sbrec_chassis *chassis,
struct hmap *dhcp_opts,
struct hmap *dhcpv6_opts,
uint32_t *conj_id_ofs,
Expand Down Expand Up @@ -84,6 +90,16 @@ lookup_port_cb(const void *aux_, const char *port_name, unsigned int *portp)
return false;
}

static bool
is_chassis_resident_cb(const void *c_aux_, const char *port_name)
{
const struct condition_aux *c_aux = c_aux_;

const struct sbrec_port_binding *pb
= lport_lookup_by_name(c_aux->lports, port_name);
return pb && pb->chassis && pb->chassis == c_aux->chassis;
}

static bool
is_switch(const struct sbrec_datapath_binding *ldp)
{
Expand All @@ -98,6 +114,7 @@ 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,
const struct sbrec_chassis *chassis,
const struct shash *addr_sets,
struct hmap *flow_table)
{
Expand All @@ -121,7 +138,7 @@ add_logical_flows(struct controller_ctx *ctx, const struct lport_index *lports,

SBREC_LOGICAL_FLOW_FOR_EACH (lflow, ctx->ovnsb_idl) {
consider_logical_flow(lports, mcgroups, lflow, local_datapaths,
group_table, ct_zones,
group_table, ct_zones, chassis,
&dhcp_opts, &dhcpv6_opts, &conj_id_ofs,
addr_sets, flow_table);
}
Expand All @@ -137,6 +154,7 @@ consider_logical_flow(const struct lport_index *lports,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
const struct sbrec_chassis *chassis,
struct hmap *dhcp_opts,
struct hmap *dhcpv6_opts,
uint32_t *conj_id_ofs,
Expand Down Expand Up @@ -235,7 +253,8 @@ consider_logical_flow(const struct lport_index *lports,
return;
}

expr = expr_simplify(expr);
struct condition_aux cond_aux = { lports, chassis };
expr = expr_simplify(expr, is_chassis_resident_cb, &cond_aux);
expr = expr_normalize(expr);
uint32_t n_conjs = expr_to_matches(expr, lookup_port_cb, &aux,
&matches);
Expand Down Expand Up @@ -356,16 +375,18 @@ add_neighbor_flows(struct controller_ctx *ctx,
/* Translates logical flows in the Logical_Flow table in the OVN_SB database
* into OpenFlow flows. See ovn-architecture(7) for more information. */
void
lflow_run(struct controller_ctx *ctx, const struct lport_index *lports,
lflow_run(struct controller_ctx *ctx,
const struct sbrec_chassis *chassis,
const struct lport_index *lports,
const struct mcgroup_index *mcgroups,
const struct hmap *local_datapaths,
struct group_table *group_table,
const struct simap *ct_zones,
const struct shash *addr_sets,
struct hmap *flow_table)
{
add_logical_flows(ctx, lports, mcgroups, local_datapaths,
group_table, ct_zones, addr_sets, flow_table);
add_logical_flows(ctx, lports, mcgroups, local_datapaths, group_table,
ct_zones, chassis, addr_sets, flow_table);
add_neighbor_flows(ctx, lports, flow_table);
}

Expand Down
5 changes: 4 additions & 1 deletion ovn/controller/lflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct group_table;
struct hmap;
struct lport_index;
struct mcgroup_index;
struct sbrec_chassis;
struct simap;
struct uuid;

Expand All @@ -61,7 +62,9 @@ struct uuid;
#define LOG_PIPELINE_LEN 16

void lflow_init(void);
void lflow_run(struct controller_ctx *, const struct lport_index *,
void lflow_run(struct controller_ctx *,
const struct sbrec_chassis *chassis,
const struct lport_index *,
const struct mcgroup_index *,
const struct hmap *local_datapaths,
struct group_table *group_table,
Expand Down
5 changes: 3 additions & 2 deletions ovn/controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@ main(int argc, char *argv[])
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, &addr_sets, &flow_table);
lflow_run(&ctx, chassis, &lports, &mcgroups,
&local_datapaths, &group_table, &ct_zones,
&addr_sets, &flow_table);

physical_run(&ctx, mff_ovn_geneve,
br_int, chassis, &ct_zones, &lports,
Expand Down
Loading

0 comments on commit ba8d381

Please sign in to comment.