- * Copyright (c) 2008, 2009, 2010 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/* Datapath. */
uint64_t datapath_id; /* Datapath ID. */
char *dp_name; /* Name of local datapath. */
char *dp_type; /* Type of local datapath. */
/* Datapath. */
uint64_t datapath_id; /* Datapath ID. */
char *dp_name; /* Name of local datapath. */
char *dp_type; /* Type of local datapath. */
static void parse_options(int argc, char *argv[], struct ofsettings *);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[], struct ofsettings *);
static void usage(void) NO_RETURN;
proctitle_init(argc, argv);
set_program_name(argv[0]);
proctitle_init(argc, argv);
set_program_name(argv[0]);
parse_options(argc, argv, &s);
signal(SIGPIPE, SIG_IGN);
parse_options(argc, argv, &s);
signal(SIGPIPE, SIG_IGN);
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
- SVEC_FOR_EACH (i, port, &s.ports) {
- error = netdev_open_default(port, &netdev);
- if (error) {
- ovs_fatal(error, "failed to open %s as a device", port);
- }
+ error = netdev_open_default(port, &netdev);
+ if (error) {
+ ovs_fatal(error, "%s: failed to open network device", port);
+ }
- error = dpif_port_add(dpif, port, 0, NULL);
- if (error) {
- ovs_fatal(error, "failed to add %s as a port", port);
- }
+ error = dpif_port_add(dpif, netdev, NULL);
+ if (error) {
+ ovs_fatal(error, "failed to add %s as a port", port);
}
ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc,
s.serial_desc, s.dp_desc);
}
ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc,
s.serial_desc, s.dp_desc);
- if (!s.listeners.n) {
- svec_add_nocopy(&s.listeners, xasprintf("punix:%s/%s.mgmt",
- ovs_rundir, s.dp_name));
- } else if (s.listeners.n == 1 && !strcmp(s.listeners.names[0], "none")) {
- svec_clear(&s.listeners);
- }
- error = ofproto_set_listeners(ofproto, &s.listeners);
- if (error) {
- ovs_fatal(error, "failed to configure management connections");
- }
error = ofproto_run(ofproto);
if (error) {
ovs_fatal(error, "unrecoverable datapath error");
error = ofproto_run(ofproto);
if (error) {
ovs_fatal(error, "unrecoverable datapath error");
+
+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);
+}
+/* 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 struct option long_options[] = {
{"datapath-id", required_argument, 0, OPT_DATAPATH_ID},
};
static struct option long_options[] = {
{"datapath-id", required_argument, 0, OPT_DATAPATH_ID},
{"sw-desc", required_argument, 0, OPT_SW_DESC},
{"serial-desc", required_argument, 0, OPT_SERIAL_DESC},
{"dp-desc", required_argument, 0, OPT_DP_DESC},
{"sw-desc", required_argument, 0, OPT_SW_DESC},
{"serial-desc", required_argument, 0, OPT_SERIAL_DESC},
{"dp-desc", required_argument, 0, OPT_DP_DESC},
- {"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},
{"config", required_argument, 0, 'F'},
{"br-name", required_argument, 0, OPT_BR_NAME},
{"fail", required_argument, 0, OPT_FAIL_MODE},
{"snoop", required_argument, 0, OPT_SNOOP},
{"rate-limit", optional_argument, 0, OPT_RATE_LIMIT},
{"burst-limit", required_argument, 0, OPT_BURST_LIMIT},
{"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},
{"netflow", required_argument, 0, OPT_NETFLOW},
{"ports", required_argument, 0, OPT_PORTS},
{"out-of-band", no_argument, 0, OPT_OUT_OF_BAND},
{"in-band", no_argument, 0, OPT_IN_BAND},
{"netflow", required_argument, 0, OPT_NETFLOW},
{"ports", required_argument, 0, OPT_PORTS},
+ {"unixctl", required_argument, 0, OPT_UNIXCTL},
+ {"enable-dummy", no_argument, 0, OPT_ENABLE_DUMMY},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
};
char *short_options = long_options_to_short_options(long_options);
struct ofproto_controller controller_opts;
};
char *short_options = long_options_to_short_options(long_options);
struct ofproto_controller controller_opts;
/* Set defaults that we can figure out before parsing options. */
controller_opts.target = NULL;
controller_opts.max_backoff = 8;
controller_opts.probe_interval = 5;
/* Set defaults that we can figure out before parsing options. */
controller_opts.target = NULL;
controller_opts.max_backoff = 8;
controller_opts.probe_interval = 5;
- if (!strcmp(optarg, "open")) {
- controller_opts.fail = OFPROTO_FAIL_STANDALONE;
- } else if (!strcmp(optarg, "closed")) {
- controller_opts.fail = OFPROTO_FAIL_SECURE;
+ 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;
- svec_split(&s->ports, optarg, ",");
+ parse_ports(optarg, &s->ports);
+ break;
+
+ case OPT_UNIXCTL:
+ s->unixctl_path = optarg;
+ break;
+
+ case OPT_ENABLE_DUMMY:
+ dummy_enable();
/* Rate limiting. */
if (controller_opts.rate_limit && controller_opts.rate_limit < 100) {
VLOG_WARN("Rate limit set to unusually low value %d",
/* Rate limiting. */
if (controller_opts.rate_limit && controller_opts.rate_limit < 100) {
VLOG_WARN("Rate limit set to unusually low value %d",
- /* Controllers. */
- s->n_controllers = argc > 1 ? argc - 1 : 1;
- s->controllers = xmalloc(s->n_controllers * sizeof *s->controllers);
- if (argc > 1) {
- size_t i;
-
- for (i = 0; i < s->n_controllers; i++) {
- s->controllers[i] = controller_opts;
- s->controllers[i].target = argv[i + 1];
+ /* 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]);
- /* Sanity check. */
- if (controller_opts.band == OFPROTO_OUT_OF_BAND) {
- size_t i;
-
- for (i = 0; i < s->n_controllers; i++) {
- if (!strcmp(s->controllers[i].target, "discover")) {
- ovs_fatal(0, "Cannot perform discovery with out-of-band "
- "control");
- }
- }
+ /* 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++;
- "usage: %s [OPTIONS] DATAPATH [CONTROLLER...]\n"
- "DATAPATH is a local datapath (e.g. \"dp0\").\n"
- "Each CONTROLLER is an active OpenFlow connection method. If\n"
- "none is given, 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"
program_name, program_name);
vconn_usage(true, true, true);
printf("\nOpenFlow options:\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"
" --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"
"\nNetworking options:\n"
" --fail=open|closed when controller connection fails:\n"
" closed: drop all packets\n"
" -h, --help display this help message\n"
" -V, --version display version information\n");
leak_checker_usage();
" -h, --help display this help message\n"
" -V, --version display version information\n");
leak_checker_usage();