Same rule can be in multiple prefix trees and so it is possible that
the total number of rules in all trees exceeds the total number of
rules in the classifier.  But the number of rules in a single prefix
tree still can't exceed the total number of rules in the classifier.
Move the check accordingly.

Note: checkpatch complains about usage of the assert(), but it is
everywhere in this file and so, not changing in just this one place.

Fixes: f358a2cb2e54 ("lib/classifier: RCUify prefix trie code.")
Signed-off-by: Ilya Maximets <i.maxim...@ovn.org>
---
 tests/test-classifier.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 2c1604a01..ee022ba1e 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -509,15 +509,15 @@ static void
 verify_tries(struct classifier *cls)
     OVS_NO_THREAD_SAFETY_ANALYSIS
 {
-    unsigned int n_rules = 0;
+    unsigned int n_rules;
     int i;
 
     for (i = 0; i < cls->n_tries; i++) {
         const struct mf_field * cls_field
             = ovsrcu_get(struct mf_field *, &cls->tries[i].field);
-        n_rules += trie_verify(&cls->tries[i].root, 0, cls_field->n_bits);
+        n_rules = trie_verify(&cls->tries[i].root, 0, cls_field->n_bits);
+        assert(n_rules <= cls->n_rules);
     }
-    assert(n_rules <= cls->n_rules);
 }
 
 static void
-- 
2.49.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to