ovs-openflowd: Add ability to run without connecting to controller.
authorBen Pfaff <blp@nicira.com>
Fri, 12 Nov 2010 22:19:23 +0000 (14:19 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 30 Nov 2010 00:29:11 +0000 (16:29 -0800)
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
utilities/ovs-openflowd.c

index 6084d46..7be7027 100644 (file)
@@ -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
index 5ed3268..d0b90a0 100644 (file)
@@ -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");