linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFS use kernel DNS resolver
@ 2010-08-04 20:46 Bryan Schumaker
  2010-08-05  1:09 ` Trond Myklebust
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Bryan Schumaker @ 2010-08-04 20:46 UTC (permalink / raw)
  To: linux-nfs

Use the kernel DNS resolver to translate hostnames to IP addresses.
Create a new config option to choose between the legacy DNS resolver and the
new resolver.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index a43d07e..b1209ac 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -100,3 +100,19 @@ config NFS_FSCACHE
 	help
 	  Say Y here if you want NFS data to be cached locally on disc through
 	  the general filesystem cache manager
+
+config NFS_USE_LEGACY_DNS
+	bool "Use the legacy NFS DNS resolver"
+	depends on NFS_FS
+	help
+	  The kernel now provides a method for translating a host name into an
+	  IP address.  Select Y here if you would rather use your own DNS
+	  resolver script.
+
+	  If unsure, say N
+
+config NFS_USE_KERNEL_DNS
+	bool
+	depends on NFS_FS && !NFS_USE_LEGACY_DNS
+	select DNS_RESOLVER
+	default y
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index da7fda6..ec8989c 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_NFS_FS) += nfs.o
 nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
 			   direct.o pagelist.o proc.o read.o symlink.o unlink.o \
 			   write.o namespace.o mount_clnt.o \
-			   dns_resolve.o cache_lib.o
+			   dns_resolve.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
 nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
@@ -15,5 +15,6 @@ nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   delegation.o idmap.o \
 			   callback.o callback_xdr.o callback_proc.o \
 			   nfs4namespace.o
+nfs-$(CONFIG_NFS_LEGACY_DNS) += cache_lib.o
 nfs-$(CONFIG_SYSCTL) += sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 76fd235..a67e2a4 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -6,6 +6,28 @@
  * Resolves DNS hostnames into valid ip addresses
  */

+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/dns_resolver.h>
+
+ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
+		struct sockaddr *sa, size_t salen)
+{
+	ssize_t ret;
+	char *ip_addr = NULL;
+	int ip_len;
+
+	ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
+	if (ip_len > 0)
+		ret = rpc_pton(ip_addr, ip_len, sa, salen);
+	else
+		ret = -ESRCH;
+	kfree(ip_addr);
+	return ret;
+}
+#else
+
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
@@ -346,3 +368,4 @@ void nfs_dns_resolver_destroy(void)
 	nfs_cache_unregister(&nfs_dns_resolve);
 }

+#endif
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index a3f0938..fe5c3b3 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -6,8 +6,21 @@

 #define NFS_DNS_HOSTNAME_MAXLEN	(128)

+
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+static inline int nfs_dns_resolver_init(void)
+{
+	return 0;
+}
+
+static inline void nfs_dns_resolver_destroy(void)
+{
+}
+#else
 extern int nfs_dns_resolver_init(void);
 extern void nfs_dns_resolver_destroy(void);
+#endif
+
 extern ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
 		struct sockaddr *sa, size_t salen);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
  2010-08-04 20:46 [PATCH] NFS use " Bryan Schumaker
@ 2010-08-05  1:09 ` Trond Myklebust
       [not found] ` <1280970596.2865.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
  2010-08-06 20:53 ` David Howells
  2 siblings, 0 replies; 9+ messages in thread
From: Trond Myklebust @ 2010-08-05  1:09 UTC (permalink / raw)
  To: Bryan Schumaker, David Howells; +Cc: linux-nfs

On Wed, 2010-08-04 at 16:46 -0400, Bryan Schumaker wrote:
> Use the kernel DNS resolver to translate hostnames to IP addresses.
> Create a new config option to choose between the legacy DNS resolver and the
> new resolver.
> 
> Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---


This looks good to me, and it makes sense to share as much code with
CIFS and AFS as we can, now that the objections I had to the original
implementation have been resolved.

David, can you carry this as part of your 'generic DNS resolver'
patchset?

Cheers
  Trond

> diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
> index a43d07e..b1209ac 100644
> --- a/fs/nfs/Kconfig
> +++ b/fs/nfs/Kconfig
> @@ -100,3 +100,19 @@ config NFS_FSCACHE
>  	help
>  	  Say Y here if you want NFS data to be cached locally on disc through
>  	  the general filesystem cache manager
> +
> +config NFS_USE_LEGACY_DNS
> +	bool "Use the legacy NFS DNS resolver"
> +	depends on NFS_FS
> +	help
> +	  The kernel now provides a method for translating a host name into an
> +	  IP address.  Select Y here if you would rather use your own DNS
> +	  resolver script.
> +
> +	  If unsure, say N
> +
> +config NFS_USE_KERNEL_DNS
> +	bool
> +	depends on NFS_FS && !NFS_USE_LEGACY_DNS
> +	select DNS_RESOLVER
> +	default y
> diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
> index da7fda6..ec8989c 100644
> --- a/fs/nfs/Makefile
> +++ b/fs/nfs/Makefile
> @@ -7,7 +7,7 @@ obj-$(CONFIG_NFS_FS) += nfs.o
>  nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
>  			   direct.o pagelist.o proc.o read.o symlink.o unlink.o \
>  			   write.o namespace.o mount_clnt.o \
> -			   dns_resolve.o cache_lib.o
> +			   dns_resolve.o
>  nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
>  nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
>  nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
> @@ -15,5 +15,6 @@ nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
>  			   delegation.o idmap.o \
>  			   callback.o callback_xdr.o callback_proc.o \
>  			   nfs4namespace.o
> +nfs-$(CONFIG_NFS_LEGACY_DNS) += cache_lib.o
>  nfs-$(CONFIG_SYSCTL) += sysctl.o
>  nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
> diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
> index 76fd235..a67e2a4 100644
> --- a/fs/nfs/dns_resolve.c
> +++ b/fs/nfs/dns_resolve.c
> @@ -6,6 +6,28 @@
>   * Resolves DNS hostnames into valid ip addresses
>   */
> 
> +#ifdef CONFIG_NFS_USE_KERNEL_DNS
> +
> +#include <linux/sunrpc/clnt.h>
> +#include <linux/dns_resolver.h>
> +
> +ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
> +		struct sockaddr *sa, size_t salen)
> +{
> +	ssize_t ret;
> +	char *ip_addr = NULL;
> +	int ip_len;
> +
> +	ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
> +	if (ip_len > 0)
> +		ret = rpc_pton(ip_addr, ip_len, sa, salen);
> +	else
> +		ret = -ESRCH;
> +	kfree(ip_addr);
> +	return ret;
> +}
> +#else
> +
>  #include <linux/hash.h>
>  #include <linux/string.h>
>  #include <linux/kmod.h>
> @@ -346,3 +368,4 @@ void nfs_dns_resolver_destroy(void)
>  	nfs_cache_unregister(&nfs_dns_resolve);
>  }
> 
> +#endif
> diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
> index a3f0938..fe5c3b3 100644
> --- a/fs/nfs/dns_resolve.h
> +++ b/fs/nfs/dns_resolve.h
> @@ -6,8 +6,21 @@
> 
>  #define NFS_DNS_HOSTNAME_MAXLEN	(128)
> 
> +
> +#ifdef CONFIG_NFS_USE_KERNEL_DNS
> +static inline int nfs_dns_resolver_init(void)
> +{
> +	return 0;
> +}
> +
> +static inline void nfs_dns_resolver_destroy(void)
> +{
> +}
> +#else
>  extern int nfs_dns_resolver_init(void);
>  extern void nfs_dns_resolver_destroy(void);
> +#endif
> +
>  extern ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
>  		struct sockaddr *sa, size_t salen);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
       [not found] ` <1280970596.2865.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
@ 2010-08-06  2:05   ` David Howells
  2010-08-06 18:29     ` Bryan Schumaker
  2010-08-06 21:00     ` David Howells
  0 siblings, 2 replies; 9+ messages in thread
