classifier: Check all rules of equal priority when inserting.
authorJesse Gross <jesse@nicira.com>
Fri, 19 Mar 2010 16:08:16 +0000 (12:08 -0400)
committerJesse Gross <jesse@nicira.com>
Fri, 19 Mar 2010 16:18:57 +0000 (12:18 -0400)
When adding a new classifier rule we check if there is a rule
of the same priority first and overwrite it before inserting a
new rule.  Previously we would stop looking if we found one rule
in the correct bucket with the same priority, even if it didn't
match.  This keeps going until we either find a matching rule or
we run out of equal priority rules.

Reported-by: Tetsuo NAKAGAWA <nakagawa@mxc.nes.nec.co.jp>
lib/classifier.c

index cdad9c9e1bc8caf44d32c48ec4680caabe2ff027..ee78dadd95d80cba9bab0656359420de7d6622be 100644 (file)
@@ -640,14 +640,14 @@ bucket_insert(struct cls_bucket *bucket, struct cls_rule *rule)
 {
     struct cls_rule *pos;
     LIST_FOR_EACH (pos, struct cls_rule, node.list, &bucket->rules) {
-        if (pos->priority <= rule->priority) {
-            if (pos->priority == rule->priority
-                && pos->wc.wildcards == rule->wc.wildcards
+        if (pos->priority == rule->priority) {
+            if (pos->wc.wildcards == rule->wc.wildcards
                 && rules_match_1wild(pos, rule, rule->table_idx))
             {
                 list_replace(&rule->node.list, &pos->node.list);
                 return pos;
             }
+        } else if (pos->priority < rule->priority) {
             break;
         }
     }