[ovs-dev] [tests+nxm-ofctl 09/42] ovs-openflowd: Add "exit" unixctl command.
Ben Pfaff
blp at nicira.com
Tue Nov 23 22:43:41 UTC 2010
This is useful for testing.
---
utilities/ovs-openflowd.8.in | 4 ++++
utilities/ovs-openflowd.c | 20 +++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/utilities/ovs-openflowd.8.in b/utilities/ovs-openflowd.8.in
index 7be7027..a449e5b 100644
--- a/utilities/ovs-openflowd.8.in
+++ b/utilities/ovs-openflowd.8.in
@@ -442,6 +442,10 @@ switching.
\fBovs\-appctl\fR(8) can send commands to a running
\fBovs\-openflowd\fR process. The currently supported commands are
described below.
+.SS "OVS\-OPENFLOWD COMMANDS"
+These commands are specific to \fBovs-openflowd\fR.
+.IP "\fBexit\fR"
+Causes \fBovs\-openflowd\fR to gracefully terminate.
.so lib/vlog-unixctl.man
.
.SH "SEE ALSO"
diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c
index da84b25..4e9de06 100644
--- a/utilities/ovs-openflowd.c
+++ b/utilities/ovs-openflowd.c
@@ -82,6 +82,8 @@ struct ofsettings {
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;
@@ -94,6 +96,7 @@ main(int argc, char *argv[])
int error;
struct dpif *dpif;
struct netflow_options nf_options;
+ bool exiting;
proctitle_init(argc, argv);
set_program_name(argv[0]);
@@ -109,6 +112,8 @@ main(int argc, char *argv[])
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);
@@ -156,7 +161,8 @@ main(int argc, char *argv[])
daemonize_complete();
- while (s.run_forever || 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");
@@ -169,6 +175,9 @@ main(int argc, char *argv[])
unixctl_server_wait(unixctl);
dp_wait();
netdev_wait();
+ if (exiting) {
+ poll_immediate_wake();
+ }
poll_block();
}
@@ -176,6 +185,15 @@ main(int argc, char *argv[])
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);
+}
/* User interface. */
--
1.7.1
More information about the dev
mailing list