summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2014-10-30 14:12:45 -0700
committerBen Pfaff <blp@nicira.com>2015-01-11 13:07:06 -0800
commit2e0bded4b44e671a06c8ceb97fc785778cc49458 (patch)
tree14b31e917ef588fea926f826fc4c32b2e1bd4538
parentae99ee4554db1ede9aadef5ee8d3e7c8e7303feb (diff)
downloadopenvswitch-2e0bded4b44e671a06c8ceb97fc785778cc49458.tar.gz
classifier: Make classifier_lookup() 'flow' parameter non-const.
An upcoming commit will make classifier_lookup() sometimes modify its 'flow' argument temporarily during the lookup. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com> --- v2: New patch. v2.1: Rebase. v3: Rebase.
-rw-r--r--lib/classifier.c7
-rw-r--r--lib/classifier.h2
-rw-r--r--lib/tnl-ports.c4
-rw-r--r--lib/tnl-ports.h3
-rw-r--r--ofproto/ofproto-dpif.c12
5 files changed, 19 insertions, 9 deletions
diff --git a/lib/classifier.c b/lib/classifier.c
index 0ac53561c..814493e08 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -816,9 +816,12 @@ trie_ctx_init(struct trie_ctx *ctx, const struct cls_trie *trie)
* If a rule is found and 'wc' is non-null, bitwise-OR's 'wc' with the
* set of bits that were significant in the lookup. At some point
* earlier, 'wc' should have been initialized (e.g., by
- * flow_wildcards_init_catchall()). */
+ * flow_wildcards_init_catchall()).
+ *
+ * 'flow' is non-const to allow for temporary modifications during the lookup.
+ * Any changes are restored before returning. */
const struct cls_rule *
-classifier_lookup(const struct classifier *cls, const struct flow *flow,
+classifier_lookup(const struct classifier *cls, struct flow *flow,
struct flow_wildcards *wc)
{
const struct cls_partition *partition;
diff --git a/lib/classifier.h b/lib/classifier.h
index 2bd6fd332..9ebc506e8 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -295,7 +295,7 @@ static inline void classifier_publish(struct classifier *);
/* 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 *,
struct flow_wildcards *);
bool classifier_rule_overlaps(const struct classifier *,
const struct cls_rule *);
diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index 7ab25eb38..ff616a29a 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -134,8 +134,10 @@ tnl_port_map_delete(ovs_be32 ip_dst, ovs_be16 udp_port)
tnl_port_unref(cr);
}
+/* 'flow' is non-const to allow for temporary modifications during the lookup.
+ * Any changes are restored before returning. */
odp_port_t
-tnl_port_map_lookup(const struct flow *flow, struct flow_wildcards *wc)
+tnl_port_map_lookup(struct flow *flow, struct flow_wildcards *wc)
{
const struct cls_rule *cr = classifier_lookup(&cls, flow, wc);
diff --git a/lib/tnl-ports.h b/lib/tnl-ports.h
index 0597afa2e..37a689f97 100644
--- a/lib/tnl-ports.h
+++ b/lib/tnl-ports.h
@@ -24,8 +24,7 @@
#include "packets.h"
#include "util.h"
-odp_port_t tnl_port_map_lookup(const struct flow *flow,
- struct flow_wildcards *wc);
+odp_port_t tnl_port_map_lookup(struct flow *flow, struct flow_wildcards *wc);
void tnl_port_map_insert(odp_port_t port, ovs_be32 ip_dst, ovs_be16 udp_port,
const char dev_name[]);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c92931dd6..bf15d047e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3735,10 +3735,13 @@ rule_dpif_lookup(struct ofproto_dpif *ofproto, struct flow *flow,
/* The returned rule (if any) is valid at least until the next RCU quiescent
* period. If the rule needs to stay around longer, a non-zero 'take_ref'
- * must be passed in to cause a reference to be taken on it. */
+ * must be passed in to cause a reference to be taken on it.
+ *
+ * 'flow' is non-const to allow for temporary modifications during the lookup.
+ * Any changes are restored before returning. */
static struct rule_dpif *
rule_dpif_lookup_in_table(struct ofproto_dpif *ofproto, uint8_t table_id,
- const struct flow *flow, struct flow_wildcards *wc,
+ struct flow *flow, struct flow_wildcards *wc,
bool take_ref)
{
struct classifier *cls = &ofproto->up.tables[table_id].cls;
@@ -3778,7 +3781,10 @@ rule_dpif_lookup_in_table(struct ofproto_dpif *ofproto, uint8_t table_id,
* on it before this returns.
*
* 'in_port' allows the lookup to take place as if the in port had the value
- * 'in_port'. This is needed for resubmit action support. */
+ * 'in_port'. This is needed for resubmit action support.
+ *
+ * 'flow' is non-const to allow for temporary modifications during the lookup.
+ * Any changes are restored before returning. */
struct rule_dpif *
rule_dpif_lookup_from_table(struct ofproto_dpif *ofproto, struct flow *flow,
struct flow_wildcards *wc, bool take_ref,