summaryrefslogtreecommitdiff
path: root/lib/ofp-flow.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-06-15 16:29:22 -0700
committerBen Pfaff <blp@ovn.org>2018-07-31 13:11:13 -0700
commitae6f7530bff39c62d3b7d1baab93623d8f5f3db1 (patch)
tree0db01af5bfa256b1b7b4cfec1efe73a6b08649dd /lib/ofp-flow.c
parent86c6aa826e9274e5cb0e49159ba5e825c43065b2 (diff)
downloadopenvswitch-ae6f7530bff39c62d3b7d1baab93623d8f5f3db1.tar.gz
ofp-actions: Split ofpacts_check__() into many functions.
ofpacts_check__() was a huge switch statement with special cases for many different kinds of actions. This made it unwieldy and put the special cases far away from the rest of the code related to a given action. This commit refactors the code to avoid the problem. Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Yifeng Sun <pkusunyifeng@gmail.com> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Diffstat (limited to 'lib/ofp-flow.c')
-rw-r--r--lib/ofp-flow.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/ofp-flow.c b/lib/ofp-flow.c
index 4b893ce95..f6b3f556e 100644
--- a/lib/ofp-flow.c
+++ b/lib/ofp-flow.c
@@ -343,9 +343,14 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
: OFPERR_OFPFMFC_TABLE_FULL);
}
+ struct ofpact_check_params cp = {
+ .match = &match,
+ .max_ports = max_port,
+ .table_id = fm->table_id,
+ .n_tables = max_table
+ };
error = ofpacts_check_consistency(fm->ofpacts, fm->ofpacts_len,
- &match, max_port,
- fm->table_id, max_table, protocol);
+ protocol, &cp);
if (!error) {
minimatch_init(&fm->match, &match);
}
@@ -1723,8 +1728,14 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string,
if (!error) {
enum ofperr err;
- err = ofpacts_check(ofpacts.data, ofpacts.size, &match,
- OFPP_MAX, fm->table_id, 255, usable_protocols);
+ struct ofpact_check_params cp = {
+ .match = &match,
+ .max_ports = OFPP_MAX,
+ .table_id = fm->table_id,
+ .n_tables = 255,
+ };
+ err = ofpacts_check(ofpacts.data, ofpacts.size, &cp);
+ *usable_protocols &= cp.usable_protocols;
if (!err && !*usable_protocols) {
err = OFPERR_OFPBAC_MATCH_INCONSISTENT;
}