When cls_cursor_init() is given a NULL target, it can skip an expensive
step comparing the rule against the target for every table and every rule
in the classifier. collect_rule_loose() and other callers could take
advantage of this optimization, except that they actually pass in a rule
that matches everything instead of a NULL rule (e.g. for "ovs-ofctl
dump-flows <bridge>" without specifying a matching rule).
This optimizes that case.
Signed-off-by: Ben Pfaff <blp@nicira.com>
{
match_format(&rule->match, s, rule->priority);
}
+
+/* Returns true if 'rule' matches every packet, false otherwise. */
+bool
+cls_rule_is_catchall(const struct cls_rule *rule)
+{
+ return flow_wildcards_is_catchall(&rule->match.wc);
+}
\f
/* Initializes 'cls' as a classifier that initially contains no classification
* rules. */
const struct cls_rule *target)
{
cursor->cls = cls;
- cursor->target = target;
+ cursor->target = target && !cls_rule_is_catchall(target) ? target : NULL;
}
/* Returns the first matching cls_rule in 'cursor''s iteration, or a null
void cls_rule_format(const struct cls_rule *, struct ds *);
+bool cls_rule_is_catchall(const struct cls_rule *);
+
bool cls_rule_is_loose_match(const struct cls_rule *rule,
const struct match *criteria);