summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ofproto/ofproto-provider.h5
-rw-r--r--ofproto/ofproto.c13
2 files changed, 8 insertions, 10 deletions
diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index 9dc73c482..ae4af4525 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -1874,7 +1874,10 @@ struct rule_criteria {
/* flow_mod with execution context. */
struct ofproto_flow_mod {
/* Allocated by 'init' phase, may be freed after 'start' phase, as these
- * are not needed for 'revert' nor 'finish'. */
+ * are not needed for 'revert' nor 'finish'.
+ *
+ * This structure owns a reference to 'temp_rule' (if it is nonnull) that
+ * must be eventually be released with ofproto_rule_unref(). */
struct rule *temp_rule;
struct rule_criteria criteria;
struct cls_conjunction *conjs;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index d42acd747..e776cd8b5 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -4955,8 +4955,6 @@ ofproto_flow_mod_init_for_learn(struct ofproto *ofproto,
struct ofproto_flow_mod *ofm)
OVS_EXCLUDED(ofproto_mutex)
{
- enum ofperr error;
-
/* Reject flow mods that do not look like they were generated by a learn
* action. */
if (fm->command != OFPFC_MODIFY_STRICT || fm->table_id == OFPTT_ALL
@@ -4997,13 +4995,7 @@ ofproto_flow_mod_init_for_learn(struct ofproto *ofproto,
}
}
- /* Initialize ofproto_flow_mod for future use. */
- error = ofproto_flow_mod_init(ofproto, ofm, fm, rule);
- if (error) {
- ofproto_rule_unref(rule);
- return error;
- }
- return 0;
+ return ofproto_flow_mod_init(ofproto, ofm, fm, rule);
}
enum ofperr
@@ -7558,6 +7550,9 @@ ofproto_flow_mod_uninit(struct ofproto_flow_mod *ofm)
}
}
+/* Initializes 'ofm' with 'ofproto', 'fm', and 'rule'. 'rule' may be null, but
+ * if it is nonnull then the caller must own a reference to it, which on
+ * success is transferred to 'ofm' and on failure is unreffed. */
static enum ofperr
ofproto_flow_mod_init(struct ofproto *ofproto, struct ofproto_flow_mod *ofm,
const struct ofputil_flow_mod *fm, struct rule *rule)