[ovs-dev] [RFC PATCH v2 5/7] flow: Eliminate miniflow_clone() and minimask_clone().
Jarno Rajahalme
jrajahalme at nicira.com
Fri Jul 10 17:35:23 UTC 2015
miniflow_clone() and minimask_clone() are no longer used, remove them
from the API.
Now that miniflow data is always inlined, it makes sense to rename
miniflow_clone_inline() miniflow_clone().
Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
lib/classifier.c | 8 ++++----
lib/flow.c | 25 ++-----------------------
lib/flow.h | 8 ++------
tests/test-classifier.c | 15 ++++++++++++++-
4 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/lib/classifier.c b/lib/classifier.c
index 5673312..2ed8697 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -101,8 +101,8 @@ cls_match_alloc(const struct cls_rule *rule, cls_version_t version,
*CONST_CAST(cls_version_t *, &cls_match->add_version) = version;
atomic_init(&cls_match->remove_version, version); /* Initially
* invisible. */
- miniflow_clone_inline(CONST_CAST(struct miniflow *, &cls_match->flow),
- rule->match.flow, count);
+ miniflow_clone(CONST_CAST(struct miniflow *, &cls_match->flow),
+ rule->match.flow, count);
ovsrcu_set_hidden(&cls_match->conj_set,
cls_conjunction_set_alloc(cls_match, conj, n));
@@ -1541,8 +1541,8 @@ insert_subtable(struct classifier *cls, const struct minimask *mask)
subtable = xzalloc(sizeof *subtable + MINIFLOW_VALUES_SIZE(count));
cmap_init(&subtable->rules);
- miniflow_clone_inline(CONST_CAST(struct miniflow *, &subtable->mask.masks),
- &mask->masks, count);
+ miniflow_clone(CONST_CAST(struct miniflow *, &subtable->mask.masks),
+ &mask->masks, count);
/* Init indices for segmented lookup, if any. */
flow_wildcards_init_catchall(&new);
diff --git a/lib/flow.c b/lib/flow.c
index b3bfca9..0faac4f 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -2076,24 +2076,11 @@ miniflow_create(const struct flow *src)
return dst;
}
-/* Returns a copy of 'src'. The caller must eventually free the returned
- * miniflow with free(). */
-struct miniflow *
-miniflow_clone(const struct miniflow *src)
-{
- struct miniflow *dst;
- size_t data_size;
-
- data_size = miniflow_alloc(&dst, 1, src);
- memcpy(dst->values, src->values, data_size);
- return dst;
-}
-
/* Initializes 'dst' as a copy of 'src'. The caller must have allocated
* 'dst' to have inline space for 'n_values' data in 'src'. */
void
-miniflow_clone_inline(struct miniflow *dst, const struct miniflow *src,
- size_t n_values)
+miniflow_clone(struct miniflow *dst, const struct miniflow *src,
+ size_t n_values)
{
dst->map = src->map;
memcpy(dst->values, src->values, MINIFLOW_VALUES_SIZE(n_values));
@@ -2185,14 +2172,6 @@ minimask_create(const struct flow_wildcards *wc)
return (struct minimask *)miniflow_create(&wc->masks);
}
-/* Returns a copy of 'src'. The caller must eventually free the returned
- * minimask with free(). */
-struct minimask *
-minimask_clone(const struct minimask *src)
-{
- return (struct minimask *)miniflow_clone(&src->masks);
-}
-
/* Initializes 'dst_' as the bit-wise "and" of 'a_' and 'b_'.
*
* The caller must provide room for FLOW_U64S "uint64_t"s in 'storage', which
diff --git a/lib/flow.h b/lib/flow.h
index d242588..1f4f9c4 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -402,12 +402,9 @@ void miniflow_map_init(struct miniflow *, const struct flow *);
size_t miniflow_alloc(struct miniflow *dsts[], size_t n,
const struct miniflow *src);
void miniflow_init(struct miniflow *, const struct flow *);
-
+void miniflow_clone(struct miniflow *, const struct miniflow *,
+ size_t n_values);
struct miniflow * miniflow_create(const struct flow *);
-struct miniflow * miniflow_clone(const struct miniflow *);
-
-void miniflow_clone_inline(struct miniflow *, const struct miniflow *,
- size_t n_values);
void miniflow_expand(const struct miniflow *, struct flow *);
@@ -565,7 +562,6 @@ struct minimask {
void minimask_init(struct minimask *, const struct flow_wildcards *);
struct minimask * minimask_create(const struct flow_wildcards *);
-struct minimask * minimask_clone(const struct minimask *);
void minimask_combine(struct minimask *dst,
const struct minimask *a, const struct minimask *b,
uint64_t storage[FLOW_U64S]);
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 388b36d..6e5b36b 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -1423,6 +1423,19 @@ wildcard_extra_bits(struct flow_wildcards *mask)
}
}
+/* Returns a copy of 'src'. The caller must eventually free the returned
+ * miniflow with free(). */
+static struct miniflow *
+miniflow_clone__(const struct miniflow *src)
+{
+ struct miniflow *dst;
+ size_t data_size;
+
+ data_size = miniflow_alloc(&dst, 1, src);
+ miniflow_clone(dst, src, data_size / sizeof(uint64_t));
+ return dst;
+}
+
static void
test_miniflow(struct ovs_cmdl_context *ctx OVS_UNUSED)
{
@@ -1455,7 +1468,7 @@ test_miniflow(struct ovs_cmdl_context *ctx OVS_UNUSED)
assert(flow_equal(&flow, &flow2));
/* Check that copying a miniflow works properly. */
- miniflow2 = miniflow_clone(miniflow);
+ miniflow2 = miniflow_clone__(miniflow);
assert(miniflow_equal(miniflow, miniflow2));
assert(miniflow_hash(miniflow, 0) == miniflow_hash(miniflow2, 0));
miniflow_expand(miniflow2, &flow3);
--
1.7.10.4
More information about the dev
mailing list