From: David Howells @ 2010-08-06  2:05 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: dhowells, Bryan Schumaker, linux-nfs

Trond Myklebust <Trond.Myklebust@netapp.com> wrote:

> David, can you carry this as part of your 'generic DNS resolver'
> patchset?

Probably.  Can you send me a copy of the patch?

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
  2010-08-06  2:05   ` David Howells
@ 2010-08-06 18:29     ` Bryan Schumaker
  2010-08-06 21:00     ` David Howells
  1 sibling, 0 replies; 9+ messages in thread
From: Bryan Schumaker @ 2010-08-06 18:29 UTC (permalink / raw)
  To: David Howells; +Cc: Trond Myklebust, linux-nfs

The patch is below.  Thanks!

Bryan




Use the kernel DNS resolver to translate hostnames to IP addresses.
Create a new config option to choose between the legacy DNS resolver and the
new resolver.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index a43d07e..10eebc5 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -100,3 +100,19 @@ config NFS_FSCACHE
 	help
 	  Say Y here if you want NFS data to be cached locally on disc through
 	  the general filesystem cache manager
+
+config NFS_USE_LEGACY_DNS
+	bool "Use the legacy NFS DNS resolver"
+	depends on NFS_V4
+	help
+	  The kernel now provides a method for translating a host name into an
+	  IP address.  Select Y here if you would rather use your own DNS
+	  resolver script.
+
+	  If unsure, say N
+
+config NFS_USE_KERNEL_DNS
+	bool
+	depends on NFS_V4 && !NFS_USE_LEGACY_DNS
+	select DNS_RESOLVER
+	default y
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 76fd235..7e5d3a9 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -6,6 +6,37 @@
  * Resolves DNS hostnames into valid ip addresses
  */

+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/dns_resolver.h>
+
+ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
+		struct sockaddr *sa, size_t salen)
+{
+	ssize_t ret;
+	char *ip_addr = NULL;
+	int ip_len;
+
+	ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
+	if (ip_len > 0)
+		ret = rpc_pton(ip_addr, ip_len, sa, salen);
+	else
+		ret = -ESRCH;
+	kfree(ip_addr);
+	return ret;
+}
+
+inline int nfs_dns_resolver_init(void)
+{
+	return 0;
+}
+
+inline void nfs_dns_resolver_destroy(void)
+{}
+
+#else
+
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
@@ -346,3 +377,4 @@ void nfs_dns_resolver_destroy(void)
 	nfs_cache_unregister(&nfs_dns_resolve);
 }

+#endif
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index a3f0938..199bb55 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -6,8 +6,20 @@

 #define NFS_DNS_HOSTNAME_MAXLEN	(128)

+
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+static inline int nfs_dns_resolver_init(void)
+{
+	return 0;
+}
+
+static inline void nfs_dns_resolver_destroy(void)
+{}
+#else
 extern int nfs_dns_resolver_init(void);
 extern void nfs_dns_resolver_destroy(void);
+#endif
+
 extern ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
 		struct sockaddr *sa, size_t salen);



On 08/05/2010 10:05 PM, David Howells wrote:
> Trond Myklebust <Trond.Myklebust@netapp.com> wrote:
> 
>> David, can you carry this as part of your 'generic DNS resolver'
>> patchset?
> 
> Probably.  Can you send me a copy of the patch?
> 
> David


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
  2010-08-04 20:46 [PATCH] NFS use " Bryan Schumaker
  2010-08-05  1:09 ` Trond Myklebust
       [not found] ` <1280970596.2865.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
@ 2010-08-06 20:53 ` David Howells
  2010-08-06 20:58   ` Trond Myklebust
  2 siblings, 1 reply; 9+ messages in thread
From: David Howells @ 2010-08-06 20:53 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: dhowells, Bryan Schumaker, linux-nfs

Trond Myklebust <Trond.Myklebust@netapp.com> wrote:

> David, can you carry this as part of your 'generic DNS resolver'
> patchset?

Do you have an Ack or a sign-off for this patch?

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
  2010-08-06 20:53 ` David Howells
