X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-openflowd.c;h=4ca22e0d8459a12216a9ff98bb5a770858e941d0;hb=b2fda3effc787f265b5ad5dfa967ac00627bd075;hp=603e2587ba5c7f085e913a8a1ecd3acbc4eb5b8d;hpb=3f355f47f8e7343e909ccfa854454d667baf3c38;p=sliver-openvswitch.git diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 603e2587b..4ca22e0d8 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,7 @@ #include "compiler.h" #include "daemon.h" #include "dirs.h" -#include "dpif.h" -#include "fault.h" +#include "dummy.h" #include "leak-checker.h" #include "list.h" #include "netdev.h" @@ -39,71 +38,50 @@ #include "packets.h" #include "poll-loop.h" #include "rconn.h" -#include "svec.h" +#include "stream-ssl.h" #include "timeval.h" #include "unixctl.h" #include "util.h" -#include "vconn-ssl.h" #include "vconn.h" - #include "vlog.h" -#define THIS_MODULE VLM_openflowd -/* Behavior when the connection to the controller fails. */ -enum fail_mode { - FAIL_OPEN, /* Act as learning switch. */ - FAIL_CLOSED /* Drop all packets. */ -}; +VLOG_DEFINE_THIS_MODULE(openflowd); /* Settings that may be configured by the user. */ struct ofsettings { - /* Overall mode of operation. */ - bool discovery; /* Discover the controller automatically? */ - bool in_band; /* Connect to controller in-band? */ + const char *unixctl_path; /* File name for unixctl socket. */ + + /* Controller configuration. */ + struct ofproto_controller *controllers; + size_t n_controllers; + enum ofproto_fail_mode fail_mode; + bool run_forever; /* Continue running even with no controller? */ /* Datapath. */ uint64_t datapath_id; /* Datapath ID. */ - const char *dp_name; /* Name of local datapath. */ + char *dp_name; /* Name of local datapath. */ + char *dp_type; /* Type of local datapath. */ + struct sset ports; /* Set of ports to add to datapath (if any). */ /* Description strings. */ const char *mfr_desc; /* Manufacturer. */ const char *hw_desc; /* Hardware. */ const char *sw_desc; /* Software version. */ const char *serial_desc; /* Serial number. */ + const char *dp_desc; /* Datapath description. */ /* Related vconns and network devices. */ - const char *controller_name; /* Controller (if not discovery mode). */ - struct svec listeners; /* Listen for management connections. */ - struct svec snoops; /* Listen for controller snooping conns. */ + struct sset snoops; /* Listen for controller snooping conns. */ /* Failure behavior. */ - enum fail_mode fail_mode; /* Act as learning switch if no controller? */ int max_idle; /* Idle time for flows in fail-open mode. */ - int probe_interval; /* # seconds idle before sending echo request. */ - int max_backoff; /* Max # seconds between connection attempts. */ - - /* Packet-in rate-limiting. */ - int rate_limit; /* Tokens added to bucket per second. */ - int burst_limit; /* Maximum number token bucket size. */ - - /* Discovery behavior. */ - const char *accept_controller_re; /* Controller vconns to accept. */ - bool update_resolv_conf; /* Update /etc/resolv.conf? */ - - /* Spanning tree protocol. */ - bool enable_stp; - - /* Remote command execution. */ - char *command_acl; /* Command white/blacklist, as shell globs. */ - char *command_dir; /* Directory that contains commands. */ - - /* Management. */ - uint64_t mgmt_id; /* Management ID. */ /* NetFlow. */ - struct svec netflow; /* NetFlow targets. */ + struct sset netflow; /* NetFlow targets. */ }; +static unixctl_cb_func ovs_openflowd_exit; + static void parse_options(int argc, char *argv[], struct ofsettings *); static void usage(void) NO_RETURN; @@ -114,112 +92,135 @@ main(int argc, char *argv[]) struct ofproto *ofproto; struct ofsettings s; int error; + struct netflow_options nf_options; + const char *port; + bool exiting; + proctitle_init(argc, argv); set_program_name(argv[0]); - register_fault_handlers(); - time_init(); - vlog_init(); parse_options(argc, argv, &s); signal(SIGPIPE, SIG_IGN); - die_if_already_running(); - daemonize(); + daemonize_start(); /* Start listening for ovs-appctl requests. */ - error = unixctl_server_create(NULL, &unixctl); + error = unixctl_server_create(s.unixctl_path, &unixctl); if (error) { - ovs_fatal(error, "Could not listen for unixctl connections"); + exit(EXIT_FAILURE); } + unixctl_command_register("exit", ovs_openflowd_exit, &exiting); + VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR); VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION); - /* Start OpenFlow processing. */ - error = ofproto_create(s.dp_name, NULL, NULL, &ofproto); - if (error) { - ovs_fatal(error, "could not initialize openflow switch"); - } - error = ofproto_set_in_band(ofproto, s.in_band); + error = ofproto_create(s.dp_name, s.dp_type, &ofproto); if (error) { - ovs_fatal(error, "failed to configure in-band control"); + VLOG_FATAL("could not initialize OpenFlow switch (%s)", + strerror(error)); } - error = ofproto_set_discovery(ofproto, s.discovery, s.accept_controller_re, - s.update_resolv_conf); - if (error) { - ovs_fatal(error, "failed to configure controller discovery"); + + /* Add ports to the datapath if requested by the user. */ + SSET_FOR_EACH (port, &s.ports) { + struct netdev *netdev; + + error = netdev_open_default(port, &netdev); + if (error) { + VLOG_FATAL("%s: failed to open network device (%s)", + port, strerror(error)); + } + + error = ofproto_port_add(ofproto, netdev, NULL); + if (error) { + VLOG_FATAL("failed to add %s as a port (%s)", + port, strerror(error)); + } + + netdev_close(netdev); } + + /* Configure OpenFlow switch. */ if (s.datapath_id) { ofproto_set_datapath_id(ofproto, s.datapath_id); } - if (s.mgmt_id) { - ofproto_set_mgmt_id(ofproto, s.mgmt_id); - } - ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, s.serial_desc); - error = ofproto_set_listeners(ofproto, &s.listeners); - if (error) { - ovs_fatal(error, "failed to configure management connections"); - } + ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, + s.serial_desc, s.dp_desc); error = ofproto_set_snoops(ofproto, &s.snoops); if (error) { - ovs_fatal(error, - "failed to configure controller snooping connections"); + VLOG_FATAL("failed to configure controller snooping connections (%s)", + strerror(error)); } - error = ofproto_set_netflow(ofproto, &s.netflow, 0, 0, false); + memset(&nf_options, 0, sizeof nf_options); + nf_options.collectors = s.netflow; + error = ofproto_set_netflow(ofproto, &nf_options); if (error) { - ovs_fatal(error, "failed to configure NetFlow collectors"); - } - ofproto_set_failure(ofproto, s.fail_mode == FAIL_OPEN); - ofproto_set_probe_interval(ofproto, s.probe_interval); - ofproto_set_max_backoff(ofproto, s.max_backoff); - ofproto_set_rate_limit(ofproto, s.rate_limit, s.burst_limit); - error = ofproto_set_stp(ofproto, s.enable_stp); - if (error) { - ovs_fatal(error, "failed to configure STP"); - } - error = ofproto_set_remote_execution(ofproto, s.command_acl, - s.command_dir); - if (error) { - ovs_fatal(error, "failed to configure remote command execution"); - } - if (!s.discovery) { - error = ofproto_set_controller(ofproto, s.controller_name); - if (error) { - ovs_fatal(error, "failed to configure controller"); - } + VLOG_FATAL("failed to configure NetFlow collectors (%s)", + strerror(error)); } + ofproto_set_controllers(ofproto, s.controllers, s.n_controllers); + ofproto_set_fail_mode(ofproto, s.fail_mode); + + daemonize_complete(); - while (ofproto_is_alive(ofproto)) { + exiting = false; + while (!exiting && (s.run_forever || ofproto_is_alive(ofproto))) { error = ofproto_run(ofproto); if (error) { - ovs_fatal(error, "unrecoverable datapath error"); + VLOG_FATAL("unrecoverable datapath error (%s)", strerror(error)); } unixctl_server_run(unixctl); - dp_run(); netdev_run(); ofproto_wait(ofproto); unixctl_server_wait(unixctl); - dp_wait(); netdev_wait(); + if (exiting) { + poll_immediate_wake(); + } poll_block(); } + ofproto_destroy(ofproto); + return 0; } + +static void +ovs_openflowd_exit(struct unixctl_conn *conn, const char *args OVS_UNUSED, + void *exiting_) +{ + bool *exiting = exiting_; + *exiting = true; + unixctl_command_reply(conn, 200, NULL); +} /* User interface. */ +/* Breaks 'ports' apart at commas and adds each resulting word to 'ports'. */ +static void +parse_ports(const char *s_, struct sset *ports) +{ + char *s = xstrdup(s_); + char *save_ptr = NULL; + char *token; + + for (token = strtok_r(s, ",", &save_ptr); token != NULL; + token = strtok_r(NULL, ",", &save_ptr)) { + sset_add(ports, token); + } + free(s); +} + static void parse_options(int argc, char *argv[], struct ofsettings *s) { enum { OPT_DATAPATH_ID = UCHAR_MAX + 1, - OPT_MANUFACTURER, - OPT_HARDWARE, - OPT_SOFTWARE, - OPT_SERIAL, - OPT_ACCEPT_VCONN, - OPT_NO_RESOLV_CONF, + OPT_MFR_DESC, + OPT_HW_DESC, + OPT_SW_DESC, + OPT_SERIAL_DESC, + OPT_DP_DESC, OPT_BR_NAME, OPT_FAIL_MODE, OPT_INACTIVITY_PROBE, @@ -229,79 +230,75 @@ parse_options(int argc, char *argv[], struct ofsettings *s) OPT_RATE_LIMIT, OPT_BURST_LIMIT, OPT_BOOTSTRAP_CA_CERT, - OPT_STP, - OPT_NO_STP, OPT_OUT_OF_BAND, OPT_IN_BAND, - OPT_COMMAND_ACL, - OPT_COMMAND_DIR, OPT_NETFLOW, - OPT_MGMT_ID, + OPT_PORTS, + OPT_UNIXCTL, + OPT_ENABLE_DUMMY, VLOG_OPTION_ENUMS, - LEAK_CHECKER_OPTION_ENUMS + LEAK_CHECKER_OPTION_ENUMS, + DAEMON_OPTION_ENUMS }; static struct option long_options[] = { - {"datapath-id", required_argument, 0, OPT_DATAPATH_ID}, - {"manufacturer", required_argument, 0, OPT_MANUFACTURER}, - {"hardware", required_argument, 0, OPT_HARDWARE}, - {"software", required_argument, 0, OPT_SOFTWARE}, - {"serial", required_argument, 0, OPT_SERIAL}, - {"accept-vconn", required_argument, 0, OPT_ACCEPT_VCONN}, - {"no-resolv-conf", no_argument, 0, OPT_NO_RESOLV_CONF}, - {"config", required_argument, 0, 'F'}, - {"br-name", required_argument, 0, OPT_BR_NAME}, - {"fail", required_argument, 0, OPT_FAIL_MODE}, - {"inactivity-probe", required_argument, 0, OPT_INACTIVITY_PROBE}, - {"max-idle", required_argument, 0, OPT_MAX_IDLE}, - {"max-backoff", required_argument, 0, OPT_MAX_BACKOFF}, - {"listen", required_argument, 0, 'l'}, - {"snoop", required_argument, 0, OPT_SNOOP}, - {"rate-limit", optional_argument, 0, OPT_RATE_LIMIT}, - {"burst-limit", required_argument, 0, OPT_BURST_LIMIT}, - {"stp", no_argument, 0, OPT_STP}, - {"no-stp", no_argument, 0, OPT_NO_STP}, - {"out-of-band", no_argument, 0, OPT_OUT_OF_BAND}, - {"in-band", no_argument, 0, OPT_IN_BAND}, - {"command-acl", required_argument, 0, OPT_COMMAND_ACL}, - {"command-dir", required_argument, 0, OPT_COMMAND_DIR}, - {"netflow", required_argument, 0, OPT_NETFLOW}, - {"mgmt-id", required_argument, 0, OPT_MGMT_ID}, - {"verbose", optional_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, - {"version", no_argument, 0, 'V'}, + {"datapath-id", required_argument, NULL, OPT_DATAPATH_ID}, + {"mfr-desc", required_argument, NULL, OPT_MFR_DESC}, + {"hw-desc", required_argument, NULL, OPT_HW_DESC}, + {"sw-desc", required_argument, NULL, OPT_SW_DESC}, + {"serial-desc", required_argument, NULL, OPT_SERIAL_DESC}, + {"dp-desc", required_argument, NULL, OPT_DP_DESC}, + {"config", required_argument, NULL, 'F'}, + {"br-name", required_argument, NULL, OPT_BR_NAME}, + {"fail", required_argument, NULL, OPT_FAIL_MODE}, + {"inactivity-probe", required_argument, NULL, OPT_INACTIVITY_PROBE}, + {"max-idle", required_argument, NULL, OPT_MAX_IDLE}, + {"max-backoff", required_argument, NULL, OPT_MAX_BACKOFF}, + {"listen", required_argument, NULL, 'l'}, + {"snoop", required_argument, NULL, OPT_SNOOP}, + {"rate-limit", optional_argument, NULL, OPT_RATE_LIMIT}, + {"burst-limit", required_argument, NULL, OPT_BURST_LIMIT}, + {"out-of-band", no_argument, NULL, OPT_OUT_OF_BAND}, + {"in-band", no_argument, NULL, OPT_IN_BAND}, + {"netflow", required_argument, NULL, OPT_NETFLOW}, + {"ports", required_argument, NULL, OPT_PORTS}, + {"unixctl", required_argument, NULL, OPT_UNIXCTL}, + {"enable-dummy", no_argument, NULL, OPT_ENABLE_DUMMY}, + {"verbose", optional_argument, NULL, 'v'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, DAEMON_LONG_OPTIONS, VLOG_LONG_OPTIONS, LEAK_CHECKER_LONG_OPTIONS, -#ifdef HAVE_OPENSSL - VCONN_SSL_LONG_OPTIONS - {"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT}, -#endif - {0, 0, 0, 0}, + STREAM_SSL_LONG_OPTIONS, + {"bootstrap-ca-cert", required_argument, NULL, OPT_BOOTSTRAP_CA_CERT}, + {NULL, 0, NULL, 0}, }; char *short_options = long_options_to_short_options(long_options); + struct ofproto_controller controller_opts; + struct sset controllers; + const char *name; + int i; /* Set defaults that we can figure out before parsing options. */ + controller_opts.target = NULL; + controller_opts.max_backoff = 8; + controller_opts.probe_interval = 5; + controller_opts.band = OFPROTO_IN_BAND; + controller_opts.rate_limit = 0; + controller_opts.burst_limit = 0; + s->unixctl_path = NULL; + s->fail_mode = OFPROTO_FAIL_STANDALONE; s->datapath_id = 0; s->mfr_desc = NULL; s->hw_desc = NULL; s->sw_desc = NULL; s->serial_desc = NULL; - svec_init(&s->listeners); - svec_init(&s->snoops); - s->fail_mode = FAIL_OPEN; + s->dp_desc = NULL; + sset_init(&controllers); + sset_init(&s->snoops); s->max_idle = 0; - s->probe_interval = 0; - s->max_backoff = 8; - s->update_resolv_conf = true; - s->rate_limit = 0; - s->burst_limit = 0; - s->accept_controller_re = NULL; - s->enable_stp = false; - s->in_band = true; - s->command_acl = ""; - s->command_dir = NULL; - svec_init(&s->netflow); - s->mgmt_id = 0; + sset_init(&s->netflow); + sset_init(&s->ports); for (;;) { int c; @@ -312,55 +309,48 @@ parse_options(int argc, char *argv[], struct ofsettings *s) switch (c) { case OPT_DATAPATH_ID: - if (strlen(optarg) != 12 - || strspn(optarg, "0123456789abcdefABCDEF") != 12) { - ovs_fatal(0, "argument to --datapath-id must be " - "exactly 12 hex digits"); - } - s->datapath_id = strtoll(optarg, NULL, 16); - if (!s->datapath_id) { - ovs_fatal(0, "argument to --datapath-id must be nonzero"); + if (!dpid_from_string(optarg, &s->datapath_id)) { + VLOG_FATAL("argument to --datapath-id must be exactly 16 hex " + "digits and may not be all-zero"); } break; - case OPT_MANUFACTURER: + case OPT_MFR_DESC: s->mfr_desc = optarg; break; - case OPT_HARDWARE: + case OPT_HW_DESC: s->hw_desc = optarg; break; - case OPT_SOFTWARE: + case OPT_SW_DESC: s->sw_desc = optarg; break; - case OPT_SERIAL: + case OPT_SERIAL_DESC: s->serial_desc = optarg; break; - case OPT_ACCEPT_VCONN: - s->accept_controller_re = optarg; - break; - - case OPT_NO_RESOLV_CONF: - s->update_resolv_conf = false; + case OPT_DP_DESC: + s->dp_desc = optarg; break; case OPT_FAIL_MODE: - if (!strcmp(optarg, "open")) { - s->fail_mode = FAIL_OPEN; - } else if (!strcmp(optarg, "closed")) { - s->fail_mode = FAIL_CLOSED; + if (!strcmp(optarg, "open") || !strcmp(optarg, "standalone")) { + s->fail_mode = OFPROTO_FAIL_STANDALONE; + } else if (!strcmp(optarg, "closed") + || !strcmp(optarg, "secure")) { + s->fail_mode = OFPROTO_FAIL_SECURE; } else { - ovs_fatal(0, "--fail argument must be \"open\" or \"closed\""); + VLOG_FATAL("--fail argument must be \"standalone\" " + "or \"secure\""); } break; case OPT_INACTIVITY_PROBE: - s->probe_interval = atoi(optarg); - if (s->probe_interval < 5) { - ovs_fatal(0, "--inactivity-probe argument must be at least 5"); + controller_opts.probe_interval = atoi(optarg); + if (controller_opts.probe_interval < 5) { + VLOG_FATAL("--inactivity-probe argument must be at least 5"); } break; @@ -370,87 +360,69 @@ parse_options(int argc, char *argv[], struct ofsettings *s) } else { s->max_idle = atoi(optarg); if (s->max_idle < 1 || s->max_idle > 65535) { - ovs_fatal(0, "--max-idle argument must be between 1 and " - "65535 or the word 'permanent'"); + VLOG_FATAL("--max-idle argument must be between 1 and " + "65535 or the word 'permanent'"); } } break; case OPT_MAX_BACKOFF: - s->max_backoff = atoi(optarg); - if (s->max_backoff < 1) { - ovs_fatal(0, "--max-backoff argument must be at least 1"); - } else if (s->max_backoff > 3600) { - s->max_backoff = 3600; + controller_opts.max_backoff = atoi(optarg); + if (controller_opts.max_backoff < 1) { + VLOG_FATAL("--max-backoff argument must be at least 1"); + } else if (controller_opts.max_backoff > 3600) { + controller_opts.max_backoff = 3600; } break; case OPT_RATE_LIMIT: if (optarg) { - s->rate_limit = atoi(optarg); - if (s->rate_limit < 1) { - ovs_fatal(0, "--rate-limit argument must be at least 1"); + controller_opts.rate_limit = atoi(optarg); + if (controller_opts.rate_limit < 1) { + VLOG_FATAL("--rate-limit argument must be at least 1"); } } else { - s->rate_limit = 1000; + controller_opts.rate_limit = 1000; } break; case OPT_BURST_LIMIT: - s->burst_limit = atoi(optarg); - if (s->burst_limit < 1) { - ovs_fatal(0, "--burst-limit argument must be at least 1"); + controller_opts.burst_limit = atoi(optarg); + if (controller_opts.burst_limit < 1) { + VLOG_FATAL("--burst-limit argument must be at least 1"); } break; - case OPT_STP: - s->enable_stp = true; - break; - - case OPT_NO_STP: - s->enable_stp = false; - break; - case OPT_OUT_OF_BAND: - s->in_band = false; + controller_opts.band = OFPROTO_OUT_OF_BAND; break; case OPT_IN_BAND: - s->in_band = true; + controller_opts.band = OFPROTO_IN_BAND; break; - case OPT_COMMAND_ACL: - s->command_acl = (s->command_acl[0] - ? xasprintf("%s,%s", s->command_acl, optarg) - : optarg); + case OPT_NETFLOW: + sset_add(&s->netflow, optarg); break; - case OPT_COMMAND_DIR: - s->command_dir = optarg; + case 'l': + sset_add(&controllers, optarg); break; - case OPT_NETFLOW: - svec_add(&s->netflow, optarg); + case OPT_SNOOP: + sset_add(&s->snoops, optarg); break; - case OPT_MGMT_ID: - if (strlen(optarg) != 12 - || strspn(optarg, "0123456789abcdefABCDEF") != 12) { - ovs_fatal(0, "argument to --mgmt-id must be " - "exactly 12 hex digits"); - } - s->mgmt_id = strtoll(optarg, NULL, 16); - if (!s->mgmt_id) { - ovs_fatal(0, "argument to --mgmt-id must be nonzero"); - } + case OPT_PORTS: + parse_ports(optarg, &s->ports); break; - case 'l': - svec_add(&s->listeners, optarg); + case OPT_UNIXCTL: + s->unixctl_path = optarg; break; - case OPT_SNOOP: - svec_add(&s->snoops, optarg); + case OPT_ENABLE_DUMMY: + dummy_enable(); break; case 'h': @@ -466,13 +438,11 @@ parse_options(int argc, char *argv[], struct ofsettings *s) LEAK_CHECKER_OPTION_HANDLERS -#ifdef HAVE_OPENSSL - VCONN_SSL_OPTION_HANDLERS + STREAM_SSL_OPTION_HANDLERS case OPT_BOOTSTRAP_CA_CERT: - vconn_ssl_set_ca_cert_file(optarg, true); + stream_ssl_set_ca_cert_file(optarg, true); break; -#endif case '?': exit(EXIT_FAILURE); @@ -485,55 +455,64 @@ parse_options(int argc, char *argv[], struct ofsettings *s) argc -= optind; argv += optind; - if (argc < 1 || argc > 2) { - ovs_fatal(0, "need one or two non-option arguments; " - "use --help for usage"); + if (argc < 2) { + VLOG_FATAL("need at least two non-option arguments; " + "use --help for usage"); } - /* Local and remote vconns. */ - s->dp_name = argv[0]; - s->controller_name = argc > 1 ? xstrdup(argv[1]) : NULL; - - /* Set accept_controller_regex. */ - if (!s->accept_controller_re) { - s->accept_controller_re - = vconn_ssl_is_configured() ? "^ssl:.*" : "^tcp:.*"; + /* Rate limiting. */ + if (controller_opts.rate_limit && controller_opts.rate_limit < 100) { + VLOG_WARN("Rate limit set to unusually low value %d", + controller_opts.rate_limit); } - /* Mode of operation. */ - s->discovery = s->controller_name == NULL; - if (s->discovery && !s->in_band) { - ovs_fatal(0, "Cannot perform discovery with out-of-band control"); + /* Local vconns. */ + ofproto_parse_name(argv[0], &s->dp_name, &s->dp_type); + + /* Figure out controller names. */ + s->run_forever = false; + if (sset_is_empty(&controllers)) { + sset_add_and_free(&controllers, xasprintf("punix:%s/%s.mgmt", + ovs_rundir(), s->dp_name)); + } + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "none")) { + s->run_forever = true; + } else { + sset_add(&controllers, argv[i]); + } } - /* Rate limiting. */ - if (s->rate_limit && s->rate_limit < 100) { - VLOG_WARN("Rate limit set to unusually low value %d", s->rate_limit); + /* Set up controllers. */ + s->n_controllers = sset_count(&controllers); + s->controllers = xmalloc(s->n_controllers * sizeof *s->controllers); + i = 0; + SSET_FOR_EACH (name, &controllers) { + s->controllers[i] = controller_opts; + s->controllers[i].target = xstrdup(name); + i++; } + sset_destroy(&controllers); } static void usage(void) { printf("%s: an OpenFlow switch implementation.\n" - "usage: %s [OPTIONS] DATAPATH [CONTROLLER]\n" - "DATAPATH is a local datapath (e.g. \"dp0\").\n" - "CONTROLLER is an active OpenFlow connection method; if it is\n" - "omitted, then ovs-openflowd performs controller discovery.\n", + "usage: %s [OPTIONS] [TYPE@]DATAPATH CONTROLLER...\n" + "where DATAPATH is a local datapath (e.g. \"dp0\")\n" + "optionally with an explicit TYPE (default: \"system\").\n" + "Each CONTROLLER is an active OpenFlow connection method.\n", program_name, program_name); vconn_usage(true, true, true); printf("\nOpenFlow options:\n" " -d, --datapath-id=ID Use ID as the OpenFlow switch ID\n" - " (ID must consist of 12 hex digits)\n" - " --mgmt-id=ID Use ID as the management ID\n" - " (ID must consist of 12 hex digits)\n" - " --manufacturer=MFR Identify manufacturer as MFR\n" - " --hardware=HW Identify hardware as HW\n" - " --software=SW Identify software as SW\n" - " --serial=SERIAL Identify serial number as SERIAL\n" - "\nController discovery options:\n" - " --accept-vconn=REGEX accept matching discovered controllers\n" - " --no-resolv-conf do not update /etc/resolv.conf\n" + " (ID must consist of 16 hex digits)\n" + " --mfr-desc=MFR Identify manufacturer as MFR\n" + " --hw-desc=HW Identify hardware as HW\n" + " --sw-desc=SW Identify software as SW\n" + " --serial-desc=SERIAL Identify serial number as SERIAL\n" + " --dp-desc=DP_DESC Identify dp description as DP_DESC\n" "\nNetworking options:\n" " --fail=open|closed when controller connection fails:\n" " closed: drop all packets\n" @@ -550,14 +529,11 @@ usage(void) " --netflow=HOST:PORT configure NetFlow output target\n" "\nRate-limiting of \"packet-in\" messages to the controller:\n" " --rate-limit[=PACKETS] max rate, in packets/s (default: 1000)\n" - " --burst-limit=BURST limit on packet credit for idle time\n" - "\nRemote command execution options:\n" - " --command-acl=[!]GLOB[,[!]GLOB...] set allowed/denied commands\n" - " --command-dir=DIR set command dir (default: %s/commands)\n", - ovs_pkgdatadir); + " --burst-limit=BURST limit on packet credit for idle time\n"); daemon_usage(); vlog_usage(); printf("\nOther options:\n" + " --unixctl=SOCKET override default control socket name\n" " -h, --help display this help message\n" " -V, --version display version information\n"); leak_checker_usage();