}
static enum ofperr
-ofpacts_from_openflow10(const union ofp_action *in, size_t n_in,
- struct ofpbuf *out)
+ofpacts_from_openflow(const union ofp_action *in, size_t n_in,
+ struct ofpbuf *out,
+ enum ofperr (*ofpact_from_openflow)(
+ const union ofp_action *a, struct ofpbuf *out))
{
const union ofp_action *a;
size_t left;
ACTION_FOR_EACH (a, left, in, n_in) {
- enum ofperr error = ofpact_from_openflow10(a, out);
+ enum ofperr error = ofpact_from_openflow(a, out);
if (error) {
log_bad_action(in, n_in, a - in, error);
return error;
return 0;
}
+static enum ofperr
+ofpacts_from_openflow10(const union ofp_action *in, size_t n_in,
+ struct ofpbuf *out)
+{
+ return ofpacts_from_openflow(in, n_in, out, ofpact_from_openflow10);
+}
+
static enum ofperr
ofpacts_pull_actions(struct ofpbuf *openflow, unsigned int actions_len,
struct ofpbuf *ofpacts,
ofpacts_from_openflow11(const union ofp_action *in, size_t n_in,
struct ofpbuf *out)
{
- const union ofp_action *a;
- size_t left;
-
- ACTION_FOR_EACH (a, left, in, n_in) {
- enum ofperr error = ofpact_from_openflow11(a, out);
- if (error) {
- VLOG_WARN_RL(&rl, "bad action at offset %td (%s)",
- (a - in) * sizeof *a, ofperr_get_name(error));
- return error;
- }
- }
- if (left) {
- VLOG_WARN_RL(&rl, "bad action format at offset %zu",
- (n_in - left) * sizeof *a);
- return OFPERR_OFPBAC_BAD_LEN;
- }
-
- return 0;
+ return ofpacts_from_openflow(in, n_in, out, ofpact_from_openflow11);
}
\f
/* OpenFlow 1.1 instructions. */
unsigned int actions_len,
struct ofpbuf *ofpacts)
{
- enum ofperr error;
-
- error = ofpacts_pull_actions(openflow, actions_len, ofpacts,
- ofpacts_from_openflow11);
- if (!error) {
- ofpact_pad(ofpacts);
- }
- return error;
+ return ofpacts_pull_actions(openflow, actions_len, ofpacts,
+ ofpacts_from_openflow11);
}
enum ofperr
}
}
- ofpact_pad(ofpacts);
-
if (insts[OVSINST_OFPIT11_GOTO_TABLE] ||
insts[OVSINST_OFPIT11_WRITE_METADATA] ||
insts[OVSINST_OFPIT11_WRITE_ACTIONS] ||
/* Converts the ofpacts in 'ofpacts' (terminated by OFPACT_END) into OpenFlow
* 1.1 actions in 'openflow', appending the actions to any existing data in
* 'openflow'. */
-void
+size_t
ofpacts_put_openflow11_actions(const struct ofpact ofpacts[],
size_t ofpacts_len, struct ofpbuf *openflow)
{
const struct ofpact *a;
+ size_t start_size = openflow->size;
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
ofpact_to_openflow11(a, openflow);
}
+
+ return openflow->size - start_size;
}
void