unsigned ofproto_max_idle = OFPROTO_MAX_IDLE_DEFAULT;
size_t n_handlers, n_revalidators;
+size_t n_dpdk_rxqs;
+char *pmd_cpu_mask;
/* Map from datapath name to struct ofproto, for use by unixctl commands. */
static struct hmap all_ofprotos = HMAP_INITIALIZER(&all_ofprotos);
ovs_mutex_unlock(&ofproto_mutex);
ofproto->ogf.capabilities = OFPGFC_CHAINING | OFPGFC_SELECT_LIVENESS |
OFPGFC_SELECT_WEIGHT;
- ofproto->ogf.max_groups[OFPGT11_ALL] = OFPG_MAX;
- ofproto->ogf.max_groups[OFPGT11_SELECT] = OFPG_MAX;
- ofproto->ogf.max_groups[OFPGT11_INDIRECT] = OFPG_MAX;
- ofproto->ogf.max_groups[OFPGT11_FF] = OFPG_MAX;
- ofproto->ogf.actions[0] =
- (1 << OFPAT11_OUTPUT) |
- (1 << OFPAT11_COPY_TTL_OUT) |
- (1 << OFPAT11_COPY_TTL_IN) |
- (1 << OFPAT11_SET_MPLS_TTL) |
- (1 << OFPAT11_DEC_MPLS_TTL) |
- (1 << OFPAT11_PUSH_VLAN) |
- (1 << OFPAT11_POP_VLAN) |
- (1 << OFPAT11_PUSH_MPLS) |
- (1 << OFPAT11_POP_MPLS) |
- (1 << OFPAT11_SET_QUEUE) |
- (1 << OFPAT11_GROUP) |
- (1 << OFPAT11_SET_NW_TTL) |
- (1 << OFPAT11_DEC_NW_TTL) |
- (1 << OFPAT12_SET_FIELD);
-/* not supported:
- * (1 << OFPAT13_PUSH_PBB) |
- * (1 << OFPAT13_POP_PBB) */
+ for (i = 0; i < 4; i++) {
+ ofproto->ogf.max_groups[i] = OFPG_MAX;
+ ofproto->ogf.ofpacts[i] = (UINT64_C(1) << N_OFPACTS) - 1;
+ }
error = ofproto->ofproto_class->construct(ofproto);
if (error) {
VLOG_ERR("failed to open datapath %s: %s",
datapath_name, ovs_strerror(error));
+ connmgr_destroy(ofproto->connmgr);
ofproto_destroy__(ofproto);
return error;
}
}
}
+/* Multicast snooping configuration. */
+
+/* Configures multicast snooping on 'ofproto' using the settings
+ * defined in 's'. If 's' is NULL, disables multicast snooping.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+int
+ofproto_set_mcast_snooping(struct ofproto *ofproto,
+ const struct ofproto_mcast_snooping_settings *s)
+{
+ return (ofproto->ofproto_class->set_mcast_snooping
+ ? ofproto->ofproto_class->set_mcast_snooping(ofproto, s)
+ : EOPNOTSUPP);
+}
+
+/* Configures multicast snooping flood setting on 'ofp_port' of 'ofproto'.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_set_mcast_snooping(struct ofproto *ofproto, void *aux, bool flood)
+{
+ return (ofproto->ofproto_class->set_mcast_snooping_port
+ ? ofproto->ofproto_class->set_mcast_snooping_port(ofproto, aux,
+ flood)
+ : EOPNOTSUPP);
+}
+
+void
+ofproto_set_n_dpdk_rxqs(int n_rxqs)
+{
+ n_dpdk_rxqs = MAX(n_rxqs, 0);
+}
+
+void
+ofproto_set_cpu_mask(const char *cmask)
+{
+ free(pmd_cpu_mask);
+
+ pmd_cpu_mask = cmask ? xstrdup(cmask) : NULL;
+}
+
void
ofproto_set_threads(int n_handlers_, int n_revalidators_)
{
? ofproto->ofproto_class->get_stp_port_stats(ofport, s)
: EOPNOTSUPP);
}
+
+/* Rapid Spanning Tree Protocol (RSTP) configuration. */
+
+/* Configures RSTP on 'ofproto' using the settings defined in 's'. If
+ * 's' is NULL, disables RSTP.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+int
+ofproto_set_rstp(struct ofproto *ofproto,
+ const struct ofproto_rstp_settings *s)
+{
+ if (!ofproto->ofproto_class->set_rstp) {
+ return EOPNOTSUPP;
+ }
+ ofproto->ofproto_class->set_rstp(ofproto, s);
+ return 0;
+}
+
+/* Retrieves RSTP status of 'ofproto' and stores it in 's'. If the
+ * 'enabled' member of 's' is false, then the other members are not
+ * meaningful.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+int
+ofproto_get_rstp_status(struct ofproto *ofproto,
+ struct ofproto_rstp_status *s)
+{
+ if (!ofproto->ofproto_class->get_rstp_status) {
+ return EOPNOTSUPP;
+ }
+ ofproto->ofproto_class->get_rstp_status(ofproto, s);
+ return 0;
+}
+
+/* Configures RSTP on 'ofp_port' of 'ofproto' using the settings defined
+ * in 's'. The caller is responsible for assigning RSTP port numbers
+ * (using the 'port_num' member in the range of 1 through 255, inclusive)
+ * and ensuring there are no duplicates. If the 's' is NULL, then RSTP
+ * is disabled on the port.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_set_rstp(struct ofproto *ofproto, ofp_port_t ofp_port,
+ const struct ofproto_port_rstp_settings *s)
+{
+ struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
+ if (!ofport) {
+ VLOG_WARN("%s: cannot configure RSTP on nonexistent port %"PRIu16,
+ ofproto->name, ofp_port);
+ return ENODEV;
+ }
+
+ if (!ofproto->ofproto_class->set_rstp_port) {
+ return EOPNOTSUPP;
+ }
+ ofproto->ofproto_class->set_rstp_port(ofport, s);
+ return 0;
+}
+
+/* Retrieves RSTP port status of 'ofp_port' on 'ofproto' and stores it in
+ * 's'. If the 'enabled' member in 's' is false, then the other members
+ * are not meaningful.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_get_rstp_status(struct ofproto *ofproto, ofp_port_t ofp_port,
+ struct ofproto_port_rstp_status *s)
+{
+ struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
+ if (!ofport) {
+ VLOG_WARN_RL(&rl, "%s: cannot get RSTP status on nonexistent "
+ "port %"PRIu16, ofproto->name, ofp_port);
+ return ENODEV;
+ }
+
+ if (!ofproto->ofproto_class->get_rstp_port_status) {
+ return EOPNOTSUPP;
+ }
+ ofproto->ofproto_class->get_rstp_port_status(ofport, s);
+ return 0;
+}
\f
/* Queue DSCP configuration. */
}
table->max_flows = s->max_flows;
- fat_rwlock_wrlock(&table->cls.rwlock);
- classifier_set_prefix_fields(&table->cls,
- s->prefix_fields, s->n_prefix_fields);
- fat_rwlock_unlock(&table->cls.rwlock);
+
+ if (classifier_set_prefix_fields(&table->cls,
+ s->prefix_fields, s->n_prefix_fields)) {
+ /* XXX: Trigger revalidation. */
+ }
ovs_mutex_lock(&ofproto_mutex);
evict_rules_from_table(table, 0);
ovs_mutex_lock(&ofproto_mutex);
OFPROTO_FOR_EACH_TABLE (table, ofproto) {
- struct rule *rule, *next_rule;
- struct cls_cursor cursor;
+ struct rule *rule;
if (table->flags & OFTABLE_HIDDEN) {
continue;
}
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, NULL);
- fat_rwlock_unlock(&table->cls.rwlock);
- CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, cr, &cursor) {
+ CLS_FOR_EACH_SAFE (rule, cr, &table->cls) {
ofproto_rule_delete__(rule, OFPRR_DELETE);
}
}
ovs_rwlock_destroy(&ofproto->groups_rwlock);
hmap_destroy(&ofproto->groups);
- connmgr_destroy(ofproto->connmgr);
-
hmap_remove(&all_ofprotos, &ofproto->hmap_node);
free(ofproto->name);
free(ofproto->type);
}
p->ofproto_class->destruct(p);
+
+ /* We should not postpone this because it involves deleting a listening
+ * socket which we may want to reopen soon. 'connmgr' should not be used
+ * by other threads */
+ connmgr_destroy(p->connmgr);
+
/* Destroying rules is deferred, must have 'ofproto' around for them. */
ovsrcu_postpone(ofproto_destroy__, p);
}
for (i = 0; i < p->n_tables; i++) {
struct oftable *table = &p->tables[i];
struct eviction_group *evg;
- struct cls_cursor cursor;
struct rule *rule;
if (!table->eviction_fields) {
continue;
}
+ if (classifier_count(&table->cls) > 100000) {
+ static struct vlog_rate_limit count_rl =
+ VLOG_RATE_LIMIT_INIT(1, 1);
+ VLOG_WARN_RL(&count_rl, "Table %"PRIuSIZE" has an excessive"
+ " number of rules: %d", i,
+ classifier_count(&table->cls));
+ }
+
ovs_mutex_lock(&ofproto_mutex);
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, NULL);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH (rule, cr, &table->cls) {
if (rule->idle_timeout || rule->hard_timeout) {
if (!rule->eviction_group) {
eviction_group_add_rule(rule);
}
}
}
- fat_rwlock_unlock(&table->cls.rwlock);
HEAP_FOR_EACH (evg, size_node, &table->eviction_groups_by_size) {
heap_rebuild(&evg->rules);
n_rules = 0;
OFPROTO_FOR_EACH_TABLE (table, ofproto) {
- fat_rwlock_rdlock(&table->cls.rwlock);
n_rules += classifier_count(&table->cls);
- fat_rwlock_unlock(&table->cls.rwlock);
}
simap_increase(usage, "rules", n_rules);
/* First do a cheap check whether the rule we're looking for already exists
* with the actions that we want. If it does, then we're done. */
- fat_rwlock_rdlock(&ofproto->tables[0].cls.rwlock);
rule = rule_from_cls_rule(classifier_find_match_exactly(
&ofproto->tables[0].cls, match, priority));
if (rule) {
} else {
must_add = true;
}
- fat_rwlock_unlock(&ofproto->tables[0].cls.rwlock);
/* If there's no such rule or the rule doesn't have the actions we want,
* fall back to a executing a full flow mod. We can't optimize this at
struct rule *rule;
bool done = false;
- fat_rwlock_rdlock(&table->cls.rwlock);
rule = rule_from_cls_rule(classifier_find_match_exactly(&table->cls,
&fm->match,
fm->priority));
}
ovs_mutex_unlock(&rule->mutex);
}
- fat_rwlock_unlock(&table->cls.rwlock);
if (done) {
return 0;
/* First do a cheap check whether the rule we're looking for has already
* been deleted. If so, then we're done. */
- fat_rwlock_rdlock(&cls->rwlock);
rule = rule_from_cls_rule(classifier_find_match_exactly(cls, target,
priority));
- fat_rwlock_unlock(&cls->rwlock);
if (!rule) {
return;
}
if (port->ofproto->ofproto_class->set_stp_port) {
port->ofproto->ofproto_class->set_stp_port(port, NULL);
}
+ if (port->ofproto->ofproto_class->set_rstp_port) {
+ port->ofproto->ofproto_class->set_rstp_port(port, NULL);
+ }
if (port->ofproto->ofproto_class->set_cfm) {
port->ofproto->ofproto_class->set_cfm(port, NULL);
}
}
}
+bool
+ofproto_rule_try_ref(struct rule *rule)
+{
+ if (rule) {
+ return ovs_refcount_try_ref_rcu(&rule->ref_count);
+ }
+ return false;
+}
+
/* Decrements 'rule''s ref_count and schedules 'rule' to be destroyed if the
* ref_count reaches 0.
*
void
ofproto_rule_unref(struct rule *rule)
{
- if (rule && ovs_refcount_unref(&rule->ref_count) == 1) {
+ if (rule && ovs_refcount_unref_relaxed(&rule->ref_count) == 1) {
ovsrcu_postpone(rule_destroy_cb, rule);
}
}
/* Returns true if 'rule' has an OpenFlow OFPAT_OUTPUT or OFPAT_ENQUEUE action
* that outputs to 'port' (output to OFPP_FLOOD and OFPP_ALL doesn't count). */
-static bool
+bool
ofproto_rule_has_out_port(const struct rule *rule, ofp_port_t port)
OVS_REQUIRES(ofproto_mutex)
{
return 0;
}
+static void
+query_tables(struct ofproto *ofproto,
+ struct ofputil_table_features **featuresp,
+ struct ofputil_table_stats **statsp)
+{
+ struct mf_bitmap rw_fields = oxm_writable_fields();
+ struct mf_bitmap match = oxm_matchable_fields();
+ struct mf_bitmap mask = oxm_maskable_fields();
+
+ struct ofputil_table_features *features;
+ struct ofputil_table_stats *stats;
+ int i;
+
+ features = *featuresp = xcalloc(ofproto->n_tables, sizeof *features);
+ for (i = 0; i < ofproto->n_tables; i++) {
+ struct ofputil_table_features *f = &features[i];
+
+ f->table_id = i;
+ sprintf(f->name, "table%d", i);
+ f->metadata_match = OVS_BE64_MAX;
+ f->metadata_write = OVS_BE64_MAX;
+ atomic_read_relaxed(&ofproto->tables[i].miss_config, &f->miss_config);
+ f->max_entries = 1000000;
+
+ bitmap_set_multiple(f->nonmiss.next, i + 1,
+ ofproto->n_tables - (i + 1), true);
+ f->nonmiss.instructions = (1u << N_OVS_INSTRUCTIONS) - 1;
+ if (i == ofproto->n_tables - 1) {
+ f->nonmiss.instructions &= ~(1u << OVSINST_OFPIT11_GOTO_TABLE);
+ }
+ f->nonmiss.write.ofpacts = (UINT64_C(1) << N_OFPACTS) - 1;
+ f->nonmiss.write.set_fields = rw_fields;
+ f->nonmiss.apply = f->nonmiss.write;
+ f->miss = f->nonmiss;
+
+ f->match = match;
+ f->mask = mask;
+ f->wildcard = match;
+ }
+
+ if (statsp) {
+ stats = *statsp = xcalloc(ofproto->n_tables, sizeof *stats);
+ for (i = 0; i < ofproto->n_tables; i++) {
+ struct ofputil_table_stats *s = &stats[i];
+ struct classifier *cls = &ofproto->tables[i].cls;
+
+ s->table_id = i;
+ s->active_count = classifier_count(cls);
+ }
+ } else {
+ stats = NULL;
+ }
+
+ ofproto->ofproto_class->query_tables(ofproto, features, stats);
+
+ for (i = 0; i < ofproto->n_tables; i++) {
+ const struct oftable *table = &ofproto->tables[i];
+ struct ofputil_table_features *f = &features[i];
+
+ if (table->name) {
+ ovs_strzcpy(f->name, table->name, sizeof f->name);
+ }
+
+ if (table->max_flows < f->max_entries) {
+ f->max_entries = table->max_flows;
+ }
+ }
+}
+
+static void
+query_switch_features(struct ofproto *ofproto,
+ bool *arp_match_ip, uint64_t *ofpacts)
+{
+ struct ofputil_table_features *features, *f;
+
+ *arp_match_ip = false;
+ *ofpacts = 0;
+
+ query_tables(ofproto, &features, NULL);
+ for (f = features; f < &features[ofproto->n_tables]; f++) {
+ *ofpacts |= f->nonmiss.apply.ofpacts | f->miss.apply.ofpacts;
+ if (bitmap_is_set(f->match.bm, MFF_ARP_SPA) ||
+ bitmap_is_set(f->match.bm, MFF_ARP_TPA)) {
+ *arp_match_ip = true;
+ }
+ }
+ free(features);
+
+ /* Sanity check. */
+ ovs_assert(*ofpacts & (UINT64_C(1) << OFPACT_OUTPUT));
+}
+
static enum ofperr
handle_features_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
bool arp_match_ip;
struct ofpbuf *b;
- ofproto->ofproto_class->get_features(ofproto, &arp_match_ip,
- &features.actions);
- ovs_assert(features.actions & OFPUTIL_A_OUTPUT); /* sanity check */
+ query_switch_features(ofproto, &arp_match_ip, &features.ofpacts);
features.datapath_id = ofproto->datapath_id;
features.n_buffers = pktbuf_capacity();
handle_table_stats_request(struct ofconn *ofconn,
const struct ofp_header *request)
{
- struct ofproto *p = ofconn_get_ofproto(ofconn);
- struct ofp12_table_stats *ots;
- struct ofpbuf *msg;
- int n_tables;
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
+ struct ofputil_table_features *features;
+ struct ofputil_table_stats *stats;
+ struct ofpbuf *reply;
size_t i;
- /* Set up default values.
- *
- * ofp12_table_stats is used as a generic structure as
- * it is able to hold all the fields for ofp10_table_stats
- * and ofp11_table_stats (and of course itself).
- */
- ots = xcalloc(p->n_tables, sizeof *ots);
- for (i = 0; i < p->n_tables; i++) {
- ots[i].table_id = i;
- sprintf(ots[i].name, "table%"PRIuSIZE, i);
- ots[i].match = htonll(OFPXMT13_MASK);
- ots[i].wildcards = htonll(OFPXMT13_MASK);
- ots[i].write_actions = htonl(OFPAT11_OUTPUT);
- ots[i].apply_actions = htonl(OFPAT11_OUTPUT);
- ots[i].write_setfields = htonll(OFPXMT13_MASK);
- ots[i].apply_setfields = htonll(OFPXMT13_MASK);
- ots[i].metadata_match = OVS_BE64_MAX;
- ots[i].metadata_write = OVS_BE64_MAX;
- ots[i].instructions = htonl(OFPIT11_ALL);
- ots[i].config = htonl(OFPTC11_TABLE_MISS_MASK);
- ots[i].max_entries = htonl(1000000); /* An arbitrary big number. */
- fat_rwlock_rdlock(&p->tables[i].cls.rwlock);
- ots[i].active_count = htonl(classifier_count(&p->tables[i].cls));
- fat_rwlock_unlock(&p->tables[i].cls.rwlock);
- }
-
- p->ofproto_class->get_tables(p, ots);
-
- /* Post-process the tables, dropping hidden tables. */
- n_tables = p->n_tables;
- for (i = 0; i < p->n_tables; i++) {
- const struct oftable *table = &p->tables[i];
+ query_tables(ofproto, &features, &stats);
- if (table->flags & OFTABLE_HIDDEN) {
- n_tables = i;
- break;
+ reply = ofputil_encode_table_stats_reply(request);
+ for (i = 0; i < ofproto->n_tables; i++) {
+ if (!(ofproto->tables[i].flags & OFTABLE_HIDDEN)) {
+ ofputil_append_table_stats_reply(reply, &stats[i], &features[i]);
}
+ }
+ ofconn_send_reply(ofconn, reply);
- if (table->name) {
- ovs_strzcpy(ots[i].name, table->name, sizeof ots[i].name);
- }
+ free(features);
+ free(stats);
- if (table->max_flows < ntohl(ots[i].max_entries)) {
- ots[i].max_entries = htonl(table->max_flows);
- }
+ return 0;
+}
+
+static enum ofperr
+handle_table_features_request(struct ofconn *ofconn,
+ const struct ofp_header *request)
+{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
+ struct ofputil_table_features *features;
+ struct list replies;
+ struct ofpbuf msg;
+ size_t i;
+
+ ofpbuf_use_const(&msg, request, ntohs(request->length));
+ ofpraw_pull_assert(&msg);
+ if (ofpbuf_size(&msg) || ofpmp_more(request)) {
+ return OFPERR_OFPTFFC_EPERM;
}
- msg = ofputil_encode_table_stats_reply(ots, n_tables, request);
- ofconn_send_reply(ofconn, msg);
+ query_tables(ofproto, &features, NULL);
- free(ots);
+ ofpmp_init(&replies, request);
+ for (i = 0; i < ofproto->n_tables; i++) {
+ if (!(ofproto->tables[i].flags & OFTABLE_HIDDEN)) {
+ ofputil_append_table_features_reply(&features[i], &replies);
+ }
+ }
+ ofconn_send_replies(ofconn, &replies);
+
+ free(features);
return 0;
}
if (rules->rules != rules->stub) {
free(rules->rules);
}
+
+ /* Make repeated destruction harmless. */
+ rule_collection_init(rules);
}
/* Checks whether 'rule' matches 'c' and, if so, adds it to 'rules'. This
}
} else {
FOR_EACH_MATCHING_TABLE (table, criteria->table_id, ofproto) {
- struct cls_cursor cursor;
struct rule *rule;
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, &criteria->cr);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH_TARGET (rule, cr, &table->cls, &criteria->cr) {
collect_rule(rule, criteria, rules, &n_readonly);
}
- fat_rwlock_unlock(&table->cls.rwlock);
}
}
FOR_EACH_MATCHING_TABLE (table, criteria->table_id, ofproto) {
struct rule *rule;
- fat_rwlock_rdlock(&table->cls.rwlock);
rule = rule_from_cls_rule(classifier_find_rule_exactly(
&table->cls, &criteria->cr));
- fat_rwlock_unlock(&table->cls.rwlock);
if (rule) {
collect_rule(rule, criteria, rules, &n_readonly);
}
struct oftable *table;
OFPROTO_FOR_EACH_TABLE (table, p) {
- struct cls_cursor cursor;
struct rule *rule;
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, NULL);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH (rule, cr, &table->cls) {
flow_stats_ds(rule, results);
}
- fat_rwlock_unlock(&table->cls.rwlock);
}
}
cls_rule_init(&cr, &fm->match, fm->priority);
/* Transform "add" into "modify" if there's an existing identical flow. */
- fat_rwlock_rdlock(&table->cls.rwlock);
rule = rule_from_cls_rule(classifier_find_rule_exactly(&table->cls, &cr));
- fat_rwlock_unlock(&table->cls.rwlock);
if (rule) {
struct rule_collection rules;
/* Check for overlap, if requested. */
if (fm->flags & OFPUTIL_FF_CHECK_OVERLAP) {
- bool overlaps;
-
- fat_rwlock_rdlock(&table->cls.rwlock);
- overlaps = classifier_rule_overlaps(&table->cls, &cr);
- fat_rwlock_unlock(&table->cls.rwlock);
-
- if (overlaps) {
+ if (classifier_rule_overlaps(&table->cls, &cr)) {
cls_rule_destroy(&cr);
return OFPERR_OFPFMFC_OVERLAP;
}
meter_insert_rule(rule);
}
- fat_rwlock_wrlock(&table->cls.rwlock);
classifier_insert(&table->cls, CONST_CAST(struct cls_rule *, &rule->cr));
- fat_rwlock_unlock(&table->cls.rwlock);
error = ofproto->ofproto_class->rule_insert(rule);
if (error) {
}
ofmonitor_report(ofproto->connmgr, rule, NXFME_ADDED, 0,
- req ? req->ofconn : NULL, req ? req->xid : 0);
+ req ? req->ofconn : NULL, req ? req->xid : 0, NULL);
return req ? send_buffered_packet(req->ofconn, fm->buffer_id, rule) : 0;
}
if (change_actions) {
ovsrcu_set(&rule->actions, rule_actions_create(fm->ofpacts,
fm->ofpacts_len));
- rule_actions_destroy(actions);
}
if (change_actions || reset_counters) {
if (event != NXFME_MODIFIED || change_actions || change_cookie) {
ofmonitor_report(ofproto->connmgr, rule, event, 0,
- req ? req->ofconn : NULL, req ? req->xid : 0);
+ req ? req->ofconn : NULL, req ? req->xid : 0,
+ change_actions ? actions : NULL);
}
if (change_actions) {
learned_cookies_inc(ofproto, rule_get_actions(rule));
learned_cookies_dec(ofproto, actions, &dead_cookies);
+ rule_actions_destroy(actions);
}
}
learned_cookies_flush(ofproto, &dead_cookies);
ofproto_rule_send_removed(rule, reason);
ofmonitor_report(ofproto->connmgr, rule, NXFME_DELETED, reason,
- req ? req->ofconn : NULL, req ? req->xid : 0);
+ req ? req->ofconn : NULL, req ? req->xid : 0,
+ NULL);
oftable_remove_rule(rule);
ofproto->ofproto_class->rule_delete(rule);
cls_rule_init_from_minimatch(&target, &m->match, 0);
FOR_EACH_MATCHING_TABLE (table, m->table_id, ofproto) {
- struct cls_cursor cursor;
struct rule *rule;
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, &target);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH_TARGET (rule, cr, &table->cls, &target) {
ofproto_collect_ofmonitor_refresh_rule(m, rule, seqno, rules);
}
- fat_rwlock_unlock(&table->cls.rwlock);
}
cls_rule_destroy(&target);
}
ofproto_collect_ofmonitor_refresh_rules(m, seqno, rules);
}
+static enum ofperr
+flow_monitor_delete(struct ofconn *ofconn, uint32_t id)
+ OVS_REQUIRES(ofproto_mutex)
+{
+ struct ofmonitor *m;
+ enum ofperr error;
+
+ m = ofmonitor_lookup(ofconn, id);
+ if (m) {
+ ofmonitor_destroy(m);
+ error = 0;
+ } else {
+ error = OFPERR_OFPMOFC_UNKNOWN_MONITOR;
+ }
+
+ return error;
+}
+
static enum ofperr
handle_flow_monitor_request(struct ofconn *ofconn, const struct ofp_header *oh)
OVS_EXCLUDED(ofproto_mutex)
struct ofpbuf b;
size_t i;
- error = 0;
ofpbuf_use_const(&b, oh, ntohs(oh->length));
monitors = NULL;
n_monitors = allocated_monitors = 0;
handle_flow_monitor_cancel(struct ofconn *ofconn, const struct ofp_header *oh)
OVS_EXCLUDED(ofproto_mutex)
{
- struct ofmonitor *m;
enum ofperr error;
uint32_t id;
id = ofputil_decode_flow_monitor_cancel(oh);
ovs_mutex_lock(&ofproto_mutex);
- m = ofmonitor_lookup(ofconn, id);
- if (m) {
- ofmonitor_destroy(m);
- error = 0;
- } else {
- error = OFPERR_OFPMOFC_UNKNOWN_MONITOR;
- }
+ error = flow_monitor_delete(ofconn, id);
ovs_mutex_unlock(&ofproto_mutex);
return error;
}
}
-enum ofproto_table_config
-ofproto_table_get_config(const struct ofproto *ofproto, uint8_t table_id)
+enum ofputil_table_miss
+ofproto_table_get_miss_config(const struct ofproto *ofproto, uint8_t table_id)
{
- unsigned int value;
- atomic_read(&ofproto->tables[table_id].config, &value);
- return (enum ofproto_table_config)value;
+ enum ofputil_table_miss value;
+
+ atomic_read_relaxed(&ofproto->tables[table_id].miss_config, &value);
+ return value;
}
static enum ofperr
table_mod(struct ofproto *ofproto, const struct ofputil_table_mod *tm)
{
- /* Only accept currently supported configurations */
- if (tm->config & ~OFPTC11_TABLE_MISS_MASK) {
- return OFPERR_OFPTMFC_BAD_CONFIG;
- }
-
- if (tm->table_id == OFPTT_ALL) {
- int i;
- for (i = 0; i < ofproto->n_tables; i++) {
- atomic_store(&ofproto->tables[i].config,
- (unsigned int)tm->config);
- }
- } else if (!check_table_id(ofproto, tm->table_id)) {
+ if (!check_table_id(ofproto, tm->table_id)) {
return OFPERR_OFPTMFC_BAD_TABLE;
- } else {
- atomic_store(&ofproto->tables[tm->table_id].config,
- (unsigned int)tm->config);
+ } else if (tm->miss_config != OFPUTIL_TABLE_MISS_DEFAULT) {
+ if (tm->table_id == OFPTT_ALL) {
+ int i;
+ for (i = 0; i < ofproto->n_tables; i++) {
+ atomic_store_relaxed(&ofproto->tables[i].miss_config,
+ tm->miss_config);
+ }
+ } else {
+ atomic_store_relaxed(&ofproto->tables[tm->table_id].miss_config,
+ tm->miss_config);
+ }
}
-
return 0;
}
case OFPTYPE_TABLE_STATS_REQUEST:
return handle_table_stats_request(ofconn, oh);
+ case OFPTYPE_TABLE_FEATURES_STATS_REQUEST:
+ return handle_table_features_request(ofconn, oh);
+
case OFPTYPE_PORT_STATS_REQUEST:
return handle_port_stats_request(ofconn, oh);
case OFPTYPE_METER_STATS_REPLY:
case OFPTYPE_METER_CONFIG_STATS_REPLY:
case OFPTYPE_METER_FEATURES_STATS_REPLY:
- case OFPTYPE_TABLE_FEATURES_STATS_REQUEST:
case OFPTYPE_TABLE_FEATURES_STATS_REPLY:
case OFPTYPE_ROLE_STATUS:
default:
memset(table, 0, sizeof *table);
classifier_init(&table->cls, flow_segment_u32s);
table->max_flows = UINT_MAX;
- atomic_init(&table->config, (unsigned int)OFPROTO_TABLE_MISS_DEFAULT);
+ atomic_init(&table->miss_config, OFPUTIL_TABLE_MISS_DEFAULT);
- fat_rwlock_wrlock(&table->cls.rwlock);
classifier_set_prefix_fields(&table->cls, default_prefix_fields,
ARRAY_SIZE(default_prefix_fields));
- fat_rwlock_unlock(&table->cls.rwlock);
atomic_init(&table->n_matched, 0);
atomic_init(&table->n_missed, 0);
static void
oftable_destroy(struct oftable *table)
{
- fat_rwlock_rdlock(&table->cls.rwlock);
ovs_assert(classifier_is_empty(&table->cls));
- fat_rwlock_unlock(&table->cls.rwlock);
oftable_disable_eviction(table);
classifier_destroy(&table->cls);
free(table->name);
const struct mf_subfield *fields, size_t n_fields)
OVS_REQUIRES(ofproto_mutex)
{
- struct cls_cursor cursor;
struct rule *rule;
if (table->eviction_fields
hmap_init(&table->eviction_groups_by_id);
heap_init(&table->eviction_groups_by_size);
- fat_rwlock_rdlock(&table->cls.rwlock);
- cls_cursor_init(&cursor, &table->cls, NULL);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH (rule, cr, &table->cls) {
eviction_group_add_rule(rule);
}
- fat_rwlock_unlock(&table->cls.rwlock);
}
/* Removes 'rule' from the oftable that contains it. */
{
struct classifier *cls = &ofproto->tables[rule->table_id].cls;
- fat_rwlock_wrlock(&cls->rwlock);
classifier_remove(cls, CONST_CAST(struct cls_rule *, &rule->cr));
- fat_rwlock_unlock(&cls->rwlock);
cookies_remove(ofproto, rule);
ofproto->vlans_changed = false;
OFPROTO_FOR_EACH_TABLE (oftable, ofproto) {
- struct cls_cursor cursor;
struct rule *rule;
- fat_rwlock_rdlock(&oftable->cls.rwlock);
- cls_cursor_init(&cursor, &oftable->cls, &target);
- CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+ CLS_FOR_EACH_TARGET (rule, cr, &oftable->cls, &target) {
if (minimask_get_vid_mask(&rule->cr.match.mask) == VLAN_VID_MASK) {
uint16_t vid = miniflow_get_vid(&rule->cr.match.flow);
bitmap_set1(ofproto->vlan_bitmap, vid);
}
}
- fat_rwlock_unlock(&oftable->cls.rwlock);
}
cls_rule_destroy(&target);