@@ -1494,6 +1494,7 @@ construct(struct ofproto *ofproto_)
ofproto->ams_seq = seq_create();
ofproto->ams_seqno = seq_read(ofproto->ams_seq);
+ ovs_refcount_init(&ofproto_->ref_count);
SHASH_FOR_EACH_SAFE (node, next, &init_ofp_ports) {
struct iface_hint *iface_hint = node->data;
@@ -139,6 +139,7 @@ struct ofproto {
/* Variable length mf_field mapping. Stores all configured variable length
* meta-flow fields (struct mf_field) in a switch. */
struct vl_mff_map vl_mff_map;
+ struct ovs_refcount ref_count;
};
void ofproto_init_tables(struct ofproto *, int n_tables);
@@ -442,6 +443,8 @@ struct rule {
void ofproto_rule_ref(struct rule *);
bool ofproto_rule_try_ref(struct rule *);
void ofproto_rule_unref(struct rule *);
+void ofproto_ref(struct ofproto *ofproto);
+void ofproto_unref(struct ofproto *ofproto);
static inline const struct rule_actions * rule_get_actions(const struct rule *);
static inline bool rule_is_table_miss(const struct rule *);
@@ -554,6 +554,10 @@ ofproto_create(const char *datapath_name, const char *datapath_type,
ovs_mutex_unlock(&ofproto_mutex);
ofproto_destroy__(ofproto);
return error;
+ } else {
+ /* ofproto construct succeed, ref its self
+ * inorder to unref when call ofproto destroy*/
+ ofproto_ref(ofproto);
}
/* Check that hidden tables, if any, are at the end. */
@@ -1673,8 +1677,9 @@ ofproto_destroy(struct ofproto *p, bool del)