X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Flearn.c;h=cd7532179340d95ebffc99c8b3033225619fd886;hb=81a76618be9ea195a1e4a881ba9591728891d10b;hp=28b8012c6ff2add47b51289936e53d5cc3a8cbfb;hpb=dbda2960f64238e80570aafeae7af5a752f54f59;p=sliver-openvswitch.git diff --git a/lib/learn.c b/lib/learn.c index 28b8012c6..cd7532179 100644 --- a/lib/learn.c +++ b/lib/learn.c @@ -20,6 +20,7 @@ #include "byte-order.h" #include "dynamic-string.h" +#include "match.h" #include "meta-flow.h" #include "nx-match.h" #include "ofp-actions.h" @@ -170,9 +171,9 @@ enum ofperr learn_check(const struct ofpact_learn *learn, const struct flow *flow) { const struct ofpact_learn_spec *spec; - struct cls_rule rule; + struct match match; - cls_rule_init_catchall(&rule, 0); + match_init_catchall(&match); for (spec = learn->specs; spec < &learn->specs[learn->n_specs]; spec++) { enum ofperr error; @@ -187,16 +188,16 @@ learn_check(const struct ofpact_learn *learn, const struct flow *flow) /* Check the destination. */ switch (spec->dst_type) { case NX_LEARN_DST_MATCH: - error = mf_check_src(&spec->dst, &rule.flow); + error = mf_check_src(&spec->dst, &match.flow); if (error) { return error; } - mf_write_subfield(&spec->dst, &spec->src_imm, &rule); + mf_write_subfield(&spec->dst, &spec->src_imm, &match); break; case NX_LEARN_DST_LOAD: - error = mf_check_dst(&spec->dst, &rule.flow); + error = mf_check_dst(&spec->dst, &match.flow); if (error) { return error; } @@ -297,7 +298,8 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow, { const struct ofpact_learn_spec *spec; - cls_rule_init_catchall(&fm->cr, learn->priority); + match_init_catchall(&fm->match); + fm->priority = learn->priority; fm->cookie = htonll(0); fm->cookie_mask = htonll(0); fm->new_cookie = htonll(learn->cookie); @@ -331,7 +333,7 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow, switch (spec->dst_type) { case NX_LEARN_DST_MATCH: - mf_write_subfield(&spec->dst, &value, &fm->cr); + mf_write_subfield(&spec->dst, &value, &fm->match); break; case NX_LEARN_DST_LOAD: @@ -508,7 +510,7 @@ learn_parse_spec(const char *orig, char *name, char *value, * * Prints an error on stderr and aborts the program if 'arg' syntax is invalid. * - * If 'flow' is nonnull, then it should be the flow from a cls_rule that is + * If 'flow' is nonnull, then it should be the flow from a struct match that is * the matching rule for the learning action. This helps to better validate * the action's arguments. * @@ -520,7 +522,7 @@ learn_parse(char *arg, const struct flow *flow, struct ofpbuf *ofpacts) char *name, *value; struct ofpact_learn *learn; - struct cls_rule rule; + struct match match; enum ofperr error; learn = ofpact_put_LEARN(ofpacts); @@ -529,7 +531,7 @@ learn_parse(char *arg, const struct flow *flow, struct ofpbuf *ofpacts) learn->priority = OFP_DEFAULT_PRIORITY; learn->table_id = 1; - cls_rule_init_catchall(&rule, 0); + match_init_catchall(&match); while (ofputil_parse_key_value(&arg, &name, &value)) { if (!strcmp(name, "table")) { learn->table_id = atoi(value); @@ -567,17 +569,17 @@ learn_parse(char *arg, const struct flow *flow, struct ofpbuf *ofpacts) } if ((spec->dst_type == NX_LEARN_DST_MATCH || spec->dst_type == NX_LEARN_DST_LOAD) - && !mf_are_prereqs_ok(spec->dst.field, &rule.flow)) { + && !mf_are_prereqs_ok(spec->dst.field, &match.flow)) { ovs_fatal(0, "%s: cannot specify destination field %s because " "prerequisites are not satisfied", orig, spec->dst.field->name); } - /* Update 'rule' to allow for satisfying destination + /* Update 'match' to allow for satisfying destination * prerequisites. */ if (spec->src_type == NX_LEARN_SRC_IMMEDIATE && spec->dst_type == NX_LEARN_DST_MATCH) { - mf_write_subfield(&spec->dst, &spec->src_imm, &rule); + mf_write_subfield(&spec->dst, &spec->src_imm, &match); } } } @@ -616,9 +618,9 @@ void learn_format(const struct ofpact_learn *learn, struct ds *s) { const struct ofpact_learn_spec *spec; - struct cls_rule rule; + struct match match; - cls_rule_init_catchall(&rule, 0); + match_init_catchall(&match); ds_put_format(s, "learn(table=%"PRIu8, learn->table_id); if (learn->idle_timeout != OFP_FLOW_PERMANENT) {