{
const struct ofproto_class *class = ofproto_class_find__(type);
return class ? class->enumerate_names(type, names) : EAFNOSUPPORT;
- }
+}
int
ofproto_create(const char *datapath_name, const char *datapath_type,
}
static void
-ofproto_rule_delete__(struct ofproto *ofproto, struct rule *rule)
+ofproto_rule_delete__(struct ofproto *ofproto, struct rule *rule,
+ uint8_t reason)
OVS_REQUIRES(ofproto_mutex)
{
struct ofopgroup *group;
ovs_assert(!rule->pending);
group = ofopgroup_create_unattached(ofproto);
- delete_flow__(rule, group, OFPRR_DELETE);
+ delete_flow__(rule, group, reason);
ofopgroup_submit(group);
}
ovs_rwlock_unlock(&table->cls.rwlock);
CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, cr, &cursor) {
if (!rule->pending) {
- ofproto_rule_delete__(ofproto, rule);
+ ofproto_rule_delete__(ofproto, rule, OFPRR_DELETE);
}
}
}
static enum ofperr
ofproto_check_ofpacts(struct ofproto *ofproto,
const struct ofpact ofpacts[], size_t ofpacts_len,
- struct flow *flow, uint8_t table_id)
+ struct flow *flow, uint8_t table_id,
+ const struct ofp_header *oh)
{
enum ofperr error;
uint32_t mid;
error = ofpacts_check(ofpacts, ofpacts_len, flow,
- u16_to_ofp(ofproto->max_ports), table_id);
+ u16_to_ofp(ofproto->max_ports), table_id,
+ oh && oh->version > OFP10_VERSION);
if (error) {
return error;
}
/* Verify actions against packet, then send packet if successful. */
in_port_.ofp_port = po.in_port;
flow_extract(payload, 0, 0, NULL, &in_port_, &flow);
- error = ofproto_check_ofpacts(p, po.ofpacts, po.ofpacts_len, &flow, 0);
+ error = ofproto_check_ofpacts(p, po.ofpacts, po.ofpacts_len, &flow, 0, oh);
if (!error) {
error = p->ofproto_class->packet_out(p, payload, &flow,
po.ofpacts, po.ofpacts_len);
/* Verify actions. */
error = ofproto_check_ofpacts(ofproto, fm->ofpacts, fm->ofpacts_len,
- &fm->match.flow, table_id);
+ &fm->match.flow, table_id, request);
if (error) {
cls_rule_destroy(&cr);
return error;
enum ofperr error;
size_t i;
+ /* Verify actions before we start to modify any rules, to avoid partial
+ * flow table modifications. */
+ for (i = 0; i < rules->n; i++) {
+ struct rule *rule = rules->rules[i];
+
+ error = ofproto_check_ofpacts(ofproto, fm->ofpacts, fm->ofpacts_len,
+ &fm->match.flow, rule->table_id,
+ request);
+ if (error) {
+ return error;
+ }
+ }
+
type = fm->command == OFPFC_ADD ? OFOPERATION_REPLACE : OFOPERATION_MODIFY;
group = ofopgroup_create(ofproto, ofconn, request, fm->buffer_id);
error = OFPERR_OFPBRC_EPERM;
continue;
}
- /* Verify actions. */
- error = ofpacts_check(fm->ofpacts, fm->ofpacts_len, &fm->match.flow,
- u16_to_ofp(ofproto->max_ports), rule->table_id);
- if (error) {
- return error;
- }
-
actions_changed = !ofpacts_equal(fm->ofpacts, fm->ofpacts_len,
rule->actions->ofpacts,
rule->actions->ofpacts_len);
ovs_assert(reason == OFPRR_HARD_TIMEOUT || reason == OFPRR_IDLE_TIMEOUT
|| reason == OFPRR_DELETE || reason == OFPRR_GROUP_DELETE);
- ofproto_rule_send_removed(rule, reason);
- ofproto_rule_delete__(ofproto, rule);
+ ofproto_rule_delete__(ofproto, rule, reason);
}
/* Reduces '*timeout' to no more than 'max'. A value of zero in either case
if (error) {
return error;
}
+ if (oh->version >= OFP13_VERSION && ofpmsg_is_stat_request(oh)
+ && ofpmp_more(oh)) {
+ /* We have no buffer implementation for multipart requests.
+ * Report overflow for requests which consists of multiple
+ * messages. */
+ return OFPERR_OFPBRC_MULTIPART_BUFFER_OVERFLOW;
+ }
switch (type) {
/* OpenFlow requests. */
/* FIXME: Change the following once they are implemented: */
case OFPTYPE_QUEUE_GET_CONFIG_REQUEST:
case OFPTYPE_TABLE_FEATURES_STATS_REQUEST:
- return OFPERR_OFPBRC_BAD_TYPE;
+ /* fallthrough */
case OFPTYPE_HELLO:
case OFPTYPE_ERROR:
case OFPTYPE_METER_FEATURES_STATS_REPLY:
case OFPTYPE_TABLE_FEATURES_STATS_REPLY:
default:
- return OFPERR_OFPBRC_BAD_TYPE;
+ if (ofpmsg_is_stat_request(oh)) {
+ return OFPERR_OFPBRC_BAD_STAT;
+ } else {
+ return OFPERR_OFPBRC_BAD_TYPE;
+ }
}
}