+/* Creates and returns a new 'struct rule_actions', with a ref_count of 1,
+ * whose actions are a copy of from the 'ofpacts_len' bytes of 'ofpacts'. */
+struct rule_actions *
+rule_actions_create(const struct ofpact *ofpacts, size_t ofpacts_len)
+{
+ struct rule_actions *actions;
+
+ actions = xmalloc(sizeof *actions);
+ atomic_init(&actions->ref_count, 1);
+ actions->ofpacts = xmemdup(ofpacts, ofpacts_len);
+ actions->ofpacts_len = ofpacts_len;
+ actions->meter_id = ofpacts_get_meter(ofpacts, ofpacts_len);
+ return actions;
+}
+
+/* Increments 'actions''s ref_count. */
+void
+rule_actions_ref(struct rule_actions *actions)
+{
+ if (actions) {
+ unsigned int orig;
+
+ atomic_add(&actions->ref_count, 1, &orig);
+ ovs_assert(orig != 0);
+ }
+}
+
+/* Decrements 'actions''s ref_count and frees 'actions' if the ref_count
+ * reaches 0. */
+void
+rule_actions_unref(struct rule_actions *actions)
+{
+ if (actions) {
+ unsigned int orig;
+
+ atomic_sub(&actions->ref_count, 1, &orig);
+ if (orig == 1) {
+ free(actions);
+ } else {
+ ovs_assert(orig != 0);
+ }
+ }
+}
+