@ 2010-08-06 20:58   ` Trond Myklebust
  0 siblings, 0 replies; 9+ messages in thread
From: Trond Myklebust @ 2010-08-06 20:58 UTC (permalink / raw)
  To: David Howells; +Cc: Bryan Schumaker, linux-nfs

On Fri, 2010-08-06 at 21:53 +0100, David Howells wrote:
> Trond Myklebust <Trond.Myklebust@netapp.com> wrote:
> 
> > David, can you carry this as part of your 'generic DNS resolver'
> > patchset?
> 
> Do you have an Ack or a sign-off for this patch?
> 
> David

Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] NFS use kernel DNS resolver
  2010-08-06  2:05   ` David Howells
  2010-08-06 18:29     ` Bryan Schumaker
@ 2010-08-06 21:00     ` David Howells
  1 sibling, 0 replies; 9+ messages in thread
From: David Howells @ 2010-08-06 21:00 UTC (permalink / raw)
  To: Bryan Schumaker; +Cc: dhowells, Trond Myklebust, linux-nfs

Bryan Schumaker <bjschuma@netapp.com> wrote:

> --- a/fs/nfs/dns_resolve.c
> +++ b/fs/nfs/dns_resolve.c
> ...
> +inline int nfs_dns_resolver_init(void)
> +{
> +	return 0;
> +}
> +
> +inline void nfs_dns_resolver_destroy(void)
> +{}

These functions are a little pointless since you do the same in the header
file, so I've removed them.  It still compiles...

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] NFS: Use kernel DNS resolver
@ 2010-08-06 21:01 David Howells
  0 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2010-08-06 21:01 UTC (permalink / raw)
  To: smfrench, jlayton
  Cc: linux-fsdevel, linux-cifs, linux-afs, linux-nfs, linux-kernel,
	Bryan Schumaker, Trond Myklebust, David Howells

From: Bryan Schumaker <bjschuma@netapp.com>

Use the kernel DNS resolver to translate hostnames to IP addresses.  Create a
new config option to choose between the legacy DNS resolver and the new
resolver.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/nfs/Kconfig       |   16 ++++++++++++++++
 fs/nfs/dns_resolve.c |   24 ++++++++++++++++++++++++
 fs/nfs/dns_resolve.h |   12 ++++++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index a43d07e..10eebc5 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -100,3 +100,19 @@ config NFS_FSCACHE
 	help
 	  Say Y here if you want NFS data to be cached locally on disc through
 	  the general filesystem cache manager
+
+config NFS_USE_LEGACY_DNS
+	bool "Use the legacy NFS DNS resolver"
+	depends on NFS_V4
+	help
+	  The kernel now provides a method for translating a host name into an
+	  IP address.  Select Y here if you would rather use your own DNS
+	  resolver script.
+
+	  If unsure, say N
+
+config NFS_USE_KERNEL_DNS
+	bool
+	depends on NFS_V4 && !NFS_USE_LEGACY_DNS
+	select DNS_RESOLVER
+	default y
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 76fd235..dba50a5 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -6,6 +6,29 @@
  * Resolves DNS hostnames into valid ip addresses
  */
 
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/dns_resolver.h>
+
+ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
+		struct sockaddr *sa, size_t salen)
+{
+	ssize_t ret;
+	char *ip_addr = NULL;
+	int ip_len;
+
+	ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
+	if (ip_len > 0)
+		ret = rpc_pton(ip_addr, ip_len, sa, salen);
+	else
+		ret = -ESRCH;
+	kfree(ip_addr);
+	return ret;
+}
+
+#else
+
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
@@ -346,3 +369,4 @@ void nfs_dns_resolver_destroy(void)
 	nfs_cache_unregister(&nfs_dns_resolve);
 }
 
