[ovs-dev,1/2] dns-resolve: Stop dns resolving if no DNS server configured

Message ID 1541627074-16939-1-git-send-email-pkusunyifeng@gmail.com
State Accepted
Headers show
Series
  • [ovs-dev,1/2] dns-resolve: Stop dns resolving if no DNS server configured
Related show

Commit Message

Yifeng Sun Nov. 7, 2018, 9:44 p.m.
DNS resolution should fail if no DNS servers are available. This
patch fixes it.

Suggested-by: Ben Pfaff <blp@ovn.org>
Suggested-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
 lib/dns-resolve.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch

diff --git a/lib/dns-resolve.c b/lib/dns-resolve.c
index 3c6d70e8fbba..7d735749e5a5 100644
--- a/lib/dns-resolve.c
+++ b/lib/dns-resolve.c
@@ -90,7 +90,16 @@  dns_resolve_init(bool is_daemon)
         if (retval != 0) {
             VLOG_WARN_RL(&rl, "Failed to read %s: %s",
                          filename, ub_strerror(retval));
+            ub_ctx_delete(ub_ctx__);
+            ub_ctx__ = NULL;
+            return;
         }
+    } else {
+        VLOG_WARN_RL(&rl, "Failed to read %s: %s",
+                     filename, ovs_strerror(errno));
+        ub_ctx_delete(ub_ctx__);
+        ub_ctx__ = NULL;
+        return;
     }
 #endif