Merge 'master' into 'next'.
[sliver-openvswitch.git] / utilities / ovs-openflowd.c
index f096af1..9a9dffe 100644 (file)
@@ -28,7 +28,6 @@
 #include "compiler.h"
 #include "daemon.h"
 #include "dirs.h"
-#include "dpif.h"
 #include "dummy.h"
 #include "leak-checker.h"
 #include "list.h"
@@ -93,7 +92,6 @@ main(int argc, char *argv[])
     struct ofproto *ofproto;
     struct ofsettings s;
     int error;
-    struct dpif *dpif;
     struct netflow_options nf_options;
     const char *port;
     bool exiting;
@@ -103,7 +101,6 @@ main(int argc, char *argv[])
     parse_options(argc, argv, &s);
     signal(SIGPIPE, SIG_IGN);
 
-    die_if_already_running();
     daemonize_start();
 
     /* Start listening for ovs-appctl requests. */
@@ -117,9 +114,10 @@ main(int argc, char *argv[])
     VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR);
     VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION);
 
-    error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif);
+    error = ofproto_create(s.dp_name, s.dp_type, &ofproto);
     if (error) {
-        ovs_fatal(error, "could not create datapath");
+        VLOG_FATAL("could not initialize OpenFlow switch (%s)",
+                   strerror(error));
     }
 
     /* Add ports to the datapath if requested by the user. */
@@ -128,22 +126,20 @@ main(int argc, char *argv[])
 
         error = netdev_open_default(port, &netdev);
         if (error) {
-            ovs_fatal(error, "%s: failed to open network device", port);
+            VLOG_FATAL("%s: failed to open network device (%s)",
+                       port, strerror(error));
         }
 
-        error = dpif_port_add(dpif, netdev, NULL);
+        error = ofproto_port_add(ofproto, netdev, NULL);
         if (error) {
-            ovs_fatal(error, "failed to add %s as a port", port);
+            VLOG_FATAL("failed to add %s as a port (%s)",
+                       port, strerror(error));
         }
 
         netdev_close(netdev);
     }
 
-    /* Start OpenFlow processing. */
-    error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto);
-    if (error) {
-        ovs_fatal(error, "could not initialize openflow switch");
-    }
+    /* Configure OpenFlow switch. */
     if (s.datapath_id) {
         ofproto_set_datapath_id(ofproto, s.datapath_id);
     }
@@ -151,14 +147,15 @@ main(int argc, char *argv[])
                      s.serial_desc, s.dp_desc);
     error = ofproto_set_snoops(ofproto, &s.snoops);
     if (error) {
-        ovs_fatal(error,
-                  "failed to configure controller snooping connections");
+        VLOG_FATAL("failed to configure controller snooping connections (%s)",
+                   strerror(error));
     }
     memset(&nf_options, 0, sizeof nf_options);
     nf_options.collectors = s.netflow;
     error = ofproto_set_netflow(ofproto, &nf_options);
     if (error) {
-        ovs_fatal(error, "failed to configure NetFlow collectors");
+        VLOG_FATAL("failed to configure NetFlow collectors (%s)",
+                   strerror(error));
     }
     ofproto_set_controllers(ofproto, s.controllers, s.n_controllers);
     ofproto_set_fail_mode(ofproto, s.fail_mode);
@@ -169,15 +166,13 @@ main(int argc, char *argv[])
     while (!exiting && (s.run_forever || ofproto_is_alive(ofproto))) {
         error = ofproto_run(ofproto);
         if (error) {
-            ovs_fatal(error, "unrecoverable datapath error");
+            VLOG_FATAL("unrecoverable datapath error (%s)", strerror(error));
         }
         unixctl_server_run(unixctl);
-        dp_run();
         netdev_run();
 
         ofproto_wait(ofproto);
         unixctl_server_wait(unixctl);
-        dp_wait();
         netdev_wait();
         if (exiting) {
             poll_immediate_wake();
@@ -185,7 +180,7 @@ main(int argc, char *argv[])
         poll_block();
     }
 
-    dpif_close(dpif);
+    ofproto_destroy(ofproto);
 
     return 0;
 }
@@ -274,10 +269,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         DAEMON_LONG_OPTIONS,
         VLOG_LONG_OPTIONS,
         LEAK_CHECKER_LONG_OPTIONS,
