From: Simon Horman Date: Mon, 23 Dec 2013 12:54:59 +0000 (+0900) Subject: ofproto: Make check_table_id generic X-Git-Tag: sliver-openvswitch-2.1.90-1~10^2~77 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=554764d1aac75030c319fc8e2fa87811149421fa;p=sliver-openvswitch.git ofproto: Make check_table_id generic Update check_table_id() so that rather than returning a flow_mod specific error it simply returns true of false. And update callers accordingly. This is in preparation for using check_table_id() in conjunction with table_mod. Also update check_table_id to use OFPTT_ALL. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 75461e2dd..676a6cbe2 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3227,14 +3227,11 @@ calc_duration(long long int start, long long int now, } /* Checks whether 'table_id' is 0xff or a valid table ID in 'ofproto'. Returns - * 0 if 'table_id' is OK, otherwise an OpenFlow error code. */ -static enum ofperr + * true if 'table_id' is OK, false otherwise. */ +static bool check_table_id(const struct ofproto *ofproto, uint8_t table_id) { - return (table_id == 0xff || table_id < ofproto->n_tables - ? 0 - : OFPERR_OFPBRC_BAD_TABLE_ID); - + return table_id == OFPTT_ALL || table_id < ofproto->n_tables; } static struct oftable * @@ -3418,12 +3415,12 @@ collect_rules_loose(struct ofproto *ofproto, OVS_REQUIRES(ofproto_mutex) { struct oftable *table; - enum ofperr error; + enum ofperr error = 0; rule_collection_init(rules); - error = check_table_id(ofproto, criteria->table_id); - if (error) { + if (!check_table_id(ofproto, criteria->table_id)) { + error = OFPERR_OFPBRC_BAD_TABLE_ID; goto exit; } @@ -3479,12 +3476,12 @@ collect_rules_strict(struct ofproto *ofproto, OVS_REQUIRES(ofproto_mutex) { struct oftable *table; - int error; + int error = 0; rule_collection_init(rules); - error = check_table_id(ofproto, criteria->table_id); - if (error) { + if (!check_table_id(ofproto, criteria->table_id)) { + error = OFPERR_OFPBRC_BAD_TABLE_ID; goto exit; } @@ -3937,10 +3934,10 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, struct cls_rule cr; struct rule *rule; uint8_t table_id; - int error; + int error = 0; - error = check_table_id(ofproto, fm->table_id); - if (error) { + if (!check_table_id(ofproto, fm->table_id)) { + error = OFPERR_OFPBRC_BAD_TABLE_ID; return error; }