From: Ben Pfaff Date: Thu, 26 May 2011 23:24:38 +0000 (-0700) Subject: classifier: New function cls_rule_hash(). X-Git-Tag: v1.2.0~202 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=57452fdcfb64aca9d110fca0736f6c9587d282f1;p=sliver-openvswitch.git classifier: New function cls_rule_hash(). An upcoming commit will introduce the first use. --- 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 *);