case NX_LEARN_DST_LOAD:
for (ofs = 0; ofs < spec->n_bits; ofs += chunk) {
struct ofpact_reg_load *load;
- ovs_be64 value_be;
chunk = MIN(spec->n_bits - ofs, 64);
load->dst.field = spec->dst.field;
load->dst.ofs = spec->dst.ofs + ofs;
load->dst.n_bits = chunk;
-
- memset(&value_be, 0, sizeof value_be);
bitwise_copy(&value, sizeof value, ofs,
- &value_be, sizeof value_be, 0,
+ &load->subvalue, sizeof load->subvalue, 0,
chunk);
- load->value = ntohll(value_be);
}
break;
*
* 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
-format_subvalue(const union mf_subvalue *subvalue, struct ds *s)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(subvalue->u8); i++) {
- if (subvalue->u8[i]) {
- ds_put_format(s, "0x%"PRIx8, subvalue->u8[i]);
- for (i++; i < ARRAY_SIZE(subvalue->u8); i++) {
- ds_put_format(s, "%02"PRIx8, subvalue->u8[i]);
- }
- return;
- }
- }
- ds_put_char(s, '0');
-}
-
/* Appends a description of 'learn' to 's', in the format that ovs-ofctl(8)
* describes. */
void
} else {
mf_format_subfield(&spec->dst, s);
ds_put_char(s, '=');
- format_subvalue(&spec->src_imm, s);
+ mf_format_subvalue(&spec->src_imm, s);
}
break;
case NX_LEARN_SRC_IMMEDIATE | NX_LEARN_DST_LOAD:
ds_put_format(s, "load:");
- format_subvalue(&spec->src_imm, s);
+ mf_format_subvalue(&spec->src_imm, s);
ds_put_cstr(s, "->");
mf_format_subfield(&spec->dst, s);
break;