* A struct rule_actions may be accessed without a risk of being
* freed by code that holds a read-lock or write-lock on 'rule->mutex' (where
* 'rule' is the rule for which 'rule->actions == actions') or during the RCU
- * active period. */
+ * active period.
+ *
+ * All members are immutable: they do not change during the struct's
+ * lifetime. */
struct rule_actions {
- /* These members are immutable: they do not change during the struct's
- * lifetime. */
+ /* Flags.
+ *
+ * 'has_meter' is true if 'ofpacts' contains an OFPACT_METER action. */
+ bool has_meter;
+
+ /* Actions. */
uint32_t ofpacts_len; /* Size of 'ofpacts', in bytes. */
- uint32_t provider_meter_id; /* Datapath meter_id, or UINT32_MAX. */
struct ofpact ofpacts[]; /* Sequence of "struct ofpacts". */
};
BUILD_ASSERT_DECL(offsetof(struct rule_actions, ofpacts) % OFPACT_ALIGNTO == 0);
-const struct rule_actions *rule_actions_create(const struct ofproto *,
- const struct ofpact *, size_t);
+const struct rule_actions *rule_actions_create(const struct ofpact *, size_t);
void rule_actions_destroy(const struct rule_actions *);
/* A set of rules to which an OpenFlow operation applies. */
/* Creates and returns a new 'struct rule_actions', whose actions are a copy
* of from the 'ofpacts_len' bytes of 'ofpacts'. */
const struct rule_actions *
-rule_actions_create(const struct ofproto *ofproto,
- const struct ofpact *ofpacts, size_t ofpacts_len)
+rule_actions_create(const struct ofpact *ofpacts, size_t ofpacts_len)
{
struct rule_actions *actions;
actions = xmalloc(sizeof *actions + ofpacts_len);
actions->ofpacts_len = ofpacts_len;
- actions->provider_meter_id
- = get_provider_meter_id(ofproto,
- ofpacts_get_meter(ofpacts, ofpacts_len));
+ actions->has_meter = ofpacts_get_meter(ofpacts, ofpacts_len) != 0;
memcpy(actions->ofpacts, ofpacts, ofpacts_len);
return actions;
*CONST_CAST(uint8_t *, &rule->table_id) = table - ofproto->tables;
rule->flags = fm->flags & OFPUTIL_FF_STATE;
- actions = rule_actions_create(ofproto, fm->ofpacts, fm->ofpacts_len);
+ actions = rule_actions_create(fm->ofpacts, fm->ofpacts_len);
ovsrcu_set(&rule->actions, actions);
list_init(&rule->meter_list_node);
rule->eviction_group = NULL;
}
cookies_insert(ofproto, rule);
eviction_group_add_rule(rule);
- if (actions->provider_meter_id != UINT32_MAX) {
+ if (actions->has_meter) {
meter_insert_rule(rule);
}
}
if (change_actions) {
- ovsrcu_set(&rule->actions, rule_actions_create(ofproto,
- fm->ofpacts,
+ ovsrcu_set(&rule->actions, rule_actions_create(fm->ofpacts,
fm->ofpacts_len));
rule_actions_destroy(actions);
}