[ovs-dev] [PATCH 14/17] ovs-controller: Add options to allow seting of OpenFlow version

Simon Horman horms at verge.net.au
Thu Oct 4 02:41:29 UTC 2012


--min-ofp-version allows the minimum OpenFlow version to be set.
--max-ofp-version allows the maximum OpenFlow version to be set.
The default for both is OFP10_VERSION which retains the existing
behaviour.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 utilities/ovs-controller.8.in |    1 +
 utilities/ovs-controller.c    |   23 +++++++++++++----------
 2 files changed, 14 insertions(+), 10 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 3e7df41..300bdb4 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"
@@ -114,7 +115,7 @@ main(int argc, char *argv[])
         const char *name = argv[i];
         struct vconn *vconn;
 
-        retval = vconn_open(name, OFP10_VERSION, OFP10_VERSION,
+        retval = vconn_open(name, min_ofp_version, max_ofp_version,
                             &vconn, DSCP_DEFAULT);
         if (!retval) {
             if (n_switches >= MAX_SWITCHES) {
@@ -154,8 +155,8 @@ main(int argc, char *argv[])
         for (i = 0; i < n_listeners && n_switches < MAX_SWITCHES; ) {
             struct vconn *new_vconn;
 
-            retval = pvconn_accept(listeners[i], OFP10_VERSION,
-                                   OFP10_VERSION, &new_vconn);
+            retval = pvconn_accept(listeners[i], min_ofp_version,
+                                   max_ofp_version, &new_vconn);
             if (!retval || retval == EAGAIN) {
                 if (!retval) {
                     new_switch(&switches[n_switches++], new_vconn);
@@ -204,7 +205,8 @@ new_switch(struct switch_ *sw, struct vconn *vconn)
     struct lswitch_config cfg;
     struct rconn *rconn;
 
-    rconn = rconn_create(60, 0, DSCP_DEFAULT, OFP10_VERSION, OFP10_VERSION);
+    rconn = rconn_create(60, 0, DSCP_DEFAULT,
+                         min_ofp_version, max_ofp_version);
     rconn_connect_unreliably(rconn, vconn, NULL);
 
     cfg.mode = (action_normal ? LSW_NORMAL
@@ -250,7 +252,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'},
@@ -264,8 +267,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},
@@ -335,11 +338,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
@@ -357,6 +357,8 @@ parse_options(int argc, char *argv[])
     }
     free(short_options);
 
+    ofp_version_check();
+
     if (!simap_is_empty(&port_queues) || default_queue != UINT32_MAX) {
         if (action_normal) {
             ovs_error(0, "queue IDs are incompatible with -N or --normal; "
@@ -381,6 +383,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