[ovs-dev] [PATCH] openflow-1.1+: OFPT_TABLE_MOD: Use enum ofp11_table_config in struct ofputil_table_mod

Simon Horman horms at verge.net.au
Mon Sep 9 01:28:42 UTC 2013


It seems convenient and in keeping with other Open vSwtich code to use enum
ofp11_table_config as the type of the config field in struct
ofputil_table_mod.

Although the presence of OFPTC11_TABLE_MISS_MASK and need to use it as a
mask seems to make things a little untidy. And there only seems to be one
location the enum is currently useful. None the less this ought to help the
compiler to help us to make sure all cases continue to be covered in future.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 lib/ofp-print.c | 7 +++++--
 lib/ofp-util.h  | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index c0553af..0bc44a3 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -965,9 +965,11 @@ ofp_print_port_mod(struct ds *string, const struct ofp_header *oh)
 }
 
 static void
-ofp_print_table_miss_config(struct ds *string, const uint32_t config)
+ofp_print_table_miss_config(struct ds *string,
+                            const enum ofp11_table_config config)
 {
-    uint32_t table_miss_config = config & OFPTC11_TABLE_MISS_MASK;
+    enum ofp11_table_config table_miss_config =
+        config & OFPTC11_TABLE_MISS_MASK;
 
     switch (table_miss_config) {
     case OFPTC11_TABLE_MISS_CONTROLLER:
@@ -979,6 +981,7 @@ ofp_print_table_miss_config(struct ds *string, const uint32_t config)
     case OFPTC11_TABLE_MISS_DROP:
         ds_put_cstr(string, "drop\n");
         break;
+    case OFPTC11_TABLE_MISS_MASK:
     default:
         ds_put_cstr(string, "Unknown\n");
         break;
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 0ca483c..4d7f2d5 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -568,7 +568,7 @@ struct ofpbuf *ofputil_encode_port_mod(const struct ofputil_port_mod *,
 /* Abstract ofp_table_mod. */
 struct ofputil_table_mod {
     uint8_t table_id;         /* ID of the table, 0xff indicates all tables. */
-    uint32_t config;
+    enum ofp11_table_config config;
 };
 
 enum ofperr ofputil_decode_table_mod(const struct ofp_header *,
-- 
1.8.4




More information about the dev mailing list