summaryrefslogtreecommitdiff
path: root/ovn
diff options
context:
space:
mode:
authorGuoshuai Li <ligs@dtdream.com>2018-02-02 10:50:29 +0800
committerBen Pfaff <blp@ovn.org>2018-02-02 14:27:10 -0800
commite50ed58a1f4218a905cde2bcd87132c2c8e70fd3 (patch)
tree14b648496bd9bb5ed1b1333382b13c079dba5547 /ovn
parent6c5c38ced4d126f6f99181156aee4316eeed429a (diff)
downloadopenvswitch-e50ed58a1f4218a905cde2bcd87132c2c8e70fd3.tar.gz
ovn-controller: Process logical flow matches before actions.
Otherwise, when the match field has "is_chassis_resident", and the match is not actually resident, and the action has meter or group, the group/meter ID is assigned even though it will never be used. Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovn')
-rw-r--r--ovn/controller/lflow.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index 1e79a5355..df125b188 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -254,31 +254,6 @@ consider_logical_flow(struct controller_ctx *ctx,
return;
}
- /* Encode OVN logical actions into OpenFlow. */
- uint64_t ofpacts_stub[1024 / 8];
- struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub);
- struct lookup_port_aux aux = {
- .ovnsb_idl = ctx->ovnsb_idl,
- .dp = lflow->logical_datapath
- };
- struct ovnact_encode_params ep = {
- .lookup_port = lookup_port_cb,
- .aux = &aux,
- .is_switch = is_switch(ldp),
- .is_gateway_router = is_gateway_router(ldp, local_datapaths),
- .group_table = group_table,
- .meter_table = meter_table,
-
- .pipeline = ingress ? OVNACT_P_INGRESS : OVNACT_P_EGRESS,
- .ingress_ptable = OFTABLE_LOG_INGRESS_PIPELINE,
- .egress_ptable = OFTABLE_LOG_EGRESS_PIPELINE,
- .output_ptable = output_ptable,
- .mac_bind_ptable = OFTABLE_MAC_BINDING,
- };
- ovnacts_encode(ovnacts.data, ovnacts.size, &ep, &ofpacts);
- ovnacts_free(ovnacts.data, ovnacts.size);
- ofpbuf_uninit(&ovnacts);
-
/* Translate OVN match into table of OpenFlow matches. */
struct hmap matches;
struct expr *expr;
@@ -296,11 +271,16 @@ consider_logical_flow(struct controller_ctx *ctx,
VLOG_WARN_RL(&rl, "error parsing match \"%s\": %s",
lflow->match, error);
expr_destroy(prereqs);
- ofpbuf_uninit(&ofpacts);
free(error);
+ ovnacts_free(ovnacts.data, ovnacts.size);
+ ofpbuf_uninit(&ovnacts);
return;
}
+ struct lookup_port_aux aux = {
+ .ovnsb_idl = ctx->ovnsb_idl,
+ .dp = lflow->logical_datapath
+ };
struct condition_aux cond_aux = { ctx->ovnsb_idl, chassis, active_tunnels,
chassis_index};
expr = expr_simplify(expr, is_chassis_resident_cb, &cond_aux);
@@ -309,6 +289,34 @@ consider_logical_flow(struct controller_ctx *ctx,
&matches);
expr_destroy(expr);
+ if (hmap_is_empty(&matches)) {
+ ovnacts_free(ovnacts.data, ovnacts.size);
+ ofpbuf_uninit(&ovnacts);
+ expr_matches_destroy(&matches);
+ return;
+ }
+
+ /* Encode OVN logical actions into OpenFlow. */
+ uint64_t ofpacts_stub[1024 / 8];
+ struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub);
+ struct ovnact_encode_params ep = {
+ .lookup_port = lookup_port_cb,
+ .aux = &aux,
+ .is_switch = is_switch(ldp),
+ .is_gateway_router = is_gateway_router(ldp, local_datapaths),
+ .group_table = group_table,
+ .meter_table = meter_table,
+
+ .pipeline = ingress ? OVNACT_P_INGRESS : OVNACT_P_EGRESS,
+ .ingress_ptable = OFTABLE_LOG_INGRESS_PIPELINE,
+ .egress_ptable = OFTABLE_LOG_EGRESS_PIPELINE,
+ .output_ptable = output_ptable,
+ .mac_bind_ptable = OFTABLE_MAC_BINDING,
+ };
+ ovnacts_encode(ovnacts.data, ovnacts.size, &ep, &ofpacts);
+ ovnacts_free(ovnacts.data, ovnacts.size);
+ ofpbuf_uninit(&ovnacts);
+
/* Prepare the OpenFlow matches for adding to the flow table. */
struct expr_match *m;
HMAP_FOR_EACH (m, hmap_node, &matches) {