mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
dns-resolve: Improve on handling of system DNS nameserver
This patch enables OVS on windows to read system nameserver configuration. In addition, a new environment variable OVS_RESOLV_CONF is introduced. If set, it can be used as DNS server configuration file. This variable is supposed to be used for sandboxing other things. It is documented accordingly. Suggested-by: Ben Pfaff <blp@ovn.org> Suggested-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
ba8eb43a07
commit
9ce4aa8ee7
@ -97,6 +97,8 @@ need the following software:
|
||||
you want to enable ovs-vswitchd and other utilities to use DNS names when
|
||||
specifying OpenFlow and OVSDB remotes. If unbound library is already
|
||||
installed, then Open vSwitch will automatically build with support for it.
|
||||
The environment variable OVS_RESOLV_CONF can be used to specify DNS server
|
||||
configuration file (the default file on Linux is /etc/resolv.conf).
|
||||
|
||||
On Linux, you may choose to compile the kernel module that comes with the Open
|
||||
vSwitch distribution or to use the kernel module built into the Linux kernel
|
||||
|
2
NEWS
2
NEWS
@ -16,6 +16,8 @@ Post-v2.10.0
|
||||
- ovs-vswitchd:
|
||||
* New configuration option "offload-rebalance", that enables dynamic
|
||||
rebalancing of offloaded flows.
|
||||
- The environment variable OVS_RESOLV_CONF, if set, is now used
|
||||
as the DNS server configuration file.
|
||||
|
||||
v2.10.0 - 18 Aug 2018
|
||||
---------------------
|
||||
|
@ -82,14 +82,21 @@ dns_resolve_init(bool is_daemon)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
const char *filename = "/etc/resolv.conf";
|
||||
const char *filename = getenv("OVS_RESOLV_CONF");
|
||||
if (!filename) {
|
||||
#ifdef _WIN32
|
||||
/* On Windows, NULL means to use the system default nameserver. */
|
||||
#else
|
||||
filename = "/etc/resolv.conf";
|
||||
#endif
|
||||
}
|
||||
struct stat s;
|
||||
if (!stat(filename, &s) || errno != ENOENT) {
|
||||
if (!filename || !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));
|
||||
filename ? filename : "system default nameserver",
|
||||
ub_strerror(retval));
|
||||
ub_ctx_delete(ub_ctx__);
|
||||
ub_ctx__ = NULL;
|
||||
return;
|
||||
@ -101,7 +108,6 @@ dns_resolve_init(bool is_daemon)
|
||||
ub_ctx__ = NULL;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Handles '/etc/hosts' on Linux and 'WINDIR/etc/hosts' on Windows. */
|
||||
int retval = ub_ctx_hosts(ub_ctx__, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user