-#ifdef HAVE_OPENSSL
-        STREAM_SSL_LONG_OPTIONS
+        STREAM_SSL_LONG_OPTIONS,
         {"bootstrap-ca-cert", required_argument, 0, OPT_BOOTSTRAP_CA_CERT},
-#endif
         {0, 0, 0, 0},
     };
     char *short_options = long_options_to_short_options(long_options);
@@ -317,8 +310,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         switch (c) {
         case OPT_DATAPATH_ID:
             if (!dpid_from_string(optarg, &s->datapath_id)) {
-                ovs_fatal(0, "argument to --datapath-id must be "
-                          "exactly 16 hex digits and may not be all-zero");
+                VLOG_FATAL("argument to --datapath-id must be exactly 16 hex "
+                           "digits and may not be all-zero");
             }
             break;
 
@@ -349,15 +342,15 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
                        || !strcmp(optarg, "secure")) {
                 s->fail_mode = OFPROTO_FAIL_SECURE;
             } else {
-                ovs_fatal(0, "--fail argument must be \"standalone\" "
-                          "or \"secure\"");
+                VLOG_FATAL("--fail argument must be \"standalone\" "
+                           "or \"secure\"");
             }
             break;
 
         case OPT_INACTIVITY_PROBE:
             controller_opts.probe_interval = atoi(optarg);
             if (controller_opts.probe_interval < 5) {
-                ovs_fatal(0, "--inactivity-probe argument must be at least 5");
+                VLOG_FATAL("--inactivity-probe argument must be at least 5");
             }
             break;
 
@@ -367,8 +360,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
             } else {
                 s->max_idle = atoi(optarg);
                 if (s->max_idle < 1 || s->max_idle > 65535) {
-                    ovs_fatal(0, "--max-idle argument must be between 1 and "
-                              "65535 or the word 'permanent'");
+                    VLOG_FATAL("--max-idle argument must be between 1 and "
+                               "65535 or the word 'permanent'");
                 }
             }
             break;
@@ -376,7 +369,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         case OPT_MAX_BACKOFF:
             controller_opts.max_backoff = atoi(optarg);
             if (controller_opts.max_backoff < 1) {
-                ovs_fatal(0, "--max-backoff argument must be at least 1");
+                VLOG_FATAL("--max-backoff argument must be at least 1");
             } else if (controller_opts.max_backoff > 3600) {
                 controller_opts.max_backoff = 3600;
             }
@@ -386,7 +379,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
             if (optarg) {
                 controller_opts.rate_limit = atoi(optarg);
                 if (controller_opts.rate_limit < 1) {
-                    ovs_fatal(0, "--rate-limit argument must be at least 1");
+                    VLOG_FATAL("--rate-limit argument must be at least 1");
                 }
             } else {
                 controller_opts.rate_limit = 1000;
@@ -396,7 +389,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
         case OPT_BURST_LIMIT:
             controller_opts.burst_limit = atoi(optarg);
             if (controller_opts.burst_limit < 1) {
-                ovs_fatal(0, "--burst-limit argument must be at least 1");
+                VLOG_FATAL("--burst-limit argument must be at least 1");
             }
             break;
 
@@ -445,13 +438,11 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
 
         LEAK_CHECKER_OPTION_HANDLERS
 
-#ifdef HAVE_OPENSSL
         STREAM_SSL_OPTION_HANDLERS
 
         case OPT_BOOTSTRAP_CA_CERT:
             stream_ssl_set_ca_cert_file(optarg, true);
             break;
-#endif
 
         case '?':
             exit(EXIT_FAILURE);
@@ -465,8 +456,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
     argc -= optind;
     argv += optind;
     if (argc < 2) {
-        ovs_fatal(0, "need at least two non-option arguments; "
-                  "use --help for usage");
+        VLOG_FATAL("need at least two non-option arguments; "
+                   "use --help for usage");
     }
 
     /* Rate limiting. */
@@ -476,7 +467,7 @@ parse_options(int argc, char *argv[], struct ofsettings *s)
     }
 
     /* Local vconns. */
-    dp_parse_name(argv[0], &s->dp_name, &s->dp_type);
+    ofproto_parse_name(argv[0], &s->dp_name, &s->dp_type);
 
     /* Figure out controller names. */
     s->run_forever = false;