Thanks for the reviews, series pushed with suggested changes (upto this patch),

  Jarno

On Jul 7, 2014, at 9:47 AM, Ben Pfaff <b...@nicira.com> wrote:

> On Fri, Jul 04, 2014 at 07:21:19AM -0700, Jarno Rajahalme wrote:
>> This is a prerequisite step in making the classifier lookups lockless.
>> If taking a reference fails, we do the lookup again, as a new (lower
>> priority) rule may now match instead.
>> 
>> Also remove unwildcarding dl_type and nw_frag, as these are already
>> taken care of by xlate_actions().
>> 
>> Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
> 
> I'd be inclined to write the retry loop in rule_dpif_lookup_in_table()
> as an actual "do-while" loop.

Yeah, definitely cleaner this way, thanks for the hint:

@@ -3383,20 +3383,15 @@ rule_dpif_lookup_in_table(struct ofproto_dpif *ofproto, 
uint8_t table_id,
         }
     }
 
-retry:
-    fat_rwlock_rdlock(&cls->rwlock);
-    cls_rule = classifier_lookup(cls, flow, wc);
-    fat_rwlock_unlock(&cls->rwlock);
-
-    rule = rule_dpif_cast(rule_from_cls_rule(cls_rule));
-    if (rule && take_ref) {
-        if (!rule_dpif_try_ref(rule)) {
-            /* The rule was released before we got the ref, so it
-             * cannot be in the classifier any more.  Do another
-             * lookup to find another rule, if any. */
-            goto retry;
-        }
-    }
+    do {
+        fat_rwlock_rdlock(&cls->rwlock);
+        cls_rule = classifier_lookup(cls, flow, wc);
+        fat_rwlock_unlock(&cls->rwlock);
+
+        rule = rule_dpif_cast(rule_from_cls_rule(cls_rule));
+
+        /* Try again if the rule was released before we get the reference. */
+    } while (rule && take_ref && !rule_dpif_try_ref(rule));
 
     return rule;
 }


> 
> Acked-by: Ben Pfaff <b...@nicira.com>

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to