mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ofp-actions: Right-justify the value in ofpact_reg_load 'subvalue' member.
This is what I intended when I suggested using mf_subvalue, but I didn't notice the difference until after applying the patch. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
@@ -346,7 +346,9 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
|
||||
load->dst.field = spec->dst.field;
|
||||
load->dst.ofs = spec->dst.ofs + ofs;
|
||||
load->dst.n_bits = chunk;
|
||||
load->subvalue = value;
|
||||
bitwise_copy(&value, sizeof value, ofs,
|
||||
&load->subvalue, sizeof load->subvalue, 0,
|
||||
chunk);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -2164,7 +2164,7 @@ mf_write_subfield_flow(const struct mf_subfield *sf,
|
||||
union mf_value value;
|
||||
|
||||
mf_get_value(field, flow, &value);
|
||||
bitwise_copy(x, sizeof *x, sf->ofs, &value, field->n_bytes,
|
||||
bitwise_copy(x, sizeof *x, 0, &value, field->n_bytes,
|
||||
sf->ofs, sf->n_bits);
|
||||
mf_set_flow_value(field, &value, flow);
|
||||
}
|
||||
|
@@ -989,7 +989,6 @@ nxm_parse_reg_load(struct ofpact_reg_load *load, const char *s)
|
||||
{
|
||||
const char *full_s = s;
|
||||
uint64_t value = strtoull(s, (char **) &s, 0);
|
||||
ovs_be64 value_be = htonll(value);
|
||||
|
||||
if (strncmp(s, "->", 2)) {
|
||||
ovs_fatal(0, "%s: missing `->' following value", full_s);
|
||||
@@ -1005,10 +1004,8 @@ nxm_parse_reg_load(struct ofpact_reg_load *load, const char *s)
|
||||
full_s, value, load->dst.n_bits);
|
||||
}
|
||||
|
||||
memset(&load->subvalue, 0, sizeof &load->subvalue);
|
||||
bitwise_copy(&value_be, sizeof value_be, 0,
|
||||
&load->subvalue, sizeof load->subvalue, load->dst.ofs,
|
||||
load->dst.n_bits);
|
||||
load->subvalue.be64[0] = htonll(0);
|
||||
load->subvalue.be64[1] = htonll(value);
|
||||
}
|
||||
|
||||
/* nxm_format_reg_move(), nxm_format_reg_load(). */
|
||||
@@ -1025,15 +1022,8 @@ nxm_format_reg_move(const struct ofpact_reg_move *move, struct ds *s)
|
||||
void
|
||||
nxm_format_reg_load(const struct ofpact_reg_load *load, struct ds *s)
|
||||
{
|
||||
union mf_subvalue right_justified;
|
||||
|
||||
memset(&right_justified, 0, sizeof right_justified);
|
||||
bitwise_copy(&load->subvalue, sizeof load->subvalue, load->dst.ofs,
|
||||
&right_justified, sizeof right_justified, 0,
|
||||
load->dst.n_bits);
|
||||
|
||||
ds_put_cstr(s, "load:");
|
||||
mf_format_subvalue(&right_justified, s);
|
||||
mf_format_subvalue(&load->subvalue, s);
|
||||
ds_put_cstr(s, "->");
|
||||
mf_format_subfield(&load->dst, s);
|
||||
}
|
||||
@@ -1065,10 +1055,7 @@ nxm_reg_load_from_openflow(const struct nx_action_reg_load *narl,
|
||||
load->dst.field = mf_from_nxm_header(ntohl(narl->dst));
|
||||
load->dst.ofs = nxm_decode_ofs(narl->ofs_nbits);
|
||||
load->dst.n_bits = nxm_decode_n_bits(narl->ofs_nbits);
|
||||
memset(&load->subvalue, 0, sizeof &load->subvalue);
|
||||
bitwise_copy(&narl->value, sizeof narl->value, 0,
|
||||
&load->subvalue, sizeof load->subvalue, load->dst.ofs,
|
||||
load->dst.n_bits);
|
||||
load->subvalue.be64[1] = narl->value;
|
||||
|
||||
/* Reject 'narl' if a bit numbered 'n_bits' or higher is set to 1 in
|
||||
* narl->value. */
|
||||
@@ -1122,9 +1109,7 @@ nxm_reg_load_to_nxast(const struct ofpact_reg_load *load,
|
||||
narl = ofputil_put_NXAST_REG_LOAD(openflow);
|
||||
narl->ofs_nbits = nxm_encode_ofs_nbits(load->dst.ofs, load->dst.n_bits);
|
||||
narl->dst = htonl(load->dst.field->nxm_header);
|
||||
narl->value = htonll(0);
|
||||
bitwise_copy(&load->subvalue, sizeof load->subvalue, load->dst.ofs,
|
||||
&narl->value, sizeof narl->value, 0, load->dst.n_bits);
|
||||
narl->value = load->subvalue.be64[1];
|
||||
}
|
||||
|
||||
/* nxm_execute_reg_move(), nxm_execute_reg_load(). */
|
||||
|
@@ -275,7 +275,7 @@ struct ofpact_reg_move {
|
||||
struct ofpact_reg_load {
|
||||
struct ofpact ofpact;
|
||||
struct mf_subfield dst;
|
||||
union mf_subvalue subvalue;
|
||||
union mf_subvalue subvalue; /* Least-significant bits are used. */
|
||||
};
|
||||
|
||||
/* OFPACT_SET_TUNNEL.
|
||||
|
Reference in New Issue
Block a user