Versions may be configured using the protocols column of
the bridge table. The protocols column is a set which accepts zero
or more of the values: 'OpenFlow10' and 'OpenFlow12'.

If the protocols column is empty, then OpenFlow10 is used.
This default is consistent with the behaviour of ovs-vswtichd
prior to this patch.

Signed-off-by: Simon Horman <ho...@verge.net.au>

---

v6
* As suggested by Ben Pfaff
  - Do not treat an unknown version string as a fatal_error.
    Rather, log the string using VLOG_WARN and ignore it.
    The implication is that the schema permits a version that
    the C code doesn't know about.

v5
* As suggested by Ben Pfaff
  - Use a protocols rather than other-config column

v4
* Rebase

wip
---
 lib/ofp-util.c             |   26 +++++++++++++++++++++++---
 lib/ofp-util.h             |    1 +
 tests/ovs-vsctl.at         |    2 ++
 vswitchd/bridge.c          |   15 ++++++++++++++-
 vswitchd/vswitch.ovsschema |    8 ++++++--
 vswitchd/vswitch.xml       |    7 +++++++
 6 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index b0b44d9..399183a 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -861,7 +861,7 @@ ofputil_protocols_from_string(const char *s)
     return protocols;
 }
 
-static enum ofp_version
+static int
 ofputil_version_from_string(const char *s)
 {
     if (!strcasecmp(s, "OpenFlow10")) {
@@ -873,7 +873,7 @@ ofputil_version_from_string(const char *s)
     if (!strcasecmp(s, "OpenFlow12")) {
         return OFP12_VERSION;
     }
-    VLOG_FATAL("Unknown OpenFlow version: \"%s\"", s);
+    return 0;
 }
 
 static bool
@@ -890,7 +890,7 @@ ofputil_versions_from_string(const char *s)
 
     while (s[i]) {
         size_t j;
-        enum ofp_version version;
+        int version;
         char *key;
 
         if (is_delimiter(s[i])) {
@@ -903,6 +903,9 @@ ofputil_versions_from_string(const char *s)
         }
         key = xmemdup0(s + i, j);
         version = ofputil_version_from_string(key);
+        if (!version) {
+            VLOG_FATAL("Unknown OpenFlow version: \"%s\"", key);
+        }
         free(key);
         bitmap |= 1u << version;
         i += j;
@@ -911,6 +914,23 @@ ofputil_versions_from_string(const char *s)
     return bitmap;
 }
 
+uint32_t
+ofputil_versions_from_strings(char ** const s, size_t count)
+{
+    uint32_t bitmap = 0;
+
+    while (count--) {
+        int version = ofputil_version_from_string(s[count]);
+        if (!version) {
+            VLOG_WARN("Unknown OpenFlow version: \"%s\"", s[count]);
+        } else {
+            bitmap |= 1u << version;
+        }
+    }
+
+    return bitmap;
+}
+
 const char *
 ofputil_version_to_string(enum ofp_version ofp_version)
 {
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 690413a..78d515b 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -139,6 +139,7 @@ enum ofputil_protocol ofputil_protocols_from_string(const 
char *s);
 
 const char *ofputil_version_to_string(enum ofp_version ofp_version);
 uint32_t ofputil_versions_from_string(const char *s);
+uint32_t ofputil_versions_from_strings(char ** const s, size_t count);
 
 bool ofputil_decode_hello(const struct ofp_header *,
                           uint32_t *allowed_versions);
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index cc1fd4e..4d4ce10 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -587,6 +587,7 @@ name                : "br0"
 netflow             : []
 other_config        : {}
 ports               : []
+protocols           : []
 sflow               : []
 status              : {}
 stp_enable          : false
@@ -1042,6 +1043,7 @@ name                : "br0"
 netflow             : []
 other_config        : {}
 ports               : []
+protocols           : []
 sflow               : []
 status              : {}
 stp_enable          : false
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 316ecc7..23642a3 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -36,6 +36,7 @@
 #include "meta-flow.h"
 #include "netdev.h"
 #include "ofp-print.h"
+#include "ofp-util.h"
 #include "ofpbuf.h"
 #include "ofproto/ofproto.h"
 #include "poll-loop.h"
@@ -814,6 +815,17 @@ bridge_configure_datapath_id(struct bridge *br)
     free(dpid_string);
 }
 
+/* Pick local port hardware address and datapath ID for 'br'. */
+static uint32_t
+bridge_get_allowed_versions(struct bridge *br)
+{
+    if (!br->cfg->n_protocols)
+        return 0;
+
+    return ofputil_versions_from_strings(br->cfg->protocols,
+                                         br->cfg->n_protocols);
+}
+
 /* Set NetFlow configuration on 'br'. */
 static void
 bridge_configure_netflow(struct bridge *br)
@@ -2800,7 +2812,8 @@ bridge_configure_remotes(struct bridge *br,
         n_ocs++;
     }
 
-    ofproto_set_controllers(br->ofproto, ocs, n_ocs, 0);
+    ofproto_set_controllers(br->ofproto, ocs, n_ocs,
+                            bridge_get_allowed_versions(br));
     free(ocs[0].target); /* From bridge_ofproto_controller_for_mgmt(). */
     free(ocs);
 
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index 1234488..fd2bb4b 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -1,6 +1,6 @@
 {"name": "Open_vSwitch",
- "version": "6.11.0",
- "cksum": "3699219253 17163",
+ "version": "6.11.1",
+ "cksum": "2684374538 17324",
  "tables": {
    "Open_vSwitch": {
      "columns": {
@@ -74,6 +74,10 @@
          "type": {"key": {"type": "uuid",
                           "refTable": "Controller"},
                   "min": 0, "max": "unlimited"}},
+       "protocols": {
+         "type": {"key": {"type": "string",
+           "enum": ["set", ["OpenFlow10", "OpenFlow12"]]},
+          "min": 0, "max": "unlimited"}},
        "fail_mode": {
          "type": {"key": {"type": "string",
                           "enum": ["set", ["standalone", "secure"]]},
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 602e687..a410dd8 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -453,6 +453,13 @@
         QoS configured, or if the port does not have a queue with the specified
         ID, the default queue is used instead.
       </column>
+
+      <column name="protocols">
+        List of OpenFlow protocols that may be used when negotiating
+       a connection with a controller. Valid element values are
+       'OpenFlow10' and 'OpenFlow12'. A default value of 'OpenFlow10'
+       will be used if this column is empty.
+      </column>
     </group>
 
     <group title="Spanning Tree Configuration">
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to