+#endif
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index a3f0938..199bb55 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -6,8 +6,20 @@
 
 #define NFS_DNS_HOSTNAME_MAXLEN	(128)
 
+
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+static inline int nfs_dns_resolver_init(void)
+{
+	return 0;
+}
+
+static inline void nfs_dns_resolver_destroy(void)
+{}
+#else
 extern int nfs_dns_resolver_init(void);
 extern void nfs_dns_resolver_destroy(void);
+#endif
+
 extern ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
 		struct sockaddr *sa, size_t salen);
 


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] NFS: Use kernel DNS resolver
@ 2010-08-09 11:50 David Howells
  0 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2010-08-09 11:50 UTC (permalink / raw)
  To: torvalds, akpm
  Cc: linux-nfs, smfrench, linux-kernel, Bryan Schumaker,
	Trond Myklebust, David Howells

From: Bryan Schumaker <bjschuma@netapp.com>

Use the kernel DNS resolver to translate hostnames to IP addresses.  Create a
new config option to choose between the legacy DNS resolver and the new
resolver.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Acked-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/nfs/Kconfig       |   16 ++++++++++++++++
 fs/nfs/dns_resolve.c |   24 ++++++++++++++++++++++++
 fs/nfs/dns_resolve.h |   12 ++++++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index cc1bb33..c5bbdca 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -100,3 +100,19 @@ config NFS_FSCACHE
 	help
 	  Say Y here if you want NFS data to be cached locally on disc through
 	  the general filesystem cache manager
+
+config NFS_USE_LEGACY_DNS
+	bool "Use the legacy NFS DNS resolver"
+	depends on NFS_V4
+	help
+	  The kernel now provides a method for translating a host name into an
+	  IP address.  Select Y here if you would rather use your own DNS
+	  resolver script.
+
+	  If unsure, say N
+
+config NFS_USE_KERNEL_DNS
+	bool
+	depends on NFS_V4 && !NFS_USE_LEGACY_DNS
+	select DNS_RESOLVER
+	default y
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 76fd235..dba50a5 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -6,6 +6,29 @@
  * Resolves DNS hostnames into valid ip addresses
  */
 
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+
+#include <linux/sunrpc/clnt.h>
+#include <linux/dns_resolver.h>
+
+ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
+		struct sockaddr *sa, size_t salen)
+{
+	ssize_t ret;
+	char *ip_addr = NULL;
+	int ip_len;
+
+	ip_len = dns_query(NULL, name, namelen, NULL, &ip_addr, NULL);
+	if (ip_len > 0)
+		ret = rpc_pton(ip_addr, ip_len, sa, salen);
+	else
+		ret = -ESRCH;
+	kfree(ip_addr);
+	return ret;
+}
+
+#else
+
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
@@ -346,3 +369,4 @@ void nfs_dns_resolver_destroy(void)
 	nfs_cache_unregister(&nfs_dns_resolve);
 }
 
+#endif
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index a3f0938..199bb55 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -6,8 +6,20 @@
 
 #define NFS_DNS_HOSTNAME_MAXLEN	(128)
 
+
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+static inline int nfs_dns_resolver_init(void)
+{
+	return 0;
+}
+
+static inline void nfs_dns_resolver_destroy(void)
+{}
+#else
 extern int nfs_dns_resolver_init(void);
 extern void nfs_dns_resolver_destroy(void);
+#endif
+
 extern ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
 		struct sockaddr *sa, size_t salen);
 


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-08-09 11:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 21:01 [PATCH] NFS: Use kernel DNS resolver David Howells
  -- strict thread matches above, loose matches on Subject: below --
2010-08-09 11:50 David Howells
2010-08-04 20:46 [PATCH] NFS use " Bryan Schumaker
2010-08-05  1:09 ` Trond Myklebust
     [not found] ` <1280970596.2865.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-08-06  2:05   ` David Howells
2010-08-06 18:29     ` Bryan Schumaker
2010-08-06 21:00     ` David Howells
2010-08-06 20:53 ` David Howells
2010-08-06 20:58   ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).