Skip to content

Commit

Permalink
ofp-actions: Factor out decode_LEARN_{common,spec}().
Browse files Browse the repository at this point in the history
No functional change, they will be used by next commit.

Signed-off-by: Daniele Di Proietto <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
ddiproietto authored and blp committed Mar 16, 2017
1 parent 3f3b97b commit 2ce5f31
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions lib/ofp-actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -4379,43 +4379,38 @@ learn_min_len(uint16_t header)
return min_len;
}

/* Converts 'nal' into a "struct ofpact_learn" and appends that struct to
* 'ofpacts'. Returns 0 if successful, otherwise an OFPERR_*. */
static enum ofperr
decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
enum ofp_version ofp_version OVS_UNUSED,
const struct vl_mff_map *vl_mff_map,
uint64_t *tlv_bitmap, struct ofpbuf *ofpacts)
decode_LEARN_common(const struct nx_action_learn *nal,
struct ofpact_learn *learn)
{
struct ofpact_learn *learn;
const void *p, *end;

if (nal->pad) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}

learn = ofpact_put_LEARN(ofpacts);

learn->idle_timeout = ntohs(nal->idle_timeout);
learn->hard_timeout = ntohs(nal->hard_timeout);
learn->priority = ntohs(nal->priority);
learn->cookie = nal->cookie;
learn->table_id = nal->table_id;
learn->fin_idle_timeout = ntohs(nal->fin_idle_timeout);
learn->fin_hard_timeout = ntohs(nal->fin_hard_timeout);

learn->flags = ntohs(nal->flags);
if (learn->flags & ~(NX_LEARN_F_SEND_FLOW_REM |
NX_LEARN_F_DELETE_LEARNED)) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}

if (learn->table_id == 0xff) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}

end = (char *) nal + ntohs(nal->len);
for (p = nal + 1; p != end; ) {
return 0;
}

static enum ofperr
decode_LEARN_specs(const void *p, const void *end,
const struct vl_mff_map *vl_mff_map, uint64_t *tlv_bitmap,
struct ofpbuf *ofpacts)
{
struct ofpact_learn *learn = ofpacts->header;

while (p != end) {
struct ofpact_learn_spec *spec;
uint16_t header = ntohs(get_be16(&p));

Expand Down Expand Up @@ -4490,6 +4485,33 @@ decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
return 0;
}

/* Converts 'nal' into a "struct ofpact_learn" and appends that struct to
* 'ofpacts'. Returns 0 if successful, otherwise an OFPERR_*. */
static enum ofperr
decode_NXAST_RAW_LEARN(const struct nx_action_learn *nal,
enum ofp_version ofp_version OVS_UNUSED,
const struct vl_mff_map *vl_mff_map,
uint64_t *tlv_bitmap, struct ofpbuf *ofpacts)
{
struct ofpact_learn *learn;
enum ofperr error;

learn = ofpact_put_LEARN(ofpacts);

error = decode_LEARN_common(nal, learn);
if (error) {
return error;
}

if (learn->flags & ~(NX_LEARN_F_SEND_FLOW_REM |
NX_LEARN_F_DELETE_LEARNED)) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}

return decode_LEARN_specs(nal + 1, (char *) nal + ntohs(nal->len),
vl_mff_map, tlv_bitmap, ofpacts);
}

static void
put_be16(struct ofpbuf *b, ovs_be16 x)
{
Expand Down

0 comments on commit 2ce5f31

Please sign in to comment.