uint16_t max_ports; /* Max possible OpenFlow port num, plus one. */
/* Flow tables. */
+ long long int eviction_group_timer; /* For rate limited reheapification. */
struct oftable *tables;
int n_tables;
* With few exceptions, ofproto implementations may look at these fields but
* should not modify them. */
struct rule {
- struct list ofproto_node; /* Owned by ofproto base code. */
struct ofproto *ofproto; /* The ofproto that contains this rule. */
struct cls_rule cr; /* In owning ofproto's classifier. */
struct ofoperation *pending; /* Operation now in progress, if nonnull. */
- ovs_be64 flow_cookie; /* Controller-issued identifier. */
+ ovs_be64 flow_cookie; /* Controller-issued identifier. Guarded by
+ rwlock. */
struct hindex_node cookie_node; /* In owning ofproto's 'cookies' index. */
long long int created; /* Creation time. */
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;
+ /* The rwlock is used to protect those elements in struct rule which are
+ * accessed by multiple threads. While maintaining a pointer to struct
+ * rule, threads are required to hold a readlock. The main ofproto code is
+ * guaranteed not to evict the rule, or change any of the elements "Guarded
+ * by rwlock" without holding the writelock.
+ *
+ * A rule will not be evicted unless both its own and its classifier's
+ * write locks are held. Therefore, while holding a classifier readlock,
+ * one can be assured that write locked rules are safe to reference. */
+ struct ovs_rwlock rwlock;
+ /* Guarded by rwlock. */
struct ofpact *ofpacts; /* Sequence of "struct ofpacts". */
unsigned int ofpacts_len; /* Size of 'ofpacts', in bytes. */
* is expirable, otherwise empty. */
};
+/* A set of rules to which an OpenFlow operation applies. */
+struct rule_collection {
+ struct rule **rules; /* The rules. */
+ size_t n; /* Number of rules collected. */
+
+ size_t capacity; /* Number of rules that will fit in 'rules'. */
+ struct rule *stub[64]; /* Preallocated rules to avoid malloc(). */
+};
+
+void rule_collection_init(struct rule_collection *);
+void rule_collection_add(struct rule_collection *, struct rule *);
+void rule_collection_destroy(struct rule_collection *);
+
/* Threshold at which to begin flow table eviction. Only affects the
* ofproto-dpif implementation */
extern unsigned flow_eviction_threshold;
return cls_rule ? CONTAINER_OF(cls_rule, struct rule, cr) : NULL;
}
-void ofproto_rule_update_used(struct rule *, long long int used);
void ofproto_rule_expire(struct rule *rule, uint8_t reason);
void ofproto_rule_delete(struct ofproto *, struct classifier *cls,
struct rule *) OVS_REQ_WRLOCK(cls->rwlock);
* flow->tunnel and flow->in_port, which are assigned the correct values
* for the incoming packet. The register values are zeroed. 'packet''s
* header pointers (e.g. packet->l3) are appropriately initialized.
+ * packet->l3 is aligned on a 32-bit boundary.
*
* The implementation should add the statistics for 'packet' into 'rule'.
*