[ovs-dev] [PATCH v2 4/7] lib/ofp-actions: make ofpact_reg_load.value mf_value from uint64_t
Isaku Yamahata
yamahata at valinux.co.jp
Thu Jun 28 11:30:45 UTC 2012
set_field action needs more than 64 bits value unlike nx_reg_load action.
This is preparation for set_field action. mf_value will be used later.
Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
---
v2
newly created
---
lib/learn.c | 2 +-
lib/nx-match.c | 17 +++++++++--------
lib/ofp-actions.h | 5 +++--
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/lib/learn.c b/lib/learn.c
index 7dd02d0..a30b6e9 100644
--- a/lib/learn.c
+++ b/lib/learn.c
@@ -350,7 +350,7 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
bitwise_copy(&value, sizeof value, ofs,
&value_be, sizeof value_be, 0,
chunk);
- load->value = ntohll(value_be);
+ load->value.be64 = value_be;
}
break;
diff --git a/lib/nx-match.c b/lib/nx-match.c
index 1c6d5dc..f5d3530 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -821,7 +821,7 @@ nxm_parse_reg_load(struct ofpact_reg_load *load, const char *s)
{
const char *full_s = s;
- load->value = strtoull(s, (char **) &s, 0);
+ load->value.be64 = htonll(strtoull(s, (char **) &s, 0));
if (strncmp(s, "->", 2)) {
ovs_fatal(0, "%s: missing `->' following value", full_s);
}
@@ -831,9 +831,10 @@ nxm_parse_reg_load(struct ofpact_reg_load *load, const char *s)
ovs_fatal(0, "%s: trailing garbage following destination", full_s);
}
- if (load->dst.n_bits < 64 && (load->value >> load->dst.n_bits) != 0) {
+ if (load->dst.n_bits < 64 &&
+ (ntohll(load->value.be64) >> load->dst.n_bits) != 0) {
ovs_fatal(0, "%s: value %"PRIu64" does not fit into %d bits",
- full_s, load->value, load->dst.n_bits);
+ full_s, ntohll(load->value.be64), load->dst.n_bits);
}
}
@@ -851,7 +852,7 @@ 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)
{
- ds_put_format(s, "load:%#"PRIx64"->", load->value);
+ ds_put_format(s, "load:%#"PRIx64"->", ntohll(load->value.be64));
mf_format_subfield(&load->dst, s);
}
@@ -882,11 +883,11 @@ 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);
- load->value = ntohll(narl->value);
+ load->value.be64 = narl->value;
/* Reject 'narl' if a bit numbered 'n_bits' or higher is set to 1 in
* narl->value. */
- if (load->dst.n_bits < 64 && load->value >> load->dst.n_bits) {
+ if (load->dst.n_bits < 64 && ntohll(load->value.be64) >> load->dst.n_bits) {
return OFPERR_OFPBAC_BAD_ARGUMENT;
}
@@ -935,7 +936,7 @@ nxm_reg_load_to_openflow(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(load->value);
+ narl->value = load->value.be64;
}
/* nxm_execute_reg_move(), nxm_execute_reg_load(). */
@@ -958,7 +959,7 @@ nxm_execute_reg_move(const struct ofpact_reg_move *move,
void
nxm_execute_reg_load(const struct ofpact_reg_load *load, struct flow *flow)
{
- nxm_reg_load(&load->dst, load->value, flow);
+ nxm_reg_load(&load->dst, ntohll(load->value.be64), flow);
}
void
diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h
index 7cf1eb5..47c9b7d 100644
--- a/lib/ofp-actions.h
+++ b/lib/ofp-actions.h
@@ -269,11 +269,12 @@ struct ofpact_reg_move {
/* OFPACT_REG_LOAD.
*
- * Used for NXAST_REG_LOAD. */
+ * Used for NXAST_REG_LOAD, OFPAT12_SET_FIELD. */
struct ofpact_reg_load {
struct ofpact ofpact;
struct mf_subfield dst;
- uint64_t value;
+ /* OFPAT12_SET_FIELD requires more than 64 bits */
+ union mf_value value;
};
/* OFPACT_SET_TUNNEL.
--
1.7.1.1
More information about the dev
mailing list