-void classifier_for_each(const struct classifier *, int include,
- cls_cb_func *, void *aux);
-void classifier_for_each_match(const struct classifier *,
- const struct cls_rule *,
- int include, cls_cb_func *, void *aux);
-struct cls_rule *classifier_find_rule_exactly(const struct classifier *,
- const struct cls_rule *);
-
-/* Iteration shorthands. */
-
-struct cls_table *classifier_exact_table(const struct classifier *);
-struct cls_rule *cls_table_first_rule(const struct cls_table *);
-struct cls_rule *cls_table_next_rule(const struct cls_table *,
- const struct cls_rule *);
-
-#define CLS_TABLE_FOR_EACH_RULE(RULE, MEMBER, TABLE) \
- for ((RULE) = OBJECT_CONTAINING(cls_table_first_rule(TABLE), \
- RULE, MEMBER); \
- &(RULE)->MEMBER != NULL; \
- (RULE) = OBJECT_CONTAINING(cls_table_next_rule(TABLE, \
- &(RULE)->MEMBER), \
- RULE, MEMBER))
-
-#define CLASSIFIER_FOR_EACH_EXACT_RULE(RULE, MEMBER, CLS) \
- CLS_TABLE_FOR_EACH_RULE (RULE, MEMBER, classifier_exact_table(CLS))
+struct cls_rule *classifier_find_rule_exactly(const struct classifier *cls,
+ const struct cls_rule *)
+ OVS_REQ_RDLOCK(cls->rwlock);
+struct cls_rule *classifier_find_match_exactly(const struct classifier *cls,
+ const struct match *,
+ unsigned int priority)
+ OVS_REQ_RDLOCK(cls->rwlock);
+\f
+/* Iteration. */
+
+struct cls_cursor {
+ const struct classifier *cls;
+ const struct cls_table *table;
+ const struct cls_rule *target;
+};
+
+void cls_cursor_init(struct cls_cursor *cursor, const struct classifier *cls,
+ const struct cls_rule *match) OVS_REQ_RDLOCK(cls->rwlock);
+struct cls_rule *cls_cursor_first(struct cls_cursor *cursor);
+struct cls_rule *cls_cursor_next(struct cls_cursor *cursor, struct cls_rule *);
+
+#define CLS_CURSOR_FOR_EACH(RULE, MEMBER, CURSOR) \
+ for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER); \
+ RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER); \
+ ASSIGN_CONTAINER(RULE, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \
+ MEMBER))
+
+#define CLS_CURSOR_FOR_EACH_SAFE(RULE, NEXT, MEMBER, CURSOR) \
+ for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER); \
+ (RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER) \
+ ? ASSIGN_CONTAINER(NEXT, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \
+ MEMBER), 1 \
+ : 0); \
+ (RULE) = (NEXT))
+
+#ifdef __cplusplus
+}
+#endif