[ovs-dev] [RFC 1/2] dpdk: allow init to fail

Aaron Conole aconole at redhat.com
Thu Apr 5 21:22:53 UTC 2018


It's possible for dpdk initialization to fail either due to an internal
error or an invalid configuration.  When that happens, it's rather
impolite to immediately abort.  Worse, any respawn mechanism will be
contsantly restarting the ovs-vswitchd process only to have an ovs-assert
be hit.

With this change, a failed dpdk initialization attempt will no longer
trigger a SIGABRT.  Instead, the failure will be logged, and OvS will
continue to operate sans dpdk.  A restart of OvS would still be required
to re-attempt initialization.

Signed-off-by: Aaron Conole <aconole at redhat.com>
---
 lib/dpdk.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/dpdk.c b/lib/dpdk.c
index 00dd97470..876ba01f1 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -22,6 +22,7 @@
 #include <sys/stat.h>
 #include <getopt.h>
 
+#include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_memzone.h>
 #include <rte_version.h>
@@ -306,7 +307,7 @@ static cookie_io_functions_t dpdk_log_func = {
     .write = dpdk_log_write,
 };
 
-static void
+static bool
 dpdk_init__(const struct smap *ovs_other_config)
 {
     char **argv = NULL, **argv_to_release = NULL;
@@ -422,10 +423,11 @@ dpdk_init__(const struct smap *ovs_other_config)
 
     /* Make sure things are initialized ... */
     result = rte_eal_init(argc, argv);
+    argv_release(argv, argv_to_release, argc);
     if (result < 0) {
-        ovs_abort(result, "Cannot init EAL");
+        VLOG_EMER("Unable to initialize DPDK: %s", ovs_strerror(rte_errno));
+        return false;
     }
-    argv_release(argv, argv_to_release, argc);
 
     /* Set the main thread affinity back to pre rte_eal_init() value */
     if (auto_determine && !err) {
@@ -459,6 +461,7 @@ dpdk_init__(const struct smap *ovs_other_config)
 
     /* Finally, register the dpdk classes */
     netdev_dpdk_register();
+    return true;
 }
 
 void
@@ -476,10 +479,13 @@ dpdk_init(const struct smap *ovs_other_config)
         if (ovsthread_once_start(&once_enable)) {
             VLOG_INFO("Using %s", rte_version());
             VLOG_INFO("DPDK Enabled - initializing...");
-            dpdk_init__(ovs_other_config);
-            enabled = true;
-            VLOG_INFO("DPDK Enabled - initialized");
+            enabled = dpdk_init__(ovs_other_config);
+            if (enabled) {
+                VLOG_INFO("DPDK Enabled - initialized");
+            }
             ovsthread_once_done(&once_enable);
+        } else {
+            VLOG_ERR_ONCE("DPDK Initialization Failed.");
         }
     } else {
         VLOG_INFO_ONCE("DPDK Disabled - Use other_config:dpdk-init to enable");
-- 
2.14.3



More information about the dev mailing list