From: Simon Horman Date: Mon, 19 Nov 2012 05:59:33 +0000 (+0900) Subject: ovs-controller: Allow setting of allowed OpenFlow versions X-Git-Tag: sliver-openvswitch-1.9.90-3~10^2~139 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=be721d87f4978f7625b9948591c7ffb079262fd9;p=sliver-openvswitch.git ovs-controller: Allow setting of allowed OpenFlow versions --protocols 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', 'OpenFlow13', Values may be combined in a comma delimited list. e.g.: --protocols 'OpenFlow10,OpenFlow12,OpenFlow13' Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/utilities/ovs-controller.8.in b/utilities/ovs-controller.8.in index cc21c9c67..d07ca1b4c 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 af8d725a7..bf0ae9244 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" @@ -115,7 +116,8 @@ main(int argc, char *argv[]) const char *name = argv[i]; struct vconn *vconn; - retval = vconn_open(name, 0, &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); @@ -124,7 +126,8 @@ main(int argc, char *argv[]) continue; } else if (retval == EAFNOSUPPORT) { struct pvconn *pvconn; - retval = pvconn_open(name, 0, &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); @@ -203,7 +206,7 @@ new_switch(struct switch_ *sw, struct vconn *vconn) struct lswitch_config cfg; struct rconn *rconn; - rconn = rconn_create(60, 0, DSCP_DEFAULT, 0); + rconn = rconn_create(60, 0, DSCP_DEFAULT, get_allowed_ofp_versions()); rconn_connect_unreliably(rconn, vconn, NULL); cfg.mode = (action_normal ? LSW_NORMAL @@ -249,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'}, @@ -263,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}, @@ -334,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 @@ -380,6 +381,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"