From: Ben Pfaff Date: Tue, 9 Nov 2010 00:45:00 +0000 (-0800) Subject: flow: New function flow_wildcards_is_exact(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00561f415c3a1622f8835c84ba2db7e7ff0fbe61;p=openvswitch flow: New function flow_wildcards_is_exact(). --- diff --git a/lib/classifier.c b/lib/classifier.c index f3b5d5d2..c57c7e56 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -479,7 +479,7 @@ classifier_find_rule_exactly(const struct classifier *cls, } head = find_equal(table, &target->flow, flow_hash(&target->flow, 0)); - if (!target->wc.wildcards) { + if (flow_wildcards_is_exact(&target->wc)) { return head; } FOR_EACH_RULE_IN_LIST (rule, head) { diff --git a/lib/flow.c b/lib/flow.c index 0b6541f6..3ac35308 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -420,6 +420,14 @@ flow_wildcards_init_exact(struct flow_wildcards *wc) memset(wc->reg_masks, 0xff, sizeof wc->reg_masks); } +/* Returns true if 'wc' is exact-match, false if 'wc' wildcards any bits or + * fields. */ +bool +flow_wildcards_is_exact(const struct flow_wildcards *wc) +{ + return !wc->wildcards; +} + static inline uint32_t combine_nw_bits(uint32_t wb1, uint32_t wb2, int shift) { diff --git a/lib/flow.h b/lib/flow.h index a19a9ae5..b30a885d 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -150,6 +150,8 @@ ovs_be32 flow_nw_bits_to_mask(uint32_t wildcards, int shift); void flow_wildcards_init(struct flow_wildcards *, uint32_t wildcards); void flow_wildcards_init_exact(struct flow_wildcards *); +bool flow_wildcards_is_exact(const struct flow_wildcards *); + bool flow_wildcards_set_nw_src_mask(struct flow_wildcards *, ovs_be32); bool flow_wildcards_set_nw_dst_mask(struct flow_wildcards *, ovs_be32); void flow_wildcards_set_reg_mask(struct flow_wildcards *, diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 45700ed9..063f718f 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -136,7 +136,8 @@ tcls_insert(struct tcls *tcls, const struct test_rule *rule) { size_t i; - assert(rule->cls_rule.wc.wildcards || rule->cls_rule.priority == UINT_MAX); + assert(!flow_wildcards_is_exact(&rule->cls_rule.wc) + || rule->cls_rule.priority == UINT_MAX); for (i = 0; i < tcls->n_rules; i++) { const struct cls_rule *pos = &tcls->rules[i]->cls_rule; if (cls_rule_equal(pos, &rule->cls_rule)) {