/* OFOPERATION_DELETE. */
enum ofp_flow_removed_reason reason; /* Reason flow was removed. */
- ovs_be64 flow_cookie; /* Rule's old flow cookie. */
- uint16_t idle_timeout; /* Rule's old idle timeout. */
- uint16_t hard_timeout; /* Rule's old hard timeout. */
- bool send_flow_removed; /* Rule's old 'send_flow_removed'. */
- enum ofperr error; /* 0 if no error. */
+ ovs_be64 flow_cookie; /* Rule's old flow cookie. */
+ uint16_t idle_timeout; /* Rule's old idle timeout. */
+ uint16_t hard_timeout; /* Rule's old hard timeout. */
+ enum ofputil_flow_mod_flags flags; /* Rule's old flags. */
+ enum ofperr error; /* 0 if no error. */
};
static struct ofoperation *ofoperation_create(struct ofopgroup *,
static void reinit_ports(struct ofproto *);
/* rule. */
+static void ofproto_rule_destroy(struct rule *);
static void ofproto_rule_destroy__(struct rule *);
static void ofproto_rule_send_removed(struct rule *, uint8_t reason);
static bool rule_is_modifiable(const struct rule *);
}
/* Sets number of upcall handler threads. The default is
- * (number of online cores - 1). */
+ * (number of online cores - 2). */
void
ofproto_set_n_handler_threads(unsigned limit)
{
if (limit) {
n_handler_threads = limit;
} else {
- n_handler_threads = MAX(1, sysconf(_SC_NPROCESSORS_ONLN) - 1);
+ int n_proc = sysconf(_SC_NPROCESSORS_ONLN);
+ n_handler_threads = n_proc > 2 ? n_proc - 2 : 1;
}
}
struct oftable *table = &p->tables[i];
struct eviction_group *evg;
struct cls_cursor cursor;
- struct cls_rule cr;
struct rule *rule;
if (!table->eviction_fields) {
}
ovs_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, &cr);
+ cls_cursor_init(&cursor, &table->cls, NULL);
CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
if (!rule->eviction_group
&& (rule->idle_timeout || rule->hard_timeout)) {
}
\f
static void
-ofproto_rule_destroy__(struct rule *rule)
+ofproto_rule_destroy(struct rule *rule)
{
if (rule) {
rule->ofproto->ofproto_class->rule_destruct(rule);
- cls_rule_destroy(&rule->cr);
- free(rule->ofpacts);
- ovs_mutex_destroy(&rule->timeout_mutex);
- ovs_rwlock_destroy(&rule->rwlock);
- rule->ofproto->ofproto_class->rule_dealloc(rule);
+ ofproto_rule_destroy__(rule);
}
}
+static void
+ofproto_rule_destroy__(struct rule *rule)
+{
+ cls_rule_destroy(&rule->cr);
+ free(rule->ofpacts);
+ ovs_mutex_destroy(&rule->timeout_mutex);
+ ovs_rwlock_destroy(&rule->rwlock);
+ rule->ofproto->ofproto_class->rule_dealloc(rule);
+}
+
/* This function allows an ofproto implementation to destroy any rules that
* remain when its ->destruct() function is called.. This function implements
* steps 4.4 and 4.5 in the section titled "Rule Life Cycle" in
goto exit;
}
if (rule->flow_cookie == cookie /* Hash collisions possible. */
- && ofproto_rule_has_out_port(rule, out_port)) {
+ && ofproto_rule_has_out_port(rule, out_port)
+ && ofproto_rule_has_out_group(rule, out_group)) {
list_push_back(rules, &rule->ofproto_node);
}
}
goto exit;
}
if (rule->flow_cookie == cookie /* Hash collisions possible. */
- && ofproto_rule_has_out_port(rule, out_port)) {
+ && ofproto_rule_has_out_port(rule, out_port)
+ && ofproto_rule_has_out_group(rule, out_group)) {
list_push_back(rules, &rule->ofproto_node);
}
}
fs.hard_timeout = rule->hard_timeout;
ovs_mutex_unlock(&rule->timeout_mutex);
- fs.flags = 0;
- if (rule->send_flow_removed) {
- fs.flags |= OFPUTIL_FF_SEND_FLOW_REM;
- /* FIXME: Implement OFPUTIL_FF_NO_PKT_COUNTS and
- OFPUTIL_FF_NO_BYT_COUNTS. */
- }
+ fs.flags = rule->flags;
+
ofputil_append_flow_stats_reply(&fs, &replies);
}
ofconn_send_replies(ofconn, &replies);
ovs_mutex_unlock(&rule->timeout_mutex);
rule->table_id = table - ofproto->tables;
- rule->send_flow_removed = (fm->flags & OFPUTIL_FF_SEND_FLOW_REM) != 0;
+ rule->flags = fm->flags & OFPUTIL_FF_STATE;
+
rule->ofpacts = xmemdup(fm->ofpacts, fm->ofpacts_len);
rule->ofpacts_len = fm->ofpacts_len;
rule->meter_id = find_meter(rule->ofpacts, rule->ofpacts_len);
rule->hard_timeout = fm->hard_timeout;
ovs_mutex_unlock(&rule->timeout_mutex);
- rule->send_flow_removed = (fm->flags
- & OFPUTIL_FF_SEND_FLOW_REM) != 0;
-
+ rule->flags = fm->flags & OFPUTIL_FF_STATE;
if (fm->idle_timeout || fm->hard_timeout) {
if (!rule->eviction_group) {
eviction_group_add_rule(rule);
{
struct ofputil_flow_removed fr;
- if (ofproto_rule_is_hidden(rule) || !rule->send_flow_removed) {
+ if (ofproto_rule_is_hidden(rule) ||
+ !(rule->flags & OFPUTIL_FF_SEND_FLOW_REM)) {
return;
}
} else {
ovs_rwlock_wrlock(&rule->rwlock);
oftable_remove_rule(rule);
- ofproto_rule_destroy__(rule);
+ ofproto_rule_destroy(rule);
}
break;
case OFOPERATION_DELETE:
ovs_assert(!op->error);
- ofproto_rule_destroy__(rule);
+ ofproto_rule_destroy(rule);
op->rule = NULL;
break;
op->ofpacts = NULL;
op->ofpacts_len = 0;
}
- rule->send_flow_removed = op->send_flow_removed;
+ rule->flags = op->flags;
}
break;
op->idle_timeout = rule->idle_timeout;
op->hard_timeout = rule->hard_timeout;
ovs_mutex_unlock(&rule->timeout_mutex);
- op->send_flow_removed = rule->send_flow_removed;
+ op->flags = rule->flags;
group->n_running++;