From 0e17074a1a43edadde14266715c614a8313c6cbb Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Fri, 22 Jan 2010 14:37:05 -0500 Subject: [PATCH] openflowd: Update for changes to dpif and netdev. Openflowd had been a bit neglected as changes were made to the dpif and netdev interfaces over time. This brings it up to date with all the latest changes. --- utilities/ovs-openflowd.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 5e63f1b24..70a74da85 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -62,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. */ @@ -110,6 +111,7 @@ 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); @@ -131,28 +133,32 @@ 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. */ + 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, NULL, &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, NULL, &ofproto); + error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto); if (error) { ovs_fatal(error, "could not initialize openflow switch"); } @@ -226,6 +232,8 @@ main(int argc, char *argv[]) poll_block(); } + dpif_close(dpif); + return 0; } @@ -499,7 +507,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. */ -- 2.43.0