classifier: Delete dead code specialized for the exact table.
authorBen Pfaff <blp@nicira.com>
Thu, 11 Nov 2010 23:08:35 +0000 (15:08 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 12 Nov 2010 22:50:45 +0000 (14:50 -0800)
These functions and macros are no longer used.

lib/classifier.c
lib/classifier.h
tests/test-classifier.c

index f568f61..6be47f8 100644 (file)
@@ -60,43 +60,6 @@ cls_table_from_hmap_node(const struct hmap_node *node)
     return node ? CONTAINER_OF(node, struct cls_table, hmap_node) : NULL;
 }
 
-static struct cls_rule *
-cls_rule_from_hmap_node(const struct hmap_node *node)
-{
-    return node ? CONTAINER_OF(node, struct cls_rule, hmap_node) : NULL;
-}
-
-/* Returns the cls_table within 'cls' that has no wildcards, or NULL if there
- * is none.  */
-struct cls_table *
-classifier_exact_table(const struct classifier *cls)
-{
-    struct flow_wildcards exact_wc;
-    flow_wildcards_init_exact(&exact_wc);
-    return find_table(cls, &exact_wc);
-}
-
-/* Returns the first rule in 'table', or a null pointer if 'table' is NULL. */
-struct cls_rule *
-cls_table_first_rule(const struct cls_table *table)
-{
-    return table ? cls_rule_from_hmap_node(hmap_first(&table->rules)) : NULL;
-}
-
-/* Returns the next rule in 'table' following 'rule', or a null pointer if
- * 'rule' is the last rule in 'table'. */
-struct cls_rule *
-cls_table_next_rule(const struct cls_table *table, const struct cls_rule *rule)
-{
-    struct cls_rule *next
-        = CONTAINER_OF(rule->list.next, struct cls_rule, list);
-
-    return (next->priority < rule->priority
-            ? next
-            : cls_rule_from_hmap_node(hmap_next(&table->rules,
-                                                &next->hmap_node)));
-}
-
 /* Converts the flow in 'flow' into a cls_rule in 'rule', with the given
  * 'wildcards' and 'priority'. */
 void
@@ -407,14 +370,6 @@ classifier_count(const struct classifier *cls)
     return cls->n_rules;
 }
 
-/* Returns the number of rules in 'classifier' that have no wildcards. */
-int
-classifier_count_exact(const struct classifier *cls)
-{
-    struct cls_table *exact_table = classifier_exact_table(cls);
-    return exact_table ? exact_table->n_table_rules : 0;
-}
-
 /* Inserts 'rule' into 'cls'.  Until 'rule' is removed from 'cls', the caller
  * must not modify or free it.
  *
index 233893b..1dc9edc 100644 (file)
@@ -104,9 +104,7 @@ void classifier_init(struct classifier *);
 void classifier_destroy(struct classifier *);
 bool classifier_is_empty(const struct classifier *);
 int classifier_count(const struct classifier *);
-int classifier_count_exact(const struct classifier *);
 struct cls_rule *classifier_insert(struct classifier *, struct cls_rule *);
-void classifier_insert_exact(struct classifier *, struct cls_rule *);
 void classifier_remove(struct classifier *, struct cls_rule *);
 struct cls_rule *classifier_lookup(const struct classifier *,
                                    const struct flow *);
@@ -123,22 +121,4 @@ void classifier_for_each_match(const struct classifier *,
 struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
                                               const struct cls_rule *);
 
-/* Iteration shorthands. */
-
-struct cls_table *classifier_exact_table(const struct classifier *);
-struct cls_rule *cls_table_first_rule(const struct cls_table *);
-struct cls_rule *cls_table_next_rule(const struct cls_table *,
-                                     const struct cls_rule *);
-
-#define CLS_TABLE_FOR_EACH_RULE(RULE, MEMBER, TABLE)                    \
-    for ((RULE) = OBJECT_CONTAINING(cls_table_first_rule(TABLE),        \
-                                    RULE, MEMBER);                      \
-         &(RULE)->MEMBER != NULL;                                       \
-         (RULE) = OBJECT_CONTAINING(cls_table_next_rule(TABLE,          \
-                                                        &(RULE)->MEMBER), \
-                                    RULE, MEMBER))
-
-#define CLASSIFIER_FOR_EACH_EXACT_RULE(RULE, MEMBER, CLS)               \
-    CLS_TABLE_FOR_EACH_RULE (RULE, MEMBER, classifier_exact_table(CLS))
-
 #endif /* classifier.h */
index 1308fa5..6cecef7 100644 (file)
@@ -125,19 +125,6 @@ tcls_destroy(struct tcls *tcls)
     }
 }
 
-static int
-tcls_count_exact(const struct tcls *tcls)
-{
-    int n_exact;
-    size_t i;
-
-    n_exact = 0;
-    for (i = 0; i < tcls->n_rules; i++) {
-        n_exact += tcls->rules[i]->cls_rule.wc.wildcards == 0;
-    }
-    return n_exact;
-}
-
 static bool
 tcls_is_empty(const struct tcls *tcls)
 {
@@ -366,7 +353,6 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls)
     unsigned int i;
 
     assert(classifier_count(cls) == tcls->n_rules);
-    assert(classifier_count_exact(cls) == tcls_count_exact(tcls));
     for (i = 0; i < confidence; i++) {
         struct cls_rule *cr0, *cr1;
         struct flow flow;
@@ -426,17 +412,13 @@ check_tables(const struct classifier *cls,
              int n_tables, int n_rules, int n_dups)
 {
     const struct cls_table *table;
-    const struct test_rule *test_rule;
     struct flow_wildcards exact_wc;
     int found_tables = 0;
     int found_rules = 0;
     int found_dups = 0;
-    int n_exact1 = 0;
-    int n_exact2 = 0;
 
     flow_wildcards_init_exact(&exact_wc);
     HMAP_FOR_EACH (table, hmap_node, &cls->tables) {
-        bool is_exact = flow_wildcards_equal(&table->wc, &exact_wc);
         const struct cls_rule *head;
 
         assert(!hmap_is_empty(&table->rules));
@@ -447,31 +429,20 @@ check_tables(const struct classifier *cls,
             const struct cls_rule *rule;
 
             found_rules++;
-            if (is_exact) {
-                n_exact1++;
-            }
             LIST_FOR_EACH (rule, list, &head->list) {
                 assert(rule->priority < prev_priority);
                 prev_priority = rule->priority;
                 found_rules++;
                 found_dups++;
-                if (is_exact) {
-                    n_exact1++;
-                }
                 assert(classifier_find_rule_exactly(cls, rule) == rule);
             }
         }
     }
 
-    CLASSIFIER_FOR_EACH_EXACT_RULE (test_rule, cls_rule, cls) {
-        n_exact2++;
-    }
-
     assert(found_tables == hmap_count(&cls->tables));
     assert(n_tables == -1 || n_tables == hmap_count(&cls->tables));
     assert(n_rules == -1 || found_rules == n_rules);
     assert(n_dups == -1 || found_dups == n_dups);
-    assert(n_exact1 == n_exact2);
 }
 
 static struct test_rule *