X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-openflowd.c;h=1b8e7ebdffcfb37fffcb412b36fc2e3ec9d12f67;hb=b123cc3ce4972378a5e564a89b8945473f561578;hp=8307891ad44a859eb95a61cb4ef708c7d71e7343;hpb=fe55ad159d8fd396a9e4914a03eea93d096d03b1;p=openvswitch diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 8307891a..1b8e7ebd 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -29,7 +29,6 @@ #include "daemon.h" #include "dirs.h" #include "dpif.h" -#include "fault.h" #include "leak-checker.h" #include "list.h" #include "netdev.h" @@ -63,7 +62,8 @@ struct ofsettings { /* Datapath. */ uint64_t datapath_id; /* Datapath ID. */ - const char *dp_name; /* Name of local datapath. */ + char *dp_name; /* Name of local datapath. */ + char *dp_type; /* Type of local datapath. */ struct svec ports; /* Set of ports to add to datapath (if any). */ /* Description strings. */ @@ -94,9 +94,6 @@ struct ofsettings { /* Spanning tree protocol. */ bool enable_stp; - /* Management. */ - uint64_t mgmt_id; /* Management ID. */ - /* NetFlow. */ struct svec netflow; /* NetFlow targets. */ }; @@ -111,10 +108,11 @@ main(int argc, char *argv[]) struct ofproto *ofproto; struct ofsettings s; int error; + struct dpif *dpif; struct netflow_options nf_options; + proctitle_init(argc, argv); set_program_name(argv[0]); - register_fault_handlers(); time_init(); vlog_init(); parse_options(argc, argv, &s); @@ -126,34 +124,38 @@ main(int argc, char *argv[]) /* Start listening for ovs-appctl requests. */ error = unixctl_server_create(NULL, &unixctl); if (error) { - ovs_fatal(error, "Could not listen for unixctl connections"); + exit(EXIT_FAILURE); } 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. */ + error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif); + if (error) { + ovs_fatal(error, "could not create datapath"); + } + + /* Add ports to the datapath 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"); - } + struct netdev *netdev; 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 = 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); + error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto); if (error) { ovs_fatal(error, "could not initialize openflow switch"); } @@ -169,9 +171,6 @@ 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); if (!s.listeners.n) { svec_add_nocopy(&s.listeners, xasprintf("punix:%s/%s.mgmt", @@ -227,6 +226,8 @@ main(int argc, char *argv[]) poll_block(); } + dpif_close(dpif); + return 0; } @@ -285,7 +286,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s) {"out-of-band", no_argument, 0, OPT_OUT_OF_BAND}, {"in-band", no_argument, 0, OPT_IN_BAND}, {"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'}, @@ -320,7 +320,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s) s->enable_stp = false; s->in_band = true; svec_init(&s->netflow); - s->mgmt_id = 0; svec_init(&s->ports); for (;;) { int c; @@ -334,7 +333,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s) case OPT_DATAPATH_ID: if (!dpid_from_string(optarg, &s->datapath_id)) { ovs_fatal(0, "argument to --datapath-id must be " - "exactly 12 hex digits and may not be all-zero"); + "exactly 16 hex digits and may not be all-zero"); } break; @@ -438,18 +437,6 @@ parse_options(int argc, char *argv[], struct ofsettings *s) svec_add(&s->netflow, optarg); break; - case OPT_MGMT_ID: - if (strlen(optarg) != 12 - || strspn(optarg, "0123456789abcdefABCDEF") != 12) { - ovs_fatal(0, "argument to --mgmt-id must be " - "exactly 12 hex digits"); - } - s->mgmt_id = strtoll(optarg, NULL, 16); - if (!s->mgmt_id) { - ovs_fatal(0, "argument to --mgmt-id must be nonzero"); - } - break; - case 'l': svec_add(&s->listeners, optarg); break; @@ -500,7 +487,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s) } /* Local and remote vconns. */ - s->dp_name = argv[0]; + dp_parse_name(argv[0], &s->dp_name, &s->dp_type); + s->controller_name = argc > 1 ? xstrdup(argv[1]) : NULL; /* Set accept_controller_regex. */ @@ -533,9 +521,7 @@ 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" - " --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"