diff options
author | Jarno Rajahalme <jarno.rajahalme@nsn.com> | 2013-06-14 17:09:33 +0300 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-06-14 09:50:42 -0700 |
commit | 09d447273ed51d4d4372efa411f23aafccba1e69 (patch) | |
tree | ddb2707135f39dc5dfb171cd784e17b3d67df13c /ofproto | |
parent | bb85f9ae20306e6d0a067026766460eacb4c8440 (diff) |
ofproto: Fix use of uninitialized local variable.
Also make the table id arithmetic less confusing.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ofproto')
-rw-r--r-- | ofproto/ofproto.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index c0d94f72..ca84d085 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3091,8 +3091,8 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, struct oftable *table; struct ofopgroup *group; struct rule *victim; - struct cls_rule cr; struct rule *rule; + uint8_t table_id; int error; error = check_table_id(ofproto, fm->table_id); @@ -3102,7 +3102,6 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, /* Pick table. */ if (fm->table_id == 0xff) { - uint8_t table_id; if (ofproto->ofproto_class->rule_choose_table) { error = ofproto->ofproto_class->rule_choose_table(ofproto, &fm->match, @@ -3111,16 +3110,17 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, return error; } ovs_assert(table_id < ofproto->n_tables); - table = &ofproto->tables[table_id]; } else { - table = &ofproto->tables[0]; + table_id = 0; } } else if (fm->table_id < ofproto->n_tables) { - table = &ofproto->tables[fm->table_id]; + table_id = fm->table_id; } else { return OFPERR_OFPBRC_BAD_TABLE_ID; } + table = &ofproto->tables[table_id]; + if (table->flags & OFTABLE_READONLY) { return OFPERR_OFPBRC_EPERM; } @@ -3135,7 +3135,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, cls_rule_init(&rule->cr, &fm->match, fm->priority); /* Serialize against pending deletion. */ - if (is_flow_deletion_pending(ofproto, &cr, table - ofproto->tables)) { + if (is_flow_deletion_pending(ofproto, &rule->cr, table_id)) { cls_rule_destroy(&rule->cr); ofproto->ofproto_class->rule_dealloc(rule); return OFPROTO_POSTPONE; |