[ovs-dev] [PATCH 14/18] ovs-controller: Allow setting of allowed OpenFlow versions

Simon Horman horms at verge.net.au
Thu Oct 18 05:58:14 UTC 2012


--allowed-ofp-versions allows configuration of the versions
that may be used when establishing an OpenFlow connection.

The default is 'OpenFlow10' which is consistent with
the behaviour prior to this patch.

The useful values at this time are:
'OpenFlow10', 'OpenFlow12' and 'OpenFlow10,OpenFlow12'.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 utilities/ovs-controller.8.in |    1 +
 utilities/ovs-controller.c    |   27 +++++++++++----------------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/utilities/ovs-controller.8.in b/utilities/ovs-controller.8.in
index cc21c9c..d07ca1b 100644
--- a/utilities/ovs-controller.8.in
+++ b/utilities/ovs-controller.8.in
@@ -140,6 +140,7 @@ Use this option more than once to add flows from multiple files.
 .so lib/vlog.man
 .so lib/unixctl.man
 .so lib/common.man
+.so so lib/ofp-version.man
 .
 .SH EXAMPLES
 .PP
diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c
index 7a72a0a..47565bb 100644
--- a/utilities/ovs-controller.c
+++ b/utilities/ovs-controller.c
@@ -29,6 +29,7 @@
 #include "daemon.h"
 #include "learning-switch.h"
 #include "ofp-parse.h"
+#include "ofp-version-opt.h"
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
 #include "poll-loop.h"
@@ -92,7 +93,6 @@ static void usage(void) NO_RETURN;
 int
 main(int argc, char *argv[])
 {
-    struct ofputil_version_bitmap ovb = OFPUTIL_VERSION_BITMAP_INITIALIZER;
     struct unixctl_server *unixctl;
     struct switch_ switches[MAX_SWITCHES];
     struct pvconn *listeners[MAX_LISTENERS];
@@ -110,14 +110,13 @@ main(int argc, char *argv[])
                   "use --help for usage");
     }
 
-    ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
-
     n_switches = n_listeners = 0;
     for (i = optind; i < argc; i++) {
         const char *name = argv[i];
         struct vconn *vconn;
 
-        retval = vconn_open(name, &ovb, &vconn, DSCP_DEFAULT);
+        retval = vconn_open(name, get_allowed_ofp_versions(),
+                            &vconn, DSCP_DEFAULT);
         if (!retval) {
             if (n_switches >= MAX_SWITCHES) {
                 ovs_fatal(0, "max %d switch connections", n_switches);
@@ -126,7 +125,8 @@ main(int argc, char *argv[])
             continue;
         } else if (retval == EAFNOSUPPORT) {
             struct pvconn *pvconn;
-            retval = pvconn_open(name, &ovb, &pvconn, DSCP_DEFAULT);
+            retval = pvconn_open(name, get_allowed_ofp_versions(),
+                                 &pvconn, DSCP_DEFAULT);
             if (!retval) {
                 if (n_listeners >= MAX_LISTENERS) {
                     ovs_fatal(0, "max %d passive connections", n_listeners);
@@ -142,7 +142,6 @@ main(int argc, char *argv[])
         ovs_fatal(0, "no active or passive switch connections");
     }
 
-    ofputil_version_bitmap_free_data(&ovb);
     daemonize_start();
 
     retval = unixctl_server_create(unixctl_path, &unixctl);
@@ -203,13 +202,10 @@ main(int argc, char *argv[])
 static void
 new_switch(struct switch_ *sw, struct vconn *vconn)
 {
-    struct ofputil_version_bitmap ovb = OFPUTIL_VERSION_BITMAP_INITIALIZER;
     struct lswitch_config cfg;
     struct rconn *rconn;
 
-    ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
-    rconn = rconn_create(60, 0, DSCP_DEFAULT, &ovb);
-    ofputil_version_bitmap_free_data(&ovb);
+    rconn = rconn_create(60, 0, DSCP_DEFAULT, get_allowed_ofp_versions());
     rconn_connect_unreliably(rconn, vconn, NULL);
 
     cfg.mode = (action_normal ? LSW_NORMAL
@@ -255,7 +251,8 @@ parse_options(int argc, char *argv[])
         OPT_WITH_FLOWS,
         OPT_UNIXCTL,
         VLOG_OPTION_ENUMS,
-        DAEMON_OPTION_ENUMS
+        DAEMON_OPTION_ENUMS,
+        OFP_VERSION_OPTION_ENUMS
     };
     static struct option long_options[] = {
         {"hub",         no_argument, NULL, 'H'},
@@ -269,8 +266,8 @@ parse_options(int argc, char *argv[])
         {"with-flows",  required_argument, NULL, OPT_WITH_FLOWS},
         {"unixctl",     required_argument, NULL, OPT_UNIXCTL},
         {"help",        no_argument, NULL, 'h'},
-        {"version",     no_argument, NULL, 'V'},
         DAEMON_LONG_OPTIONS,
+        OFP_VERSION_LONG_OPTIONS,
         VLOG_LONG_OPTIONS,
         STREAM_SSL_LONG_OPTIONS,
         {"peer-ca-cert", required_argument, NULL, OPT_PEER_CA_CERT},
@@ -340,11 +337,8 @@ parse_options(int argc, char *argv[])
         case 'h':
             usage();
 
-        case 'V':
-            ovs_print_version(OFP10_VERSION, OFP10_VERSION);
-            exit(EXIT_SUCCESS);
-
         VLOG_OPTION_HANDLERS
+        OFP_VERSION_OPTION_HANDLERS
         DAEMON_OPTION_HANDLERS
 
         STREAM_SSL_OPTION_HANDLERS
@@ -386,6 +380,7 @@ usage(void)
            program_name, program_name);
     vconn_usage(true, true, false);
     daemon_usage();
+    ofp_version_usage();
     vlog_usage();
     printf("\nOther options:\n"
            "  -H, --hub               act as hub instead of learning switch\n"
-- 
1.7.10.4




More information about the dev mailing list