Skip to content

Commit

Permalink
ofp-actions: Rename ofpact_update_len() to ofpact_finish().
Browse files Browse the repository at this point in the history
It does more than just update the length now, so this is a more accurate
name.

Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Russell Bryant <[email protected]>
  • Loading branch information
blp committed Jan 5, 2016
1 parent 2bd318d commit 34abaa3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bundle_parse__(const char *s, char **save_ptr,
bundle = ofpacts->header;
bundle->n_slaves++;
}
ofpact_update_len(ofpacts, &bundle->ofpact);
ofpact_finish(ofpacts, &bundle->ofpact);

bundle->basis = atoi(basis);

Expand Down
2 changes: 1 addition & 1 deletion lib/learn.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ learn_parse__(char *orig, char *arg, struct ofpbuf *ofpacts)
}
}
}
ofpact_update_len(ofpacts, &learn->ofpact);
ofpact_finish(ofpacts, &learn->ofpact);

return NULL;
}
Expand Down
22 changes: 11 additions & 11 deletions lib/ofp-actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ decode_bundle(bool load, const struct nx_action_bundle *nab,
}

bundle = ofpacts->header;
ofpact_update_len(ofpacts, &bundle->ofpact);
ofpact_finish(ofpacts, &bundle->ofpact);

if (!error) {
error = bundle_check(bundle, OFPP_MAX, NULL);
Expand Down Expand Up @@ -2933,7 +2933,7 @@ decode_OFPAT_RAW_DEC_NW_TTL(struct ofpbuf *out)
ids->n_controllers = 1;
ofpbuf_put(out, &id, sizeof id);
ids = out->header;
ofpact_update_len(out, &ids->ofpact);
ofpact_finish(out, &ids->ofpact);
return error;
}

Expand Down Expand Up @@ -2970,7 +2970,7 @@ decode_NXAST_RAW_DEC_TTL_CNT_IDS(const struct nx_action_cnt_ids *nac_ids,
ids = out->header;
}

ofpact_update_len(out, &ids->ofpact);
ofpact_finish(out, &ids->ofpact);

return 0;
}
Expand Down Expand Up @@ -3009,7 +3009,7 @@ parse_noargs_dec_ttl(struct ofpbuf *ofpacts)
ofpbuf_put(ofpacts, &id, sizeof id);
ids = ofpacts->header;
ids->n_controllers++;
ofpact_update_len(ofpacts, &ids->ofpact);
ofpact_finish(ofpacts, &ids->ofpact);
}

static char * OVS_WARN_UNUSED_RESULT
Expand All @@ -3036,7 +3036,7 @@ parse_DEC_TTL(char *arg, struct ofpbuf *ofpacts,
return xstrdup("dec_ttl_cnt_ids: expected at least one controller "
"id.");
}
ofpact_update_len(ofpacts, &ids->ofpact);
ofpact_finish(ofpacts, &ids->ofpact);
}
return NULL;
}
Expand Down Expand Up @@ -4054,7 +4054,7 @@ decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
get_subfield(spec->n_bits, &p, &spec->dst);
}
}
ofpact_update_len(ofpacts, &learn->ofpact);
ofpact_finish(ofpacts, &learn->ofpact);

if (!is_all_zeros(p, (char *) end - (char *) p)) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
Expand Down Expand Up @@ -4378,7 +4378,7 @@ decode_NXAST_RAW_NOTE(const struct nx_action_note *nan,
note = ofpact_put_NOTE(out);
note->length = length;
ofpbuf_put(out, nan->note, length);
ofpact_update_len(out, out->header);
ofpact_finish(out, out->header);

return 0;
}
Expand Down Expand Up @@ -4426,7 +4426,7 @@ parse_NOTE(const char *arg, struct ofpbuf *ofpacts,

arg += 2;
}
ofpact_update_len(ofpacts, &note->ofpact);
ofpact_finish(ofpacts, &note->ofpact);
return NULL;
}

Expand Down Expand Up @@ -4833,7 +4833,7 @@ decode_NXAST_RAW_CT(const struct nx_action_conntrack *nac,

conntrack = ofpbuf_push_uninit(out, sizeof(*conntrack));
out->header = &conntrack->ofpact;
ofpact_update_len(out, &conntrack->ofpact);
ofpact_finish(out, &conntrack->ofpact);

if (conntrack->ofpact.len > sizeof(*conntrack)
&& !(conntrack->flags & NX_CT_F_COMMIT)) {
Expand Down Expand Up @@ -4954,7 +4954,7 @@ parse_CT(char *arg, struct ofpbuf *ofpacts,
}
}

ofpact_update_len(ofpacts, &oc->ofpact);
ofpact_finish(ofpacts, &oc->ofpact);
ofpbuf_push_uninit(ofpacts, ct_offset);
return error;
}
Expand Down Expand Up @@ -7282,7 +7282,7 @@ ofpact_init(struct ofpact *ofpact, enum ofpact_type type, size_t len)
* bytes and updating its embedded length field. See the large comment near
* the end of ofp-actions.h for more information. */
void
ofpact_update_len(struct ofpbuf *ofpacts, struct ofpact *ofpact)
ofpact_finish(struct ofpbuf *ofpacts, struct ofpact *ofpact)
{
ovs_assert(ofpact == ofpacts->header);
ofpact->len = (char *) ofpbuf_tail(ofpacts) - (char *) ofpact;
Expand Down
9 changes: 4 additions & 5 deletions lib/ofp-actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,9 @@ void *ofpact_put(struct ofpbuf *, enum ofpact_type, size_t len);
*
* After using this function to add a variable-length action, add the
* elements of the flexible array (e.g. with ofpbuf_put()), then use
* ofpact_update_len() to pad the action to a multiple of OFPACT_ALIGNTO
* bytes and update its embedded length field. (Keep in mind the need to
* refresh the structure from 'ofpacts->header' after adding data to
* 'ofpacts'.)
* ofpact_finish() to pad the action to a multiple of OFPACT_ALIGNTO bytes
* and update its embedded length field. (Keep in mind the need to refresh
* the structure from 'ofpacts->header' after adding data to 'ofpacts'.)
*
* struct <STRUCT> *ofpact_get_<ENUM>(const struct ofpact *ofpact);
*
Expand Down Expand Up @@ -958,7 +957,7 @@ OFPACTS
#undef OFPACT

/* Call after adding the variable-length part to a variable-length action. */
void ofpact_update_len(struct ofpbuf *, struct ofpact *);
void ofpact_finish(struct ofpbuf *, struct ofpact *);

/* Additional functions for composing ofpacts. */
struct ofpact_set_field *ofpact_put_reg_load(struct ofpbuf *ofpacts);
Expand Down

0 comments on commit 34abaa3

Please sign in to comment.