#include <signal.h>
#include <string.h>
-#include "cfg.h"
#include "command-line.h"
#include "compiler.h"
#include "daemon.h"
#include "packets.h"
#include "poll-loop.h"
#include "rconn.h"
-#include "signals.h"
#include "status.h"
#include "svec.h"
#include "timeval.h"
/* Settings that may be configured by the user. */
struct ofsettings {
- /* Configuration. */
- const char *br_name; /* Bridge name to use for configuration lookup */
-
/* Overall mode of operation. */
bool discovery; /* Discover the controller automatically? */
bool in_band; /* Connect to controller in-band? */
/* 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. */
};
-static void reconfigure(struct ofproto *, struct ofsettings *);
static void parse_options(int argc, char *argv[], struct ofsettings *);
static void usage(void) NO_RETURN;
int
main(int argc, char *argv[])
{
- struct signal *sighup;
struct ofproto *ofproto;
struct ofsettings s;
int error;
vlog_init();
parse_options(argc, argv, &s);
signal(SIGPIPE, SIG_IGN);
- sighup = signal_register(SIGHUP);
die_if_already_running();
daemonize();
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) {
ofp_fatal(error, "failed to configure management connections");
}
+ error = ofproto_set_netflow(ofproto, &s.netflow);
+ if (error) {
+ ofp_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);
}
}
- reconfigure(ofproto, &s);
while (ofproto_is_alive(ofproto)) {
- if (signal_poll(sighup)) {
- reconfigure(ofproto, &s);
- }
-
error = ofproto_run(ofproto);
if (error) {
ofp_fatal(error, "unrecoverable datapath error");
}
-
ofproto_wait(ofproto);
- signal_wait(sighup);
poll_block();
}
return 0;
}
-
-static void
-reconfigure(struct ofproto *ofproto, struct ofsettings *s)
-{
- cfg_read();
- if (s->br_name) {
- struct svec collectors;
-
- svec_init(&collectors);
- cfg_get_all_keys(&collectors, "netflow.%s.host", s->br_name);
- ofproto_set_netflow(ofproto, &collectors);
- svec_destroy(&collectors);
- }
-
- /* xxx Changing this should probably force reconnect to NOX! */
- ofproto_set_mgmt_id(ofproto, cfg_get_mac(0, "vswitchd.mgmt.id"));
-}
\f
/* User interface. */
OPT_IN_BAND,
OPT_COMMAND_ACL,
OPT_COMMAND_DIR,
+ OPT_NETFLOW,
+ OPT_MGMT_ID,
VLOG_OPTION_ENUMS,
LEAK_CHECKER_OPTION_ENUMS
};
{"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'},
char *short_options = long_options_to_short_options(long_options);
/* Set defaults that we can figure out before parsing options. */
- s->br_name = NULL;
s->datapath_id = 0;
s->mfr_desc = NULL;
s->hw_desc = NULL;
s->in_band = true;
s->command_acl = "";
s->command_dir = NULL;
+ svec_init(&s->netflow);
+ s->mgmt_id = 0;
for (;;) {
int error;
int c;
s->accept_controller_re = optarg;
break;
- case OPT_BR_NAME:
- s->br_name = optarg;
- break;
-
case OPT_NO_RESOLV_CONF:
s->update_resolv_conf = false;
break;
s->command_dir = optarg;
break;
- case 'F':
- error = cfg_set_file(optarg);
- if (error) {
- ofp_fatal(error, "failed to add configuration file \"%s\"",
- optarg);
+ case OPT_NETFLOW:
+ svec_add(&s->netflow, optarg);
+ break;
+
+ case OPT_MGMT_ID:
+ if (strlen(optarg) != 12
+ || strspn(optarg, "0123456789abcdefABCDEF") != 12) {
+ ofp_fatal(0, "argument to --mgmt-id must be "
+ "exactly 12 hex digits");
+ }
+ s->mgmt_id = strtoll(optarg, NULL, 16);
+ if (!s->mgmt_id) {
+ ofp_fatal(0, "argument to --mgmt-id must be nonzero");
}
break;
"omitted, then secchan performs controller discovery.\n",
program_name, program_name);
vconn_usage(true, true, true);
- printf("\nConfiguration options:\n"
- " -F, --config=FILE reads configuration from FILE\n"
- " --br-name=NAME bridge name to use for configuration\n"
- "\nOpenFlow options:\n"
+ 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"
" --out-of-band controller connection is out-of-band\n"
" --stp enable 802.1D Spanning Tree Protocol\n"
" --no-stp disable 802.1D Spanning Tree Protocol\n"
+ " --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"