[ovs-dev] [PATCH 16/18] ofp-util: Flow Dump Protocol for OpenFlow 12

Simon Horman horms at verge.net.au
Fri Oct 26 02:36:04 UTC 2012


Allow only OpenFlow 12 as a flow dump protocol for OpenFlow12.
Allow OpenFlow10 and NXM as flow dump protocols for other OpenFlow versions.
This only changes the behaviour prior to this patch in the case of OpenFlow12
which seemed broken as an attempt would be made to set NXM as the
flow dump format using an OpenFlow 1.0 message even though an OpenFlow 1.2
connection had been negotiated..

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 lib/ofp-util.c        |   22 +++++++++++++++++-----
 lib/ofp-util.h        |    5 ++---
 utilities/ovs-ofctl.c |    8 ++++++--
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 4f10553..1639f9c 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -586,11 +586,23 @@ static const struct proto_abbrev proto_abbrevs[] = {
 };
 #define N_PROTO_ABBREVS ARRAY_SIZE(proto_abbrevs)
 
-enum ofputil_protocol ofputil_flow_dump_protocols[] = {
-    OFPUTIL_P_NXM,
-    OFPUTIL_P_OF10,
-};
-size_t ofputil_n_flow_dump_protocols = ARRAY_SIZE(ofputil_flow_dump_protocols);
+/* Protocols to use for flow dumps, from most to least preferred. */
+const enum ofputil_protocol *
+ofputil_get_flow_dump_protocols(enum ofputil_protocol current, size_t *count)
+{
+    if (current == OFPUTIL_P_OF12) {
+        static const enum ofputil_protocol of12_proto[] = { OFPUTIL_P_OF12 };
+        *count = ARRAY_SIZE(of12_proto);
+        return of12_proto;
+    } else {
+        static const enum ofputil_protocol of10_proto[] = {
+            OFPUTIL_P_NXM,
+            OFPUTIL_P_OF10,
+        };
+        *count = ARRAY_SIZE(of10_proto);
+        return of10_proto;
+    }
+}
 
 /* Returns the ofputil_protocol that is initially in effect on an OpenFlow
  * connection that has negotiated the given 'version'.  'version' should
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index e6bf055..8dd1389 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -83,9 +83,8 @@ enum ofputil_protocol {
 #define OFPUTIL_P_NXM_ANY_OR_OF11_PLUS OFPUTIL_P_NXM_ANY_OR_OF12
 };
 
-/* Protocols to use for flow dumps, from most to least preferred. */
-extern enum ofputil_protocol ofputil_flow_dump_protocols[];
-extern size_t ofputil_n_flow_dump_protocols;
+const enum ofputil_protocol *
+ofputil_get_flow_dump_protocols(enum ofputil_protocol current, size_t *count);
 
 enum ofputil_protocol
 ofputil_protocol_from_ofp_version(enum ofp_version version);
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 710001f..9261051 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -793,9 +793,13 @@ set_protocol_for_flow_dump(struct vconn *vconn,
 {
     char *usable_s;
     int i;
+    size_t n_dump_protocols;
+    const enum ofputil_protocol *dump_protocols;
 
-    for (i = 0; i < ofputil_n_flow_dump_protocols; i++) {
-        enum ofputil_protocol f = ofputil_flow_dump_protocols[i];
+    dump_protocols = ofputil_get_flow_dump_protocols(cur_protocol,
+                                                     &n_dump_protocols);
+    for (i = 0; i < n_dump_protocols; i++) {
+        enum ofputil_protocol f = dump_protocols[i];
         if (f & usable_protocols & allowed_protocols
             && try_set_protocol(vconn, f, &cur_protocol)) {
             return f;
-- 
1.7.10.4




More information about the dev mailing list