diff mbox series

[ovs-dev,v1,1/1] dns-resolve: Allow unbound's config file to be set through an env var.

Message ID 20200928185427.88168-2-ted.elhourani@nutanix.com
State Changes Requested
Headers show
Series dns-resolve: Allow unbound's config file to be set through an env var. | expand

Commit Message

Ted Elhourani Sept. 28, 2020, 6:54 p.m. UTC
When an unbound context is created, check whether OVS_UNBOUND_CONF has been
set. If a valid config file is supplied then use it to configure the
context. The procedure returns if the config file is invalid. If no config
file is found then the default unbound config is used.

Signed-off-by: Ted Elhourani <ted.elhourani@nutanix.com>
---
 Documentation/intro/install/general.rst |  4 +++-
 lib/dns-resolve.c                       | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

Comments

Yifeng Sun Sept. 28, 2020, 8:38 p.m. UTC | #1
Looks good to me, thanks.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>


On Mon, Sep 28, 2020 at 11:54 AM Ted Elhourani <ted.elhourani@nutanix.com>
wrote:

> When an unbound context is created, check whether OVS_UNBOUND_CONF has been
> set. If a valid config file is supplied then use it to configure the
> context. The procedure returns if the config file is invalid. If no config
> file is found then the default unbound config is used.
>
> Signed-off-by: Ted Elhourani <ted.elhourani@nutanix.com>
> ---
>  Documentation/intro/install/general.rst |  4 +++-
>  lib/dns-resolve.c                       | 12 ++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/intro/install/general.rst
> b/Documentation/intro/install/general.rst
> index 09f2c13f1..c4300cd53 100644
> --- a/Documentation/intro/install/general.rst
> +++ b/Documentation/intro/install/general.rst
> @@ -97,7 +97,9 @@ need the following software:
>    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).
> +  configuration file (the default file on Linux is /etc/resolv.conf), and
> +  environment variable OVS_UNBOUND_CONF can be used to specify the
> +  configuration file for unbound.
>
>  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/lib/dns-resolve.c b/lib/dns-resolve.c
> index 1ff58960f..d34451434 100644
> --- a/lib/dns-resolve.c
> +++ b/lib/dns-resolve.c
> @@ -82,6 +82,18 @@ dns_resolve_init(bool is_daemon)
>          return;
>      }
>
> +    const char *ub_conf_filename = getenv("OVS_UNBOUND_CONF");
> +    if (ub_conf_filename != NULL) {
> +        int retval = ub_ctx_config(ub_ctx__, ub_conf_filename);
> +        if (retval != 0) {
> +            VLOG_WARN_RL(&rl, "Failed to set libunbound context config:
> %s",
> +                         ub_strerror(retval));
> +            ub_ctx_delete(ub_ctx__);
> +            ub_ctx__ = NULL;
> +            return;
> +        }
> +    }
> +
>      const char *filename = getenv("OVS_RESOLV_CONF");
>      if (!filename) {
>  #ifdef _WIN32
> --
> 2.22.3
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ted Elhourani Oct. 5, 2020, 8:11 p.m. UTC | #2
Thanks Yifeng,

Not sure how to move this forward. Ben?

Thanks,
Ted

From: Yifeng Sun <pkusunyifeng@gmail.com>
Date: Monday, September 28, 2020 at 1:39 PM
To: Ted Elhourani <ted.elhourani@nutanix.com>
Cc: ovs dev <dev@openvswitch.org>
Subject: Re: [ovs-dev] [PATCH v1 1/1] dns-resolve: Allow unbound's config file to be set through an env var.

Looks good to me, thanks.


Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com<mailto:pkusunyifeng@gmail.com>>


On Mon, Sep 28, 2020 at 11:54 AM Ted Elhourani <ted.elhourani@nutanix.com<mailto:ted.elhourani@nutanix.com>> wrote:
When an unbound context is created, check whether OVS_UNBOUND_CONF has been
set. If a valid config file is supplied then use it to configure the
context. The procedure returns if the config file is invalid. If no config
file is found then the default unbound config is used.

Signed-off-by: Ted Elhourani <ted.elhourani@nutanix.com<mailto:ted.elhourani@nutanix.com>>
---
 Documentation/intro/install/general.rst |  4 +++-
 lib/dns-resolve.c                       | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 09f2c13f1..c4300cd53 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -97,7 +97,9 @@ need the following software:
   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).
