*
* Modifies 'arg'. */
void
-learn_parse(char *arg, const struct flow *flow, struct ofpbuf *ofpacts)
+learn_parse(char *arg, struct ofpbuf *ofpacts)
{
char *orig = xstrdup(arg);
char *name, *value;
struct ofpact_learn *learn;
struct match match;
- enum ofperr error;
learn = ofpact_put_LEARN(ofpacts);
learn->idle_timeout = OFP_FLOW_PERMANENT;
learn_parse_spec(orig, name, value, spec);
- /* Check prerequisites. */
- if (spec->src_type == NX_LEARN_SRC_FIELD
- && flow && !mf_are_prereqs_ok(spec->src.field, flow)) {
- ovs_fatal(0, "%s: cannot specify source field %s because "
- "prerequisites are not satisfied",
- orig, spec->src.field->name);
- }
- if ((spec->dst_type == NX_LEARN_DST_MATCH
- || spec->dst_type == NX_LEARN_DST_LOAD)
- && !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 'match' to allow for satisfying destination
* prerequisites. */
if (spec->src_type == NX_LEARN_SRC_IMMEDIATE
}
ofpact_update_len(ofpacts, &learn->ofpact);
- /* In theory the above should have caught any errors, but... */
- if (flow) {
- error = learn_check(learn, flow);
- if (error) {
- ovs_fatal(0, "%s: %s", orig, ofperr_to_string(error));
- }
- }
free(orig);
}
}
static void
-parse_named_action(enum ofputil_action_code code, const struct flow *flow,
+parse_named_action(enum ofputil_action_code code,
char *arg, struct ofpbuf *ofpacts)
{
struct ofpact_tunnel *tunnel;
NOT_REACHED();
case OFPUTIL_NXAST_LEARN:
- learn_parse(arg, flow, ofpacts);
+ learn_parse(arg, ofpacts);
break;
case OFPUTIL_NXAST_EXIT:
}
static bool
-str_to_ofpact__(const struct flow *flow, char *pos, char *act, char *arg,
+str_to_ofpact__(char *pos, char *act, char *arg,
struct ofpbuf *ofpacts, int n_actions)
{
int code = ofputil_action_code_from_name(act);
if (code >= 0) {
- parse_named_action(code, flow, arg, ofpacts);
+ parse_named_action(code, arg, ofpacts);
} else if (!strcasecmp(act, "drop")) {
if (n_actions) {
ovs_fatal(0, "Drop actions must not be preceded by other "
}
static void
-str_to_ofpacts(const struct flow *flow, char *str, struct ofpbuf *ofpacts)
+str_to_ofpacts(char *str, struct ofpbuf *ofpacts)
{
char *pos, *act, *arg;
enum ofperr error;
pos = str;
n_actions = 0;
while (ofputil_parse_key_value(&pos, &act, &arg)) {
- if (!str_to_ofpact__(flow, pos, act, arg, ofpacts, n_actions)) {
+ if (!str_to_ofpact__(pos, act, arg, ofpacts, n_actions)) {
break;
}
n_actions++;
}
static void
-str_to_inst_ofpacts(const struct flow *flow, char *str, struct ofpbuf *ofpacts)
+str_to_inst_ofpacts(char *str, struct ofpbuf *ofpacts)
{
char *pos, *inst, *arg;
int type;
while (ofputil_parse_key_value(&pos, &inst, &arg)) {
type = ofpact_instruction_type_from_name(inst);
if (type < 0) {
- if (!str_to_ofpact__(flow, pos, inst, arg, ofpacts, n_actions)) {
+ if (!str_to_ofpact__(pos, inst, arg, ofpacts, n_actions)) {
break;
}
enum ofperr err;
ofpbuf_init(&ofpacts, 32);
- str_to_inst_ofpacts(&fm->match.flow, act_str, &ofpacts);
+ str_to_inst_ofpacts(act_str, &ofpacts);
fm->ofpacts_len = ofpacts.size;
fm->ofpacts = ofpbuf_steal_data(&ofpacts);
parse_ofpacts(const char *s_, struct ofpbuf *ofpacts)
{
char *s = xstrdup(s_);
- str_to_ofpacts(NULL, s, ofpacts);
+ str_to_ofpacts(s, ofpacts);
free(s);
}
AT_SETUP([learning action - invalid prerequisites])
AT_CHECK([[ovs-ofctl parse-flow 'actions=learn(load:5->NXM_OF_IP_DST[])']],
- [1], [],
- [[ovs-ofctl: load:5->NXM_OF_IP_DST[]: cannot specify destination field ip_dst because prerequisites are not satisfied
-]])
+ [1], [], [stderr])
+AT_CHECK([sed -e 's/.*|meta_flow|WARN|//' < stderr], [0],
+ [[destination field ip_dst lacks correct prerequisites
+]], [[]])
AT_CHECK([[ovs-ofctl parse-flow 'actions=learn(load:NXM_OF_IP_DST[]->NXM_NX_REG1[])']],
- [1], [],
- [[ovs-ofctl: load:NXM_OF_IP_DST[]->NXM_NX_REG1[]: cannot specify source field ip_dst because prerequisites are not satisfied
+ [1], [], [stderr])
+AT_CHECK([sed -e 's/.*|meta_flow|WARN|//' < stderr], [0],
+ [[source field ip_dst lacks correct prerequisites
]])
AT_CLEANUP