+/* Checks if the flow defined by 'target' with 'wildcards' at 'priority'
+ * overlaps with any other rule at the same priority in the classifier.
+ * Two rules are considered overlapping if a packet could match both. */
+bool
+classifier_rule_overlaps(const struct classifier *cls,
+ const flow_t *target, uint32_t wildcards,
+ unsigned int priority)
+{
+ struct cls_rule target_rule;
+ const struct hmap *tbl;
+
+ if (!wildcards) {
+ return search_exact_table(cls, flow_hash(target, 0), target) ?
+ true : false;
+ }
+
+ cls_rule_from_flow(&target_rule, target, wildcards, priority);
+
+ for (tbl = &cls->tables[0]; tbl < &cls->tables[CLS_N_FIELDS]; tbl++) {
+ struct cls_bucket *bucket;
+
+ HMAP_FOR_EACH (bucket, struct cls_bucket, hmap_node, tbl) {
+ struct cls_rule *rule;
+
+ LIST_FOR_EACH (rule, struct cls_rule, node.list,
+ &bucket->rules) {
+ if (rule->priority == priority
+ && rules_match_2wild(rule, &target_rule, 0)) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+