summaryrefslogtreecommitdiff
path: root/lib/classifier.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2015-07-06 11:45:54 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2015-07-06 11:46:34 -0700
commitbd53aa1723a007415d26fdd8fb7da05acc06aad0 (patch)
treecdff83f858e77eee3f8052e71d0fc6b646f4f3df /lib/classifier.h
parent8be0036745ecda6325e27e87cdb1d23e3e3d5d34 (diff)
downloadopenvswitch-bd53aa1723a007415d26fdd8fb7da05acc06aad0.tar.gz
classifier: Make versioning more explicit.
Now that struct cls_match has 'add_version' the 'version' in cls_match was largely redundant. Remove 'version' from struct cls_rule, and add it to function prototypes that need it. This makes versioning more explicit (or less indirect) in the API. Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/classifier.h')
-rw-r--r--lib/classifier.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/lib/classifier.h b/lib/classifier.h
index 8bbc7366b..5ffe756b1 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -357,18 +357,14 @@ struct cls_conjunction {
struct cls_rule {
struct rculist node; /* In struct cls_subtable 'rules_list'. */
const int priority; /* Larger numbers are higher priorities. */
- const cls_version_t version; /* Version in which the rule was added. */
struct cls_match *cls_match; /* NULL if not in a classifier. */
const struct minimatch match; /* Matching rule. */
};
-void cls_rule_init(struct cls_rule *, const struct match *, int priority,
- cls_version_t);
+void cls_rule_init(struct cls_rule *, const struct match *, int priority);
void cls_rule_init_from_minimatch(struct cls_rule *, const struct minimatch *,
- int priority, cls_version_t);
+ int priority);
void cls_rule_clone(struct cls_rule *, const struct cls_rule *);
-void cls_rule_clone_in_version(struct cls_rule *, const struct cls_rule *,
- cls_version_t);
void cls_rule_move(struct cls_rule *dst, struct cls_rule *src);
void cls_rule_destroy(struct cls_rule *);
@@ -395,9 +391,11 @@ bool classifier_set_prefix_fields(struct classifier *,
const enum mf_field_id *trie_fields,
unsigned int n_trie_fields);
void classifier_insert(struct classifier *, const struct cls_rule *,
- const struct cls_conjunction *, size_t n_conjunctions);
+ cls_version_t, const struct cls_conjunction *,
+ size_t n_conjunctions);
const struct cls_rule *classifier_replace(struct classifier *,
const struct cls_rule *,
+ cls_version_t,
const struct cls_conjunction *,
size_t n_conjunctions);
const struct cls_rule *classifier_remove(struct classifier *,
@@ -411,9 +409,10 @@ const struct cls_rule *classifier_lookup(const struct classifier *,
cls_version_t, struct flow *,
struct flow_wildcards *);
bool classifier_rule_overlaps(const struct classifier *,
- const struct cls_rule *);
+ const struct cls_rule *, cls_version_t);
const struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
- const struct cls_rule *);
+ const struct cls_rule *,
+ cls_version_t);
const struct cls_rule *classifier_find_match_exactly(const struct classifier *,
const struct match *,
int priority,
@@ -437,18 +436,20 @@ struct cls_cursor {
const struct classifier *cls;
const struct cls_subtable *subtable;
const struct cls_rule *target;
+ cls_version_t version; /* Version to iterate. */
struct pvector_cursor subtables;
const struct cls_rule *rule;
};
-struct cls_cursor cls_cursor_start(const struct classifier *cls,
- const struct cls_rule *target);
+struct cls_cursor cls_cursor_start(const struct classifier *,
+ const struct cls_rule *target,
+ cls_version_t);
void cls_cursor_advance(struct cls_cursor *);
#define CLS_FOR_EACH(RULE, MEMBER, CLS) \
- CLS_FOR_EACH_TARGET(RULE, MEMBER, CLS, NULL)
-#define CLS_FOR_EACH_TARGET(RULE, MEMBER, CLS, TARGET) \
- for (struct cls_cursor cursor__ = cls_cursor_start(CLS, TARGET); \
+ CLS_FOR_EACH_TARGET(RULE, MEMBER, CLS, NULL, CLS_MAX_VERSION)
+#define CLS_FOR_EACH_TARGET(RULE, MEMBER, CLS, TARGET, VERSION) \
+ for (struct cls_cursor cursor__ = cls_cursor_start(CLS, TARGET, VERSION); \
(cursor__.rule \
? (INIT_CONTAINER(RULE, cursor__.rule, MEMBER), \
cls_cursor_advance(&cursor__), \
@@ -456,9 +457,6 @@ void cls_cursor_advance(struct cls_cursor *);
: false); \
)
-#ifdef __cplusplus
-}
-#endif
static inline void
classifier_defer(struct classifier *cls)
@@ -472,4 +470,8 @@ classifier_publish(struct classifier *cls)
cls->publish = true;
pvector_publish(&cls->subtables);
}
+
+#ifdef __cplusplus
+}
+#endif
#endif /* classifier.h */