[ovs-dev] [PATCH 1/4] ofproto: Add enum ofp_table
Simon Horman
horms at verge.net.au
Tue Nov 12 07:45:50 UTC 2013
Add enum ofp_table and use it for Flow Mod.
Cc: Andy Zhou <azhou at nicira.com>
Signed-off-by: Simon Horman <horms at verge.net.au>
---
include/openflow/openflow-common.h | 10 ++++++++++
lib/ofp-parse.c | 2 +-
lib/ofp-util.c | 8 ++++----
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h
index a38f1e3..234bf96 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -465,4 +465,14 @@ struct ofp_vendor_header {
};
OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
+/* Table numbering. Tables can use any number up to OFPT_MAX. */
+enum ofp_table {
+ /* Last usable table number. */
+ OFPTT_MAX = 0xfe,
+
+ /* Fake tables. */
+ OFPTT_ALL = 0xff /* Wildcard table used for table config,
+ flow stats and flow deletes. */
+};
+
#endif /* openflow/openflow-common.h */
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 0fbe9f0..f2debb3 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -1845,7 +1845,7 @@ parse_ofp_table_mod(struct ofputil_table_mod *tm, const char *table_id,
*usable_protocols = OFPUTIL_P_OF11_UP;
if (!strcasecmp(table_id, "all")) {
- tm->table_id = 255;
+ tm->table_id = OFPTT_ALL;
} else {
char *error = str_to_u8(table_id, "table_id", &tm->table_id);
if (error) {
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 77804a6..ede37b0 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1542,10 +1542,10 @@ ofputil_decode_flow_mod(struct ofputil_flow_mod *fm,
/* Get table ID.
*
- * OF1.1 entirely forbids table_id == 255.
- * OF1.2+ allows table_id == 255 only for deletes. */
+ * OF1.1 entirely forbids table_id == OFPTT_ALL.
+ * OF1.2+ allows table_id == OFPTT_ALL only for deletes. */
fm->table_id = ofm->table_id;
- if (fm->table_id == 255
+ if (fm->table_id == OFPTT_ALL
&& (oh->version == OFP11_VERSION
|| (ofm->command != OFPFC_DELETE &&
ofm->command != OFPFC_DELETE_STRICT))) {
@@ -2093,7 +2093,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
ofm->cookie = fm->cookie;
}
ofm->cookie_mask = fm->cookie_mask;
- if (fm->table_id != 255
+ if (fm->table_id != OFPTT_ALL
|| (protocol != OFPUTIL_P_OF11_STD
&& (fm->command == OFPFC_DELETE ||
fm->command == OFPFC_DELETE_STRICT))) {
--
1.8.4
More information about the dev
mailing list