projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dpif-linux: Replace 'minor' by 'dp_idx'.
[openvswitch]
/
utilities
/
ovs-openflowd.c
diff --git
a/utilities/ovs-openflowd.c
b/utilities/ovs-openflowd.c
index 5ed32683929bdb443b9fce76be02759855a5f044..0cd919a696f00fdf2143aa71f9b08acf6b35153b 100644
(file)
--- a/
utilities/ovs-openflowd.c
+++ b/
utilities/ovs-openflowd.c
@@
-57,6
+57,7
@@
struct ofsettings {
struct ofproto_controller *controllers;
size_t n_controllers;
enum ofproto_fail_mode fail_mode;
struct ofproto_controller *controllers;
size_t n_controllers;
enum ofproto_fail_mode fail_mode;
+ bool run_forever; /* Continue running even with no controller? */
/* Datapath. */
uint64_t datapath_id; /* Datapath ID. */
/* Datapath. */
uint64_t datapath_id; /* Datapath ID. */
@@
-81,6
+82,8
@@
struct ofsettings {
struct svec netflow; /* NetFlow targets. */
};
struct svec netflow; /* NetFlow targets. */
};
+static unixctl_cb_func ovs_openflowd_exit;
+
static void parse_options(int argc, char *argv[], struct ofsettings *);
static void usage(void) NO_RETURN;
static void parse_options(int argc, char *argv[], struct ofsettings *);
static void usage(void) NO_RETURN;
@@
-93,6
+96,7
@@
main(int argc, char *argv[])
int error;
struct dpif *dpif;
struct netflow_options nf_options;
int error;
struct dpif *dpif;
struct netflow_options nf_options;
+ bool exiting;
proctitle_init(argc, argv);
set_program_name(argv[0]);
proctitle_init(argc, argv);
set_program_name(argv[0]);
@@
-108,6
+112,8
@@
main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
+ unixctl_command_register("exit", ovs_openflowd_exit, &exiting);
+
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
@@
-122,10
+128,19
@@
main(int argc, char *argv[])
size_t i;
SVEC_FOR_EACH (i, port, &s.ports) {
size_t i;
SVEC_FOR_EACH (i, port, &s.ports) {
- error = dpif_port_add(dpif, port, 0, NULL);
+ struct netdev *netdev;
+
+ error = netdev_open_default(port, &netdev);
+ if (error) {
+ ovs_fatal(error, "%s: failed to open network device", port);
+ }
+
+ error = dpif_port_add(dpif, netdev, NULL);
if (error) {
ovs_fatal(error, "failed to add %s as a port", port);
}
if (error) {
ovs_fatal(error, "failed to add %s as a port", port);
}
+
+ netdev_close(netdev);
}
}
}
}
@@
-155,7
+170,8
@@
main(int argc, char *argv[])
daemonize_complete();
daemonize_complete();
- while (ofproto_is_alive(ofproto)) {
+ exiting = false;
+ while (!exiting && (s.run_forever || ofproto_is_alive(ofproto))) {
error = ofproto_run(ofproto);
if (error) {
ovs_fatal(error, "unrecoverable datapath error");
error = ofproto_run(ofproto);
if (error) {
ovs_fatal(error, "unrecoverable datapath error");
@@
-168,6
+184,9
@@
main(int argc, char *argv[])
unixctl_server_wait(unixctl);
dp_wait();
netdev_wait();
unixctl_server_wait(unixctl);
dp_wait();
netdev_wait();
+ if (exiting) {
+ poll_immediate_wake();
+ }
poll_block();
}
poll_block();
}
@@
-175,6
+194,15
@@
main(int argc, char *argv[])
return 0;
}
return 0;
}
+
+static void
+ovs_openflowd_exit(struct unixctl_conn *conn, const char *args OVS_UNUSED,
+ void *exiting_)
+{
+ bool *exiting = exiting_;
+ *exiting = true;
+ unixctl_command_reply(conn, 200, NULL);
+}
\f
/* User interface. */
\f
/* User interface. */
@@
-459,12
+487,17
@@
parse_options(int argc, char *argv[], struct ofsettings *s)
dp_parse_name(argv[0], &s->dp_name, &s->dp_type);
/* Figure out controller names. */
dp_parse_name(argv[0], &s->dp_name, &s->dp_type);
/* Figure out controller names. */
+ s->run_forever = false;
if (!controllers.n) {
svec_add_nocopy(&controllers, xasprintf("punix:%s/%s.mgmt",
ovs_rundir(), s->dp_name));
}
for (i = 1; i < argc; i++) {
if (!controllers.n) {
svec_add_nocopy(&controllers, xasprintf("punix:%s/%s.mgmt",
ovs_rundir(), s->dp_name));
}
for (i = 1; i < argc; i++) {
- svec_add(&controllers, argv[i]);
+ if (!strcmp(argv[i], "none")) {
+ s->run_forever = true;
+ } else {
+ svec_add(&controllers, argv[i]);
+ }
}
if (argc < 2) {
svec_add(&controllers, "discover");
}
if (argc < 2) {
svec_add(&controllers, "discover");