summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-26 16:24:38 -0700
committerBen Pfaff <blp@nicira.com>2011-06-14 11:21:51 -0700
commit57452fdcfb64aca9d110fca0736f6c9587d282f1 (patch)
treeeff96546bf41c1f185a43b5793679975e773e8b5
parent1006cda6d4c36f4e10cab9714d4d625e141a4cad (diff)
downloadopenvswitch-57452fdcfb64aca9d110fca0736f6c9587d282f1.tar.gz
classifier: New function cls_rule_hash().
An upcoming commit will introduce the first use.
-rw-r--r--lib/classifier.c10
-rw-r--r--lib/classifier.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/classifier.c b/lib/classifier.c
index 185195b1e..6d5faaabe 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -406,6 +406,16 @@ cls_rule_equal(const struct cls_rule *a, const struct cls_rule *b)
&& flow_equal(&a->flow, &b->flow));
}
+/* Returns a hash value for the flow, wildcards, and priority in 'rule',
+ * starting from 'basis'. */
+uint32_t
+cls_rule_hash(const struct cls_rule *rule, uint32_t basis)
+{
+ uint32_t h0 = flow_hash(&rule->flow, basis);
+ uint32_t h1 = flow_wildcards_hash(&rule->wc, h0);
+ return hash_int(rule->priority, h1);
+}
+
static void
format_ip_netmask(struct ds *s, const char *name, ovs_be32 ip,
ovs_be32 netmask)
diff --git a/lib/classifier.h b/lib/classifier.h
index 4227c98ab..b1162aeb8 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -114,6 +114,7 @@ bool cls_rule_set_ipv6_dst_masked(struct cls_rule *, const struct in6_addr *,
void cls_rule_set_nd_target(struct cls_rule *, const struct in6_addr);
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 *);
char *cls_rule_to_string(const struct cls_rule *);