summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-09-12 16:40:03 -0700
committerBen Pfaff <blp@nicira.com>2011-09-13 11:46:10 -0700
commit9cdaaebe218dbd9d2126818725b0111a70a3df54 (patch)
treeb1a046fe4623fb891357240d8c91a8f8d91c3cd2 /ofproto
parentecf1e7ac2bc61b1d614395354554e672535135f8 (diff)
downloadopenvswitch-9cdaaebe218dbd9d2126818725b0111a70a3df54.tar.gz
ofproto-dpif: Introduce an enum for the number of tables.
It seems reasonable that someone might want to reduce this number, so make it an enum to simplify that. If someone does reduce the number then rule_dpif_lookup() needs to validate the table_id, so add code to do that too.
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/ofproto-dpif.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index ac196eeb6..4bf1ea067 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -65,6 +65,10 @@ COVERAGE_DEFINE(facet_unexpected);
* flow translation. */
#define MAX_RESUBMIT_RECURSION 16
+/* Number of implemented OpenFlow tables. */
+enum { N_TABLES = 255 };
+BUILD_ASSERT_DECL(N_TABLES >= 1 && N_TABLES <= 255);
+
struct ofport_dpif;
struct ofproto_dpif;
@@ -473,7 +477,7 @@ construct(struct ofproto *ofproto_, int *n_tablesp)
ofproto->has_bundle_action = false;
- *n_tablesp = 255;
+ *n_tablesp = N_TABLES;
return 0;
}
@@ -2630,6 +2634,10 @@ static struct rule_dpif *
rule_dpif_lookup(struct ofproto_dpif *ofproto, const struct flow *flow,
uint8_t table_id)
{
+ if (table_id >= N_TABLES) {
+ return NULL;
+ }
+
return rule_dpif_cast(rule_from_cls_rule(
classifier_lookup(&ofproto->up.tables[table_id],
flow)));