diff options
author | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-11-14 15:58:09 -0800 |
---|---|---|
committer | Jarno Rajahalme <jrajahalme@nicira.com> | 2014-11-14 15:58:09 -0800 |
commit | fccd7c092e09ce9767d34436bf9c70302c87c5f5 (patch) | |
tree | c8f4b214dcc276199be878ce9c4b1c603cec0a8f /lib/classifier.h | |
parent | de4ad4a21569fa63912be87c1b2e858d888dc1b0 (diff) | |
download | openvswitch-fccd7c092e09ce9767d34436bf9c70302c87c5f5.tar.gz |
classifier: Remove internal mutex.
Almost all classifier users already exclude concurrent modifications,
or are single-threaded, hence the classifier internal mutex can be
removed. Due to this change, ovs-router.c and tnl-ports.c need new
mutexes, which are added.
As noted by Ben in review, ovs_router_flush() should also free the
entries it removes from the classifier. It now calls
ovsrcu_postpone() to that effect.
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.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/classifier.h b/lib/classifier.h index 9a5ca4e7b..f7ba46c9c 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -216,7 +216,6 @@ #include "cmap.h" #include "match.h" #include "meta-flow.h" -#include "ovs-thread.h" #include "pvector.h" #include "rculist.h" @@ -244,8 +243,7 @@ enum { /* A flow classifier. */ struct classifier { - struct ovs_mutex mutex; - int n_rules OVS_GUARDED; /* Total number of rules. */ + int n_rules; /* Total number of rules. */ uint8_t n_flow_segments; uint8_t flow_segments[CLS_MAX_INDICES]; /* Flow segment boundaries to use * for staged lookup. */ @@ -260,7 +258,7 @@ struct classifier { struct cls_rule { struct rculist node; /* In struct cls_subtable 'rules_list'. */ int priority; /* Larger numbers are higher priorities. */ - struct cls_match *cls_match OVS_GUARDED; /* NULL if not in a classifier. */ + struct cls_match *cls_match; /* NULL if not in a classifier. */ struct minimatch match; /* Matching rule. */ }; @@ -270,42 +268,41 @@ void cls_rule_init_from_minimatch(struct cls_rule *, const struct minimatch *, void cls_rule_clone(struct cls_rule *, const struct cls_rule *); void cls_rule_move(struct cls_rule *dst, struct cls_rule *src); void cls_rule_destroy(struct cls_rule *); - bool cls_rule_equal(const struct cls_rule *, const struct cls_rule *); uint32_t cls_rule_hash(const struct cls_rule *, uint32_t basis); - void cls_rule_format(const struct cls_rule *, struct ds *); - bool cls_rule_is_catchall(const struct cls_rule *); - bool cls_rule_is_loose_match(const struct cls_rule *rule, const struct minimatch *criteria); +/* Constructor/destructor. Must run single-threaded. */ void classifier_init(struct classifier *, const uint8_t *flow_segments); void classifier_destroy(struct classifier *); + +/* Modifiers. Caller MUST exclude concurrent calls from other threads. */ bool classifier_set_prefix_fields(struct classifier *, const enum mf_field_id *trie_fields, unsigned int n_trie_fields); - -bool classifier_is_empty(const struct classifier *); -int classifier_count(const struct classifier *); void classifier_insert(struct classifier *, struct cls_rule *); const struct cls_rule *classifier_replace(struct classifier *, struct cls_rule *); const struct cls_rule *classifier_remove(struct classifier *, const struct cls_rule *); + +/* Lookups. These are RCU protected and may run concurrently with modifiers + * and each other. */ const struct cls_rule *classifier_lookup(const struct classifier *, const struct flow *, struct flow_wildcards *); bool classifier_rule_overlaps(const struct classifier *, const struct cls_rule *); - const struct cls_rule *classifier_find_rule_exactly(const struct classifier *, const struct cls_rule *); - const struct cls_rule *classifier_find_match_exactly(const struct classifier *, const struct match *, int priority); +bool classifier_is_empty(const struct classifier *); +int classifier_count(const struct classifier *); /* Iteration. * |