[ovs-dev] [LimitFlows 1/4] classifier: New function classifier_count_wild().

Ben Pfaff blp at nicira.com
Mon Apr 19 21:08:48 UTC 2010


---
 lib/classifier.c |    8 ++++++++
 lib/classifier.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/classifier.c b/lib/classifier.c
index 4bd8942..d425c3a 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -209,6 +209,14 @@ classifier_count_exact(const struct classifier *cls)
     return hmap_count(&cls->exact_table);
 }
 
+/* Returns the number of rules in 'classifier' that have at least one
+ * wildcard. */
+int
+classifier_count_wild(const struct classifier *cls)
+{
+    return cls->n_rules - classifier_count_exact(cls);
+}
+
 /* Inserts 'rule' into 'cls'.  Transfers ownership of 'rule' to 'cls'.
  *
  * If 'cls' already contains an identical rule (including wildcards, values of
diff --git a/lib/classifier.h b/lib/classifier.h
index 3551602..43f858c 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -140,6 +140,7 @@ 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 *);
+int classifier_count_wild(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 *);
-- 
1.6.6.1





More information about the dev mailing list