[ovs-dev] [PATCH 2/5] lib/ofp-actions: make ofpact_reg_load.value mf_value from uint64_t
Simon Horman
horms at verge.net.au
Thu Aug 30 01:40:24 UTC 2012
From: Isaku Yamahata <yamahata at valinux.co.jp>
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>
Signed-off-by: Simon Horman <horms at verge.net.au>
---
v3
* No change
v2 [Isaku Yamahata]
* First post
---
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 28b8012..982c5ce 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 16c1674..3d63375 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -1002,7 +1002,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);
}
@@ -1012,9 +1012,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);
}
}
@@ -1032,7 +1033,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);
}
@@ -1063,11 +1064,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;
}
@@ -1116,7 +1117,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(load->value);
+ narl->value = load->value.be64;
}
/* nxm_execute_reg_move(), nxm_execute_reg_load(). */
@@ -1139,7 +1140,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 4fc9094..39a7d1e 100644
--- a/lib/ofp-actions.h
+++ b/lib/ofp-actions.h
@@ -271,11 +271,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.10.2.484.gcd07cc5
More information about the dev
mailing list