From f6acdb447eb22b710ff1901b333022f191a41ff4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 28 Oct 2010 16:19:45 -0700 Subject: [PATCH] classifier: Remove classifier_for_each(), classifier_for_each_match(). These functions no longer have any users. --- lib/classifier.c | 103 +---------------------------------------------- lib/classifier.h | 6 --- 2 files changed, 1 insertion(+), 108 deletions(-) diff --git a/lib/classifier.c b/lib/classifier.c index 3387767bb..591322e77 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -423,7 +423,7 @@ classifier_remove(struct classifier *cls, struct cls_rule *rule) hmap_replace(&table->rules, &rule->hmap_node, &next->hmap_node); } - if (--table->n_table_rules == 0 && !table->n_refs) { + if (--table->n_table_rules == 0) { destroy_table(cls, table); } @@ -507,107 +507,6 @@ classifier_rule_overlaps(const struct classifier *cls, return false; } - -/* Searches 'cls' for rules that exactly match 'target' or are more specific - * than 'target'. That is, a given 'rule' matches 'target' if, for every - * field: - * - * - 'target' and 'rule' specify the same (non-wildcarded) value for the - * field, or - * - * - 'target' wildcards the field, - * - * but not if: - * - * - 'target' and 'rule' specify different values for the field, or - * - * - 'target' specifies a value for the field but 'rule' wildcards it. - * - * Equivalently, the truth table for whether a field matches is: - * - * rule - * - * wildcard exact - * +---------+---------+ - * t wild | yes | yes | - * a card | | | - * r +---------+---------+ - * g exact | no |if values| - * e | |are equal| - * t +---------+---------+ - * - * This is the matching rule used by OpenFlow 1.0 non-strict OFPT_FLOW_MOD - * commands and by OpenFlow 1.0 aggregate and flow stats. - * - * Ignores target->priority. - * - * 'callback' is allowed to delete the rule that is passed as its argument, but - * it must not delete (or move) any other rules in 'cls' that have the same - * wildcards as the argument rule. */ -void -classifier_for_each_match(const struct classifier *cls_, - const struct cls_rule *target, - cls_cb_func *callback, void *aux) -{ - struct classifier *cls = (struct classifier *) cls_; - struct cls_table *table, *next_table; - - for (table = classifier_first_table(cls); table; table = next_table) { - if (!flow_wildcards_has_extra(&table->wc, &target->wc)) { - /* We have eliminated the "no" case in the truth table above. Two - * of the three remaining cases are trivial. We only need to check - * the fourth case, where both 'rule' and 'target' require an exact - * match. */ - struct cls_rule *head, *next_head; - - table->n_refs++; - HMAP_FOR_EACH_SAFE (head, next_head, hmap_node, &table->rules) { - if (flow_equal_except(&head->flow, &target->flow, - &target->wc)) { - struct cls_rule *rule, *next_rule; - - FOR_EACH_RULE_IN_LIST_SAFE (rule, next_rule, head) { - callback(rule, aux); - } - } - } - next_table = classifier_next_table(cls, table); - if (!--table->n_refs && !table->n_table_rules) { - destroy_table(cls, table); - } - } else { - next_table = classifier_next_table(cls, table); - } - } -} - -/* 'callback' is allowed to delete the rule that is passed as its argument, but - * it must not delete (or move) any other rules in 'cls' that have the same - * wildcards as the argument rule. */ -void -classifier_for_each(const struct classifier *cls_, - cls_cb_func *callback, void *aux) -{ - struct classifier *cls = (struct classifier *) cls_; - struct cls_table *table, *next_table; - - for (table = classifier_first_table(cls); table; table = next_table) { - struct cls_rule *head, *next_head; - - table->n_refs++; - HMAP_FOR_EACH_SAFE (head, next_head, hmap_node, &table->rules) { - struct cls_rule *rule, *next_rule; - - FOR_EACH_RULE_IN_LIST_SAFE (rule, next_rule, head) { - callback(rule, aux); - } - } - next_table = classifier_next_table(cls, table); - if (!--table->n_refs && !table->n_table_rules) { - destroy_table(cls, table); - } - } -} /* Iteration. */ diff --git a/lib/classifier.h b/lib/classifier.h index 220a3395e..c22a161e6 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -44,7 +44,6 @@ struct cls_table { struct hmap rules; /* Contains "struct cls_rule"s. */ struct flow_wildcards wc; /* Wildcards for fields. */ int n_table_rules; /* Number of rules, including duplicates. */ - int n_refs; /* Reference count used during iteration. */ }; /* A flow classification rule. @@ -113,11 +112,6 @@ bool classifier_rule_overlaps(const struct classifier *, typedef void cls_cb_func(struct cls_rule *, void *aux); -void classifier_for_each(const struct classifier *, - cls_cb_func *, void *aux); -void classifier_for_each_match(const struct classifier *, - const struct cls_rule *, - cls_cb_func *, void *aux); struct cls_rule *classifier_find_rule_exactly(const struct classifier *, const struct cls_rule *); -- 2.43.0