Skip to content

Commit

Permalink
ofp-actions: Update "copy_field" to latest OF1.5 draft.
Browse files Browse the repository at this point in the history
Since my original prototype, the oxm_id_len field was removed and
replaced by 2 bytes of padding.

ONF-JIRA: EXT-320
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Thomas Graf <[email protected]>
  • Loading branch information
blp committed Dec 5, 2014
1 parent 7631e9b commit 650763d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions lib/ofp-actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,13 +1710,13 @@ struct ofp15_action_copy_field {
ovs_be16 n_bits; /* Number of bits to copy. */
ovs_be16 src_offset; /* Starting bit offset in source. */
ovs_be16 dst_offset; /* Starting bit offset in destination. */
ovs_be16 oxm_id_len; /* Length of oxm_ids. */
uint8_t pad[2];
/* Followed by:
* - OXM header for source field.
* - OXM header for destination field.
* - Padding with 0-bytes to a multiple of 8 bytes.
* The "pad" member is the beginning of the above. */
uint8_t pad[4];
* The "pad2" member is the beginning of the above. */
uint8_t pad2[4];
};
OFP_ASSERT(sizeof(struct ofp15_action_copy_field) == 16);

Expand Down Expand Up @@ -1833,7 +1833,6 @@ decode_OFPAT_RAW15_COPY_FIELD(const struct ofp15_action_copy_field *oacf,
{
struct ofpact_reg_move *move;
enum ofperr error;
size_t orig_size;
struct ofpbuf b;

move = ofpact_put_REG_MOVE(ofpacts);
Expand All @@ -1843,8 +1842,7 @@ decode_OFPAT_RAW15_COPY_FIELD(const struct ofp15_action_copy_field *oacf,
move->dst.n_bits = ntohs(oacf->n_bits);

ofpbuf_use_const(&b, oacf, ntohs(oacf->len));
ofpbuf_pull(&b, offsetof(struct ofp15_action_copy_field, pad));
orig_size = ofpbuf_size(&b);
ofpbuf_pull(&b, offsetof(struct ofp15_action_copy_field, pad2));
error = nx_pull_header(&b, &move->src.field, NULL);
if (error) {
return error;
Expand All @@ -1853,9 +1851,6 @@ decode_OFPAT_RAW15_COPY_FIELD(const struct ofp15_action_copy_field *oacf,
if (error) {
return error;
}
if (orig_size - ofpbuf_size(&b) != ntohs(oacf->oxm_id_len)) {
return OFPERR_OFPBAC_BAD_LEN;
}

if (!is_all_zeros(ofpbuf_data(&b), ofpbuf_size(&b))) {
return OFPERR_NXBRC_MUST_BE_ZERO;
Expand Down Expand Up @@ -1905,8 +1900,7 @@ encode_REG_MOVE(const struct ofpact_reg_move *move,
copy->n_bits = htons(move->dst.n_bits);
copy->src_offset = htons(move->src.ofs);
copy->dst_offset = htons(move->dst.ofs);
copy->oxm_id_len = htons(8);
ofpbuf_set_size(out, ofpbuf_size(out) - sizeof copy->pad);
ofpbuf_set_size(out, ofpbuf_size(out) - sizeof copy->pad2);
nx_put_header(out, move->src.field->id, ofp_version, false);
nx_put_header(out, move->dst.field->id, ofp_version, false);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/ofp-actions.at
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ AT_DATA([test-data], [dnl
0000 0010 fffffffe 04d2 000000000000

# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
001c 0018 0010 0000 0000 0008 00000002 00000802 00000000
001c 0018 0010 0000 0000 0000 00000002 00000802 00000000

# actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
0019 0018 8000090c 000000001234 00000000ffff 00000000
Expand Down

0 comments on commit 650763d

Please sign in to comment.