From f8bfdc308beedddd5127201201da278f830df21b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 12 Nov 2010 14:19:23 -0800 Subject: [PATCH] ovs-openflowd: Add ability to run without connecting to controller. This is useful for testing, for which we may want to simply use tools like ovs-ofctl without maintaining an active connection to a remote controller. --- utilities/ovs-openflowd.8.in | 5 +++++ utilities/ovs-openflowd.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/utilities/ovs-openflowd.8.in b/utilities/ovs-openflowd.8.in index 6084d463..7be70273 100644 --- a/utilities/ovs-openflowd.8.in +++ b/utilities/ovs-openflowd.8.in @@ -30,6 +30,11 @@ OpenFlow controller or controllers. Each takes one of the following forms: . .so lib/vconn-active.man +.IP "\fBnone\fR" +Run without actively maintaining a connection to a remote OpenFlow +controller. (See the \fB\-\-listen\fR option, under \fBNetworking +Options\fR below, for another way to make OpenFlow connections to the +switch.) . .PP When multiple controllers are configured, \fBovs\-openflowd\fR diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 5ed32683..d0b90a09 100644 --- 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; + bool run_forever; /* Continue running even with no controller? */ /* Datapath. */ uint64_t datapath_id; /* Datapath ID. */ @@ -155,7 +156,7 @@ main(int argc, char *argv[]) daemonize_complete(); - while (ofproto_is_alive(ofproto)) { + while (s.run_forever || ofproto_is_alive(ofproto)) { error = ofproto_run(ofproto); if (error) { ovs_fatal(error, "unrecoverable datapath error"); @@ -459,12 +460,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. */ + 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++) { - 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"); -- 2.30.2