[ovs-dev] [PATCH 19/22] ofp-util: Provide bucket list helper functions
Simon Horman
simon.horman at netronome.com
Mon Nov 10 04:48:06 UTC 2014
This is in preparation for supporting the bucket commands of
(draft) Open Flow 1.5 group mod messages.
EXT-350
Signed-off-by: Simon Horman <simon.horman at netronome.com>
---
lib/ofp-util.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/ofp-util.h | 6 ++++++
2 files changed, 73 insertions(+)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index e5a0289..8e73d3d 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -6850,6 +6850,53 @@ ofputil_bucket_list_destroy(struct list *buckets)
}
}
+static struct ofputil_bucket *
+ofputil_bucket_clone_data(const struct ofputil_bucket *bucket)
+{
+ struct ofputil_bucket *new;
+
+ new = xmemdup(bucket, sizeof *bucket);
+ new->ofpacts = xmemdup(bucket->ofpacts, bucket->ofpacts_len);
+
+ return new;
+}
+
+void
+ofputil_bucket_clone_list(struct list *dest, const struct list *src,
+ const struct ofputil_bucket *skip)
+{
+ struct ofputil_bucket *bucket;
+
+ LIST_FOR_EACH (bucket, list_node, src) {
+ struct ofputil_bucket *new_bucket;
+
+ if (bucket == skip) {
+ continue;
+ }
+
+ new_bucket = ofputil_bucket_clone_data(bucket);
+ list_push_back(dest, &new_bucket->list_node);
+ }
+}
+
+struct ofputil_bucket *
+ofputil_bucket_find(const struct list *buckets, uint32_t bucket_id)
+{
+ struct ofputil_bucket *bucket;
+
+ if (bucket_id > OFPG15_BUCKET_MAX) {
+ return NULL;
+ }
+
+ LIST_FOR_EACH (bucket, list_node, buckets) {
+ if (bucket->bucket_id == bucket_id) {
+ return bucket;
+ }
+ }
+
+ return NULL;
+}
+
bool
ofputil_bucket_check_duplicate_id(const struct list *buckets)
{
@@ -6869,6 +6916,26 @@ ofputil_bucket_check_duplicate_id(const struct list *buckets)
return false;
}
+struct ofputil_bucket *
+ofputil_bucket_list_front(const struct list *buckets)
+{
+ static struct ofputil_bucket *bucket;
+
+ ASSIGN_CONTAINER(bucket, list_front(buckets), list_node);
+
+ return bucket;
+}
+
+struct ofputil_bucket *
+ofputil_bucket_list_back(const struct list *buckets)
+{
+ static struct ofputil_bucket *bucket;
+
+ ASSIGN_CONTAINER(bucket, list_back(buckets), list_node);
+
+ return bucket;
+}
+
/* Returns an OpenFlow group stats request for OpenFlow version 'ofp_version',
* that requests stats for group 'group_id'. (Use OFPG_ALL to request stats
* for all groups.)
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index ffae20f..673acf6 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -1033,7 +1033,13 @@ struct ofputil_group_desc {
};
void ofputil_bucket_list_destroy(struct list *buckets);
+void ofputil_bucket_clone_list(struct list *dest, const struct list *src,
+ const struct ofputil_bucket *);
+struct ofputil_bucket *ofputil_bucket_find(const struct list *,
+ uint32_t bucket_id);
bool ofputil_bucket_check_duplicate_id(const struct list *);
+struct ofputil_bucket *ofputil_bucket_list_front(const struct list *);
+struct ofputil_bucket *ofputil_bucket_list_back(const struct list *);
static inline bool
ofputil_bucket_has_liveness(const struct ofputil_bucket *bucket)
--
2.1.1
More information about the dev
mailing list