X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-openflowd.c;h=35f6f246ae9c5a685bb6cfcb3356527dd011fccf;hb=cef90b63b91e6738ea43d2039d6b0506a4752f97;hp=f60dea5a47777ccdfd17b39673381671fae81fbc;hpb=3b01baa3970139c3a195017ab1ea3e42761e3db2;p=sliver-openvswitch.git diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index f60dea5a4..35f6f246a 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -64,6 +64,7 @@ struct ofsettings { /* Datapath. */ uint64_t datapath_id; /* Datapath ID. */ const char *dp_name; /* Name of local datapath. */ + struct svec ports; /* Set of ports to add to datapath (if any). */ /* Description strings. */ const char *mfr_desc; /* Manufacturer. */ @@ -114,6 +115,7 @@ main(int argc, char *argv[]) struct ofproto *ofproto; struct ofsettings s; int error; + struct netflow_options nf_options; set_program_name(argv[0]); register_fault_handlers(); @@ -134,6 +136,26 @@ main(int argc, char *argv[]) VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR); VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION); + /* Create the datapath and add ports to it, if requested by the user. */ + if (s.ports.n) { + struct dpif *dpif; + const char *port; + size_t i; + + error = dpif_create_and_open(s.dp_name, &dpif); + if (error) { + ovs_fatal(error, "could not create datapath"); + } + + 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); + } + } + dpif_close(dpif); + } + /* Start OpenFlow processing. */ error = ofproto_create(s.dp_name, NULL, NULL, &ofproto); if (error) { @@ -155,6 +177,12 @@ main(int argc, char *argv[]) ofproto_set_mgmt_id(ofproto, s.mgmt_id); } ofproto_set_desc(ofproto, s.mfr_desc, s.hw_desc, s.sw_desc, s.serial_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"); @@ -164,7 +192,9 @@ main(int argc, char *argv[]) ovs_fatal(error, "failed to configure controller snooping connections"); } - 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"); } @@ -195,10 +225,12 @@ main(int argc, char *argv[]) } unixctl_server_run(unixctl); dp_run(); + netdev_run(); ofproto_wait(ofproto); unixctl_server_wait(unixctl); dp_wait(); + netdev_wait(); poll_block(); } @@ -235,6 +267,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) OPT_COMMAND_DIR, OPT_NETFLOW, OPT_MGMT_ID, + OPT_PORTS, VLOG_OPTION_ENUMS, LEAK_CHECKER_OPTION_ENUMS }; @@ -264,6 +297,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) {"command-dir", required_argument, 0, OPT_COMMAND_DIR}, {"netflow", required_argument, 0, OPT_NETFLOW}, {"mgmt-id", required_argument, 0, OPT_MGMT_ID}, + {"ports", required_argument, 0, OPT_PORTS}, {"verbose", optional_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, @@ -289,7 +323,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->fail_mode = FAIL_OPEN; s->max_idle = 0; s->probe_interval = 0; - s->max_backoff = 15; + s->max_backoff = 8; s->update_resolv_conf = true; s->rate_limit = 0; s->burst_limit = 0; @@ -300,6 +334,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->command_dir = NULL; svec_init(&s->netflow); s->mgmt_id = 0; + svec_init(&s->ports); for (;;) { int c; @@ -310,10 +345,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s) switch (c) { case OPT_DATAPATH_ID: - if (strlen(optarg) != 12 - || strspn(optarg, "0123456789abcdefABCDEF") != 12) { + if (strlen(optarg) != 16 + || strspn(optarg, "0123456789abcdefABCDEF") != 16) { ovs_fatal(0, "argument to --datapath-id must be " - "exactly 12 hex digits"); + "exactly 16 hex digits"); } s->datapath_id = strtoll(optarg, NULL, 16); if (!s->datapath_id) { @@ -351,8 +386,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) } else if (!strcmp(optarg, "closed")) { s->fail_mode = FAIL_CLOSED; } else { - ovs_fatal(0, "-f or --fail argument must be \"open\" " - "or \"closed\""); + ovs_fatal(0, "--fail argument must be \"open\" or \"closed\""); } break; @@ -433,10 +467,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s) break; case OPT_MGMT_ID: - if (strlen(optarg) != 12 - || strspn(optarg, "0123456789abcdefABCDEF") != 12) { + if (strlen(optarg) != 16 + || strspn(optarg, "0123456789abcdefABCDEF") != 16) { ovs_fatal(0, "argument to --mgmt-id must be " - "exactly 12 hex digits"); + "exactly 16 hex digits"); } s->mgmt_id = strtoll(optarg, NULL, 16); if (!s->mgmt_id) { @@ -452,6 +486,10 @@ parse_options(int argc, char *argv[], struct ofsettings *s) svec_add(&s->snoops, optarg); break; + case OPT_PORTS: + svec_split(&s->ports, optarg, ","); + break; + case 'h': usage(); @@ -523,9 +561,9 @@ usage(void) 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" + " (ID must consist of 16 hex digits)\n" " --mgmt-id=ID Use ID as the management ID\n" - " (ID must consist of 12 hex digits)\n" + " (ID must consist of 16 hex digits)\n" " --manufacturer=MFR Identify manufacturer as MFR\n" " --hardware=HW Identify hardware as HW\n" " --software=SW Identify software as SW\n" @@ -540,7 +578,7 @@ usage(void) " --inactivity-probe=SECS time between inactivity probes\n" " --max-idle=SECS max idle for flows set up by switch\n" " --max-backoff=SECS max time between controller connection\n" - " attempts (default: 15 seconds)\n" + " attempts (default: 8 seconds)\n" " -l, --listen=METHOD allow management connections on METHOD\n" " (a passive OpenFlow connection method)\n" " --snoop=METHOD allow controller snooping on METHOD\n"