diff options
| author | Ben Pfaff <blp@nicira.com> | 2009-11-23 11:32:08 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2009-11-23 15:58:48 -0800 |
| commit | e3e9370bf9ee0fde67b3d94acf119cec5dc3701d (patch) | |
| tree | b48a56488a326a40e7bda3853c966d0a5a0ba665 /utilities/ovs-openflowd.c | |
| parent | cfae8ec3e7ba9e02d4f994f77ef70435cd3575e5 (diff) | |
| download | openvswitch-e3e9370bf9ee0fde67b3d94acf119cec5dc3701d.tar.gz | |
ovs-openflowd: Add support for userspace-only switching.
Diffstat (limited to 'utilities/ovs-openflowd.c')
| -rw-r--r-- | utilities/ovs-openflowd.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index d6b2c51f3..c275cd6a5 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. */ @@ -135,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) { @@ -246,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 }; @@ -275,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'}, @@ -311,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; @@ -462,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(); |
