- /* Eviction groups. */
- struct heap_node evg_node; /* In eviction_group's "rules" heap. */
- struct eviction_group *eviction_group; /* NULL if not in any group. */
-
- /* The evict lock is used to prevent rules from being evicted while child
- * threads are using them to xlate flows. A read lock means the rule is
- * currently being used. A write lock means the rule is in the process of
- * being evicted and should be considered gone. A rule will not be evicted
- * unless both its own and its classifiers write locks are held.
- * Therefore, while holding a classifier readlock, one can be assured that
- * even write locked rules are safe. */
- struct ovs_rwlock evict;
-
- struct ofpact *ofpacts; /* Sequence of "struct ofpacts". */
- unsigned int ofpacts_len; /* Size of 'ofpacts', in bytes. */
-
- uint32_t meter_id; /* Non-zero OF meter_id, or zero. */
- struct list meter_list_node; /* In owning meter's 'rules' list. */
-
- /* Flow monitors. */
- enum nx_flow_monitor_flags monitor_flags;
- uint64_t add_seqno; /* Sequence number when added. */
- uint64_t modify_seqno; /* Sequence number when changed. */
-
- /* Optimisation for flow expiry. */
- struct list expirable; /* In ofproto's 'expirable' list if this rule
- * is expirable, otherwise empty. */
+ /* Eviction groups (see comment on struct eviction_group for explanation) .
+ *
+ * 'eviction_group' is this rule's eviction group, or NULL if it is not in
+ * any eviction group. When 'eviction_group' is nonnull, 'evg_node' is in
+ * the ->eviction_group->rules hmap. */
+ struct eviction_group *eviction_group OVS_GUARDED_BY(ofproto_mutex);
+ struct heap_node evg_node OVS_GUARDED_BY(ofproto_mutex);
+
+ /* OpenFlow actions. See struct rule_actions for more thread-safety
+ * notes. */
+ OVSRCU_TYPE(const struct rule_actions *) actions;
+
+ /* In owning meter's 'rules' list. An empty list if there is no meter. */
+ struct list meter_list_node OVS_GUARDED_BY(ofproto_mutex);
+
+ /* Flow monitors (e.g. for NXST_FLOW_MONITOR, related to struct ofmonitor).
+ *
+ * 'add_seqno' is the sequence number when this rule was created.
+ * 'modify_seqno' is the sequence number when this rule was last modified.
+ * See 'monitor_seqno' in connmgr.c for more information. */
+ enum nx_flow_monitor_flags monitor_flags OVS_GUARDED_BY(ofproto_mutex);
+ uint64_t add_seqno OVS_GUARDED_BY(ofproto_mutex);
+ uint64_t modify_seqno OVS_GUARDED_BY(ofproto_mutex);
+
+ /* Optimisation for flow expiry. In ofproto's 'expirable' list if this
+ * rule is expirable, otherwise empty. */
+ struct list expirable OVS_GUARDED_BY(ofproto_mutex);
+
+ /* Times. Last so that they are more likely close to the stats managed
+ * by the provider. */
+ long long int created OVS_GUARDED; /* Creation time. */
+
+ /* Must hold 'mutex' for both read/write, 'ofproto_mutex' not needed. */
+ long long int modified OVS_GUARDED; /* Time of last modification. */
+};
+
+void ofproto_rule_ref(struct rule *);
+void ofproto_rule_unref(struct rule *);
+
+static inline const struct rule_actions * rule_get_actions(const struct rule *);
+static inline bool rule_is_table_miss(const struct rule *);
+
+/* A set of actions within a "struct rule".
+ *
+ *
+ * Thread-safety
+ * =============
+ *
+ * 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. */
+struct rule_actions {
+ /* These members are immutable: they do not change during the struct's
+ * lifetime. */
+ 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". */