flow: New function flow_wildcards_is_exact().
authorBen Pfaff <blp@nicira.com>
Tue, 9 Nov 2010 00:45:00 +0000 (16:45 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 22 Nov 2010 17:40:35 +0000 (09:40 -0800)
lib/classifier.c
lib/flow.c
lib/flow.h
tests/test-classifier.c

index f3b5d5d..c57c7e5 100644 (file)
@@ -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) {
index 0b6541f..3ac3530 100644 (file)
@@ -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)
 {
index a19a9ae..b30a885 100644 (file)
@@ -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 *,
index 45700ed..063f718 100644 (file)
@@ -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)) {