NFS use kernel DNS resolver
Subsystems (2)
PATCH 1/1 NFS use kernel DNS resolver
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.
fs/nfs/Kconfig +16 -0
@@ -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
fs/nfs/Makefile +2 -1
@@ -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
fs/nfs/dns_resolve.c +23 -0
@@ -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
fs/nfs/dns_resolve.h +13 -0
@@ -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);
Quoted 5 lines · Bryan Schumaker
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 <[email protected]>
---
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
Quoted 111 lines
fs/nfs/Kconfig +16
-0@@ -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 yfs/nfs/Makefile +2
-1@@ -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.ofs/nfs/dns_resolve.c +23
-0@@ -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 fs/nfs/dns_resolve.h +13
-1@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Trond Myklebust
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
Trond Myklebust
Acked-byQuoted 8 lines · David Howells
Quoted 2 lines · Trond Myklebust
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
A message that is not in the archive (sent off-list or not yet received): 1280970596.2865.28.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 2 lines · Trond Myklebust
David, can you carry this as part of your 'generic DNS resolver' patchset?
Probably. Can you send me a copy of the patch?
David
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.
fs/nfs/Kconfig +16 -0
@@ -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
fs/nfs/dns_resolve.c +32 -0
@@ -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
fs/nfs/dns_resolve.h +12 -0
@@ -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);
Quoted 8 lines · David Howells
Quoted 2 lines · Trond Myklebust
David, can you carry this as part of your 'generic DNS resolver' patchset?
Probably. Can you send me a copy of the patch?
David
fs/nfs/dns_resolve.c line 36
Quoted 10 lines · Bryan Schumaker
fs/nfs/dns_resolve.c +7
-0+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