+  configuration file (the default file on Linux is /etc/resolv.conf), and
+  environment variable OVS_UNBOUND_CONF can be used to specify the
+  configuration file for unbound.

 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/lib/dns-resolve.c b/lib/dns-resolve.c
index 1ff58960f..d34451434 100644
--- a/lib/dns-resolve.c
+++ b/lib/dns-resolve.c
@@ -82,6 +82,18 @@ dns_resolve_init(bool is_daemon)
         return;
     }

+    const char *ub_conf_filename = getenv("OVS_UNBOUND_CONF");
+    if (ub_conf_filename != NULL) {
+        int retval = ub_ctx_config(ub_ctx__, ub_conf_filename);
+        if (retval != 0) {
+            VLOG_WARN_RL(&rl, "Failed to set libunbound context config: %s",
+                         ub_strerror(retval));
+            ub_ctx_delete(ub_ctx__);
+            ub_ctx__ = NULL;
+            return;
+        }
+    }
+
     const char *filename = getenv("OVS_RESOLV_CONF");
     if (!filename) {
 #ifdef _WIN32
--
2.22.3
Ilya Maximets Oct. 5, 2020, 10:11 p.m. UTC | #3
On 9/28/20 8:54 PM, Ted Elhourani wrote:
> When an unbound context is created, check whether OVS_UNBOUND_CONF has been
> set. If a valid config file is supplied then use it to configure the
> context. The procedure returns if the config file is invalid. If no config
> file is found then the default unbound config is used.
> 
> Signed-off-by: Ted Elhourani <ted.elhourani@nutanix.com>
> ---

Hi.

Since this is a user-visible change, could you, please, add an entry
to the NEWS file?

Best regards, Ilya Maximets.

>  Documentation/intro/install/general.rst |  4 +++-
>  lib/dns-resolve.c                       | 12 ++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
> index 09f2c13f1..c4300cd53 100644
> --- a/Documentation/intro/install/general.rst
> +++ b/Documentation/intro/install/general.rst
> @@ -97,7 +97,9 @@ need the following software:
>    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).
> +  configuration file (the default file on Linux is /etc/resolv.conf), and
> +  environment variable OVS_UNBOUND_CONF can be used to specify the
> +  configuration file for unbound.
>  
>  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/lib/dns-resolve.c b/lib/dns-resolve.c
> index 1ff58960f..d34451434 100644
> --- a/lib/dns-resolve.c
> +++ b/lib/dns-resolve.c
> @@ -82,6 +82,18 @@ dns_resolve_init(bool is_daemon)
>          return;
>      }
>  
> +    const char *ub_conf_filename = getenv("OVS_UNBOUND_CONF");
> +    if (ub_conf_filename != NULL) {
> +        int retval = ub_ctx_config(ub_ctx__, ub_conf_filename);
> +        if (retval != 0) {
> +            VLOG_WARN_RL(&rl, "Failed to set libunbound context config: %s",
> +                         ub_strerror(retval));
> +            ub_ctx_delete(ub_ctx__);
> +            ub_ctx__ = NULL;
> +            return;
> +        }
> +    }
> +
>      const char *filename = getenv("OVS_RESOLV_CONF");
>      if (!filename) {
>  #ifdef _WIN32
>
diff mbox series

Patch

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 09f2c13f1..c4300cd53 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -97,7 +97,9 @@  need the following software:
   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).
+  configuration file (the default file on Linux is /etc/resolv.conf), and
+  environment variable OVS_UNBOUND_CONF can be used to specify the
+  configuration file for unbound.
 
 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/lib/dns-resolve.c b/lib/dns-resolve.c
index 1ff58960f..d34451434 100644
--- a/lib/dns-resolve.c
+++ b/lib/dns-resolve.c
@@ -82,6 +82,18 @@  dns_resolve_init(bool is_daemon)
         return;
     }
 
+    const char *ub_conf_filename = getenv("OVS_UNBOUND_CONF");
+    if (ub_conf_filename != NULL) {
+        int retval = ub_ctx_config(ub_ctx__, ub_conf_filename);
+        if (retval != 0) {
+            VLOG_WARN_RL(&rl, "Failed to set libunbound context config: %s",
+                         ub_strerror(retval));
+            ub_ctx_delete(ub_ctx__);
+            ub_ctx__ = NULL;
+            return;
+        }
+    }
+
     const char *filename = getenv("OVS_RESOLV_CONF");
     if (!filename) {
 #ifdef _WIN32