- * 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]);
parse_options(argc, argv, &s);
signal(SIGPIPE, SIG_IGN);
proctitle_init(argc, argv);
set_program_name(argv[0]);
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);
error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif);
if (error) {
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif);
if (error) {
- if (s.ports.n) {
- const char *port;
- size_t i;
-
- SVEC_FOR_EACH (i, port, &s.ports) {
- error = dpif_port_add(dpif, port, 0, NULL);
- if (error) {
- ovs_fatal(error, "failed to add %s as a port", port);
- }
+ 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 = dpif_port_add(dpif, netdev, NULL);
+ if (error) {
+ VLOG_FATAL("failed to add %s as a port (%s)",
+ port, strerror(error));
}
/* Start OpenFlow processing. */
error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto);
if (error) {
}
/* Start OpenFlow processing. */
error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto);
if (error) {
}
if (s.datapath_id) {
ofproto_set_datapath_id(ofproto, s.datapath_id);
}
ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc,
s.serial_desc, s.dp_desc);
}
if (s.datapath_id) {
ofproto_set_datapath_id(ofproto, s.datapath_id);
}
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");
- }
}
memset(&nf_options, 0, sizeof nf_options);
nf_options.collectors = s.netflow;
error = ofproto_set_netflow(ofproto, &nf_options);
if (error) {
}
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");
- }
- error = ofproto_set_stp(ofproto, s.enable_stp);
- if (error) {
- ovs_fatal(error, "failed to configure STP");
+ VLOG_FATAL("failed to configure NetFlow collectors (%s)",
+ strerror(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;
- ovs_fatal(0, "argument to --datapath-id must be "
- "exactly 16 hex digits and may not be all-zero");
+ VLOG_FATAL("argument to --datapath-id must be exactly 16 hex "
+ "digits and may not be all-zero");
} else if (!strcmp(optarg, "closed")
|| !strcmp(optarg, "secure")) {
} else if (!strcmp(optarg, "closed")
|| !strcmp(optarg, "secure")) {
}
break;
case OPT_INACTIVITY_PROBE:
controller_opts.probe_interval = atoi(optarg);
if (controller_opts.probe_interval < 5) {
}
break;
case OPT_INACTIVITY_PROBE:
controller_opts.probe_interval = atoi(optarg);
if (controller_opts.probe_interval < 5) {
- 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'");
- 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();
- if (argc < 1 || argc > 2) {
- ovs_fatal(0, "need one or two non-option arguments; "
- "use --help for usage");
- }
-
- /* Set accept_controller_regex. */
- if (!controller_opts.accept_re) {
- controller_opts.accept_re
- = stream_ssl_is_configured() ? "^ssl:.*" : "^tcp:.*";
+ if (argc < 2) {
+ VLOG_FATAL("need at least two non-option arguments; "
+ "use --help for usage");
- /* 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();