From: Ben Pfaff Date: Thu, 12 Mar 2009 00:10:42 +0000 (-0700) Subject: secchan: Drop configuration file support. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35e0f01f4b9546a3af82b0ddf282511bfb1db066;p=openvswitch secchan: Drop configuration file support. Configuration file support was added to secchan specifically to allow vswitchd to change the set of NetFlow collectors at runtime without killing and restarting secchan. secchan is integrated into vswitchd, so vswitchd can now do this through a function call instead of through a configuration file. This means that we can kill off the secchan configuration file and add back the --netflow option that it replaced. Also, add a --mgmt-id option to supplant the other use for the configuration file that had appeared in the meantime. --- diff --git a/secchan/main.c b/secchan/main.c index 890d6d40..8b82ad8d 100644 --- a/secchan/main.c +++ b/secchan/main.c @@ -41,7 +41,6 @@ #include #include -#include "cfg.h" #include "command-line.h" #include "compiler.h" #include "daemon.h" @@ -60,7 +59,6 @@ #include "packets.h" #include "poll-loop.h" #include "rconn.h" -#include "signals.h" #include "status.h" #include "svec.h" #include "timeval.h" @@ -80,9 +78,6 @@ enum fail_mode { /* 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? */ @@ -121,16 +116,20 @@ struct ofsettings { /* 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; @@ -141,7 +140,6 @@ main(int argc, char *argv[]) vlog_init(); parse_options(argc, argv, &s); signal(SIGPIPE, SIG_IGN); - sighup = signal_register(SIGHUP); die_if_already_running(); daemonize(); @@ -172,11 +170,18 @@ main(int argc, char *argv[]) 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); @@ -197,41 +202,17 @@ main(int argc, char *argv[]) } } - 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")); -} /* User interface. */ @@ -260,6 +241,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s) OPT_IN_BAND, OPT_COMMAND_ACL, OPT_COMMAND_DIR, + OPT_NETFLOW, + OPT_MGMT_ID, VLOG_OPTION_ENUMS, LEAK_CHECKER_OPTION_ENUMS }; @@ -286,6 +269,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s) {"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'}, @@ -301,7 +286,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s) 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; @@ -320,6 +304,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->in_band = true; s->command_acl = ""; s->command_dir = NULL; + svec_init(&s->netflow); + s->mgmt_id = 0; for (;;) { int error; int c; @@ -362,10 +348,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s) 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; @@ -453,11 +435,19 @@ parse_options(int argc, char *argv[], struct ofsettings *s) 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; @@ -542,12 +532,11 @@ usage(void) "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" @@ -568,6 +557,7 @@ usage(void) " --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"