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 <[email protected]> Suggested-by: Mark Michelson <[email protected]> Signed-off-by: Yifeng Sun <[email protected]> --- Documentation/intro/install/general.rst | 2 ++ NEWS | 2 ++ lib/dns-resolve.c | 16 +++++++++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst index 537137ef58df..71dfeaefca27 100644 --- a/Documentation/intro/install/general.rst +++ b/Documentation/intro/install/general.rst @@ -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 diff --git a/NEWS b/NEWS index fc8ab05def4a..8eba5a38fafc 100644 --- a/NEWS +++ b/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 --------------------- diff --git a/lib/dns-resolve.c b/lib/dns-resolve.c index 7d735749e5a5..3e4e57b9379a 100644 --- a/lib/dns-resolve.c +++ b/lib/dns-resolve.c @@ -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); -- 2.7.4 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
