/* Initializes 'rule' to match packets specified by 'match' at the given
* 'priority'.
*
+ * The caller must eventually destroy 'rule' with cls_rule_destroy().
+ *
* 'match' must satisfy the invariant described in the comment at the
* definition of struct match.
*
rule->priority = priority;
}
+/* Initializes 'dst' as a copy of 'src'.
+ *
+ * The caller must eventually destroy 'rule' with cls_rule_destroy(). */
+void
+cls_rule_clone(struct cls_rule *dst, const struct cls_rule *src)
+{
+ *dst = *src;
+}
+
+/* Frees memory referenced by 'rule'. Doesn't free 'rule' itself (it's
+ * normally embedded into a larger structure).
+ *
+ * ('rule' must not currently be in a classifier.) */
+void
+cls_rule_destroy(struct cls_rule *rule OVS_UNUSED)
+{
+ /* Nothing to do yet. */
+}
+
/* Returns true if 'a' and 'b' match the same packets at the same priority,
* false if they differ in some way. */
bool
* If 'cls' already contains an identical rule (including wildcards, values of
* fixed fields, and priority), replaces the old rule by 'rule' and returns the
* rule that was replaced. The caller takes ownership of the returned rule and
- * is thus responsible for freeing it, etc., as necessary.
+ * is thus responsible for destroying it with cls_rule_destroy(), freeing the
+ * memory block in which it resides, etc., as necessary.
*
* Returns NULL if 'cls' does not contain a rule with an identical key, after
* inserting the new rule. In this case, no rules are displaced by the new
assert(!displaced_rule);
}
-/* Removes 'rule' from 'cls'. It is the caller's responsibility to free
- * 'rule', if this is desirable. */
+/* Removes 'rule' from 'cls'. It is the caller's responsibility to destroy
+ * 'rule' with cls_rule_destroy(), freeing the memory block in which 'rule'
+ * resides, etc., as necessary. */
void
classifier_remove(struct classifier *cls, struct cls_rule *rule)
{
cls_rule_init(&cr, target, priority);
retval = classifier_find_rule_exactly(cls, &cr);
+ cls_rule_destroy(&cr);
return retval;
}