classifier: New function cls_rule_hash().
authorBen Pfaff <blp@nicira.com>
Thu, 26 May 2011 23:24:38 +0000 (16:24 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 14 Jun 2011 18:21:51 +0000 (11:21 -0700)
An upcoming commit will introduce the first use.

lib/classifier.c
lib/classifier.h

index 185195b..6d5faaa 100644 (file)
@@ -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)
index 4227c98..b1162ae 100644 (file)
@@ -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 *);