summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Pettit <jpettit@ovn.org>2016-05-03 18:20:51 -0700
committerJustin Pettit <jpettit@ovn.org>2016-05-08 09:26:19 -0700
commit2ff8484bbf88ce2552f0a55c6032d30eaff377e6 (patch)
treecc86a6270076eed91a2b1b49b71cc1421818e062
parent20322d4b6ef2c4513535c7837a1e8becae1da7f1 (diff)
downloadopenvswitch-2ff8484bbf88ce2552f0a55c6032d30eaff377e6.tar.gz
util: Pass 128-bit arguments directly instead of using pointers.
Commit f2d105b5 (ofproto-dpif-xlate: xlate ct_{mark, label} correctly.) introduced the ovs_u128_and() function. It directly takes ovs_u128 values as arguments instead of pointers to them. As this is a bit more direct way to deal with 128-bit values, modify the other utility functions to do the same. Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
-rw-r--r--lib/ct-dpif.c2
-rw-r--r--lib/dpif-netdev.c4
-rw-r--r--lib/dpif.c2
-rw-r--r--lib/flow.c6
-rw-r--r--lib/match.c4
-rw-r--r--lib/meta-flow.c2
-rw-r--r--lib/odp-util.c8
-rw-r--r--lib/util.h20
-rw-r--r--ofproto/ofproto-dpif-upcall.c2
-rw-r--r--ofproto/ofproto-dpif-xlate.c2
-rw-r--r--ofproto/ofproto-dpif.c2
-rw-r--r--tests/test-hash.c4
12 files changed, 29 insertions, 29 deletions
diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c
index d255a7150..63ca49829 100644
--- a/lib/ct-dpif.c
+++ b/lib/ct-dpif.c
@@ -168,7 +168,7 @@ ct_dpif_format_entry(const struct ct_dpif_entry *entry, struct ds *ds,
if (entry->mark) {
ds_put_format(ds, ",mark=%"PRIu32, entry->mark);
}
- if (!ovs_u128_is_zero(&entry->labels)) {
+ if (!ovs_u128_is_zero(entry->labels)) {
ovs_be128 value;
ds_put_cstr(ds, ",labels=");
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d288f452b..33fd2283c 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1819,7 +1819,7 @@ dp_netdev_pmd_find_flow(const struct dp_netdev_pmd_thread *pmd,
if (ufidp) {
CMAP_FOR_EACH_WITH_HASH (netdev_flow, node, dp_netdev_flow_hash(ufidp),
&pmd->flow_table) {
- if (ovs_u128_equals(&netdev_flow->ufid, ufidp)) {
+ if (ovs_u128_equals(netdev_flow->ufid, *ufidp)) {
return netdev_flow;
}
}
@@ -1965,7 +1965,7 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
/* Userspace datapath doesn't support conntrack. */
if (flow->ct_state || flow->ct_zone || flow->ct_mark
- || !ovs_u128_is_zero(&flow->ct_label)) {
+ || !ovs_u128_is_zero(flow->ct_label)) {
return EINVAL;
}
diff --git a/lib/dpif.c b/lib/dpif.c
index 2c64d9e3c..5037ac67f 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -903,7 +903,7 @@ dpif_probe_feature(struct dpif *dpif, const char *name,
PMD_ID_NULL, &reply, &flow);
if (!error
&& (!ufid || (flow.ufid_present
- && ovs_u128_equals(ufid, &flow.ufid)))) {
+ && ovs_u128_equals(*ufid, flow.ufid)))) {
enable_feature = true;
}
diff --git a/lib/flow.c b/lib/flow.c
index 343ae6df7..fc8843ef4 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -524,7 +524,7 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst)
miniflow_push_uint32(mf, ct_mark, md->ct_mark);
miniflow_pad_to_64(mf, ct_mark);
- if (!ovs_u128_is_zero(&md->ct_label)) {
+ if (!ovs_u128_is_zero(md->ct_label)) {
miniflow_push_words(mf, ct_label, &md->ct_label,
sizeof md->ct_label / sizeof(uint64_t));
}
@@ -895,7 +895,7 @@ flow_get_metadata(const struct flow *flow, struct match *flow_metadata)
if (flow->ct_mark != 0) {
match_set_ct_mark(flow_metadata, flow->ct_mark);
}
- if (!ovs_u128_is_zero(&flow->ct_label)) {
+ if (!ovs_u128_is_zero(flow->ct_label)) {
match_set_ct_label(flow_metadata, flow->ct_label);
}
}
@@ -1206,7 +1206,7 @@ flow_format(struct ds *ds, const struct flow *flow)
if (!flow->ct_mark) {
WC_UNMASK_FIELD(wc, ct_mark);
}
- if (ovs_u128_is_zero(&flow->ct_label)) {
+ if (ovs_u128_is_zero(flow->ct_label)) {
WC_UNMASK_FIELD(wc, ct_label);
}
for (int i = 0; i < FLOW_N_REGS; i++) {
diff --git a/lib/match.c b/lib/match.c
index 052130a62..db78831c7 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -1033,7 +1033,7 @@ format_flow_tunnel(struct ds *s, const struct match *match)
static void
format_ct_label_masked(struct ds *s, const ovs_u128 *key, const ovs_u128 *mask)
{
- if (!ovs_u128_is_zero(mask)) {
+ if (!ovs_u128_is_zero(*mask)) {
ovs_be128 value = hton128(*key);
ds_put_format(s, "%sct_label=%s", colors.param, colors.end);
ds_put_hex(s, &value, sizeof value);
@@ -1118,7 +1118,7 @@ match_format(const struct match *match, struct ds *s, int priority)
format_uint32_masked(s, "ct_mark", f->ct_mark, wc->masks.ct_mark);
}
- if (!ovs_u128_is_zero(&wc->masks.ct_label)) {
+ if (!ovs_u128_is_zero(wc->masks.ct_label)) {
format_ct_label_masked(s, &f->ct_label, &wc->masks.ct_label);
}
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index ce60f2256..2a129ea25 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -232,7 +232,7 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
case MFF_CT_MARK:
return !wc->masks.ct_mark;
case MFF_CT_LABEL:
- return ovs_u128_is_zero(&wc->masks.ct_label);
+ return ovs_u128_is_zero(wc->masks.ct_label);
CASE_MFF_REGS:
return !wc->masks.regs[mf->id - MFF_REG0];
CASE_MFF_XREGS:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index e0a1ad475..2cdd504a0 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -1492,7 +1492,7 @@ find_end:
nl_msg_put_unspec(actions, OVS_CT_ATTR_MARK, &ct_mark,
sizeof(ct_mark));
}
- if (!ovs_u128_is_zero(&ct_label.mask)) {
+ if (!ovs_u128_is_zero(ct_label.mask)) {
nl_msg_put_unspec(actions, OVS_CT_ATTR_LABELS, &ct_label,
sizeof ct_label);
}
@@ -2950,12 +2950,12 @@ static void
format_u128(struct ds *ds, const ovs_u128 *key, const ovs_u128 *mask,
bool verbose)
{
- if (verbose || (mask && !ovs_u128_is_zero(mask))) {
+ if (verbose || (mask && !ovs_u128_is_zero(*mask))) {
ovs_be128 value;
value = hton128(*key);
ds_put_hex(ds, &value, sizeof value);
- if (mask && !(ovs_u128_is_ones(mask))) {
+ if (mask && !(ovs_u128_is_ones(*mask))) {
value = hton128(*mask);
ds_put_char(ds, '/');
ds_put_hex(ds, &value, sizeof value);
@@ -4464,7 +4464,7 @@ odp_key_from_pkt_metadata(struct ofpbuf *buf, const struct pkt_metadata *md)
if (md->ct_mark) {
nl_msg_put_u32(buf, OVS_KEY_ATTR_CT_MARK, md->ct_mark);
}
- if (!ovs_u128_is_zero(&md->ct_label)) {
+ if (!ovs_u128_is_zero(md->ct_label)) {
nl_msg_put_unspec(buf, OVS_KEY_ATTR_CT_LABELS, &md->ct_label,
sizeof(md->ct_label));
}
diff --git a/lib/util.h b/lib/util.h
index f631bdf6a..7be4a30e9 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -392,37 +392,37 @@ void bitwise_toggle_bit(void *dst, unsigned int len, unsigned int ofs);
/* Returns non-zero if the parameters have equal value. */
static inline int
-ovs_u128_equals(const ovs_u128 *a, const ovs_u128 *b)
+ovs_u128_equals(const ovs_u128 a, const ovs_u128 b)
{
- return (a->u64.hi == b->u64.hi) && (a->u64.lo == b->u64.lo);
+ return (a.u64.hi == b.u64.hi) && (a.u64.lo == b.u64.lo);
}
/* Returns true if 'val' is 0. */
static inline bool
-ovs_u128_is_zero(const ovs_u128 *val)
+ovs_u128_is_zero(const ovs_u128 val)
{
- return !(val->u64.hi || val->u64.lo);
+ return !(val.u64.hi || val.u64.lo);
}
/* Returns true if 'val' is all ones. */
static inline bool
-ovs_u128_is_ones(const ovs_u128 *val)
+ovs_u128_is_ones(const ovs_u128 val)
{
- return ovs_u128_equals(val, &OVS_U128_MAX);
+ return ovs_u128_equals(val, OVS_U128_MAX);
}
/* Returns non-zero if the parameters have equal value. */
static inline int
-ovs_be128_equals(const ovs_be128 *a, const ovs_be128 *b)
+ovs_be128_equals(const ovs_be128 a, const ovs_be128 b)
{
- return (a->be64.hi == b->be64.hi) && (a->be64.lo == b->be64.lo);
+ return (a.be64.hi == b.be64.hi) && (a.be64.lo == b.be64.lo);
}
/* Returns true if 'val' is 0. */
static inline bool
-ovs_be128_is_zero(const ovs_be128 *val)
+ovs_be128_is_zero(const ovs_be128 val)
{
- return !(val->be64.hi || val->be64.lo);
+ return !(val.be64.hi || val.be64.lo);
}
static inline ovs_u128
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index f62f46b8e..ae8c2d366 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1391,7 +1391,7 @@ ukey_lookup(struct udpif *udpif, const ovs_u128 *ufid, const unsigned pmd_id)
CMAP_FOR_EACH_WITH_HASH (ukey, cmap_node,
get_ukey_hash(ufid, pmd_id), cmap) {
- if (ovs_u128_equals(&ukey->ufid, ufid)) {
+ if (ovs_u128_equals(ukey->ufid, *ufid)) {
return ukey;
}
}
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 5272249bd..232180261 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4327,7 +4327,7 @@ static void
put_ct_label(const struct flow *flow, struct ofpbuf *odp_actions,
struct flow_wildcards *wc)
{
- if (!ovs_u128_is_zero(&wc->masks.ct_label)) {
+ if (!ovs_u128_is_zero(wc->masks.ct_label)) {
struct {
ovs_u128 key;
ovs_u128 mask;
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 0c65df26c..fea86aa3a 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3997,7 +3997,7 @@ check_mask(struct ofproto_dpif *ofproto, const struct miniflow *flow)
|| ((ct_state & (CS_SRC_NAT | CS_DST_NAT)) && !support->ct_state_nat)
|| (ct_zone && !support->ct_zone)
|| (ct_mark && !support->ct_mark)
- || (!ovs_u128_is_zero(&ct_label) && !support->ct_label)) {
+ || (!ovs_u128_is_zero(ct_label) && !support->ct_label)) {
return OFPERR_OFPBMC_BAD_MASK;
}
diff --git a/tests/test-hash.c b/tests/test-hash.c
index 67a1f6c89..d1beead36 100644
--- a/tests/test-hash.c
+++ b/tests/test-hash.c
@@ -162,7 +162,7 @@ check_hash_bytes128(void (*hash)(const void *, size_t, uint32_t, ovs_u128 *),
set_bit128(&in1, i, n_bits);
hash(in0, sizeof(ovs_u128), 0, &out0);
hash(&in1, sizeof(ovs_u128), 0, &out1);
- if (!ovs_u128_equals(&out0, &out1)) {
+ if (!ovs_u128_equals(out0, out1)) {
printf("%s hash not the same for non-64 aligned data "
"%016"PRIx64"%016"PRIx64" != %016"PRIx64"%016"PRIx64"\n",
name, out0.u64.lo, out0.u64.hi, out1.u64.lo, out1.u64.hi);
@@ -214,7 +214,7 @@ check_256byte_hash(void (*hash)(const void *, size_t, uint32_t, ovs_u128 *),
set_bit128(in1, i, n_bits);
hash(in0, sizeof(ovs_u128) * 16, 0, &out0);
hash(in1, sizeof(ovs_u128) * 16, 0, &out1);
- if (!ovs_u128_equals(&out0, &out1)) {
+ if (!ovs_u128_equals(out0, out1)) {
printf("%s hash not the same for non-64 aligned data "
"%016"PRIx64"%016"PRIx64" != %016"PRIx64"%016"PRIx64"\n",
name, out0.u64.lo, out0.u64.hi, out1.u64.lo, out1.u64.hi);