diff options
author | Ben Pfaff <blp@ovn.org> | 2018-08-07 12:40:13 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-08-07 14:38:37 -0700 |
commit | 70c5afb0e58dc09f8446269e78f3438cc1e14262 (patch) | |
tree | f5f0099e14707d87baead855547f7aa550eadb3f /lib | |
parent | 7c98d261fa14e5eedebb3f2cdb72e15f84d61d47 (diff) | |
download | openvswitch-70c5afb0e58dc09f8446269e78f3438cc1e14262.tar.gz |
dns-resolve: Only ask unbound to read /etc/resolv.conf if it exists.
The unbound library complains if we ask it to read /etc/resolv.conf but
that file doesn't exist. It's better to just skip reading it in that case.
Reported-by: Flavio Leitner <fbl@sysclose.org>
Reporetd-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-August/350751.html
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dns-resolve.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/dns-resolve.c b/lib/dns-resolve.c index f1f911296..299ab27ab 100644 --- a/lib/dns-resolve.c +++ b/lib/dns-resolve.c @@ -22,6 +22,7 @@ #include <arpa/nameser.h> #include <errno.h> #include <string.h> +#include <sys/stat.h> #include <unbound.h> #include "hash.h" #include "openvswitch/hmap.h" @@ -81,17 +82,20 @@ dns_resolve_init(bool is_daemon) return; } - int retval; #ifdef __linux__ - retval = ub_ctx_resolvconf(ub_ctx__, "/etc/resolv.conf"); - if (retval != 0) { - VLOG_WARN_RL(&rl, "Failed to read /etc/resolv.conf: %s", - ub_strerror(retval)); + const char *filename = "/etc/resolv.conf"; + struct stat s; + if (!stat(filename, &s) || errno != ENOENT) { + int retval = ub_ctx_resolvconf(ub_ctx__, filename); + if (retval != 0) { + VLOG_WARN_RL(&rl, "Failed to read %s: %s", + filename, ub_strerror(retval)); + } } #endif /* Handles '/etc/hosts' on Linux and 'WINDIR/etc/hosts' on Windows. */ - retval = ub_ctx_hosts(ub_ctx__, NULL); + int retval = ub_ctx_hosts(ub_ctx__, NULL); if (retval != 0) { VLOG_WARN_RL(&rl, "Failed to read etc/hosts: %s", ub_strerror(retval)); |