From 502ac6ebb22dbba30abaaa0c9953f572bd3ca9bf Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 11 Aug 2010 09:37:53 +0100 Subject: [PATCH] --- yaml --- r: 209189 b: refs/heads/master c: c2e8139c9f797baa46515af6d350c51823736cbb h: refs/heads/master i: 209187: 20720242c29861cc90ba52b950bcc71eec10bf5d v: v3 --- [refs] | 2 +- trunk/fs/nfs/Kconfig | 16 ++++++++++++++++ trunk/fs/nfs/dns_resolve.c | 24 ++++++++++++++++++++++++ trunk/fs/nfs/dns_resolve.h | 12 ++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 0ec677522c7b..c78799ca3e4b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3694b91a59c3bc784735574878d36652dfd623c2 +refs/heads/master: c2e8139c9f797baa46515af6d350c51823736cbb diff --git a/trunk/fs/nfs/Kconfig b/trunk/fs/nfs/Kconfig index cc1bb33b59b8..c5bbdca13ac2 100644 --- a/trunk/fs/nfs/Kconfig +++ b/trunk/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/trunk/fs/nfs/dns_resolve.c b/trunk/fs/nfs/dns_resolve.c index 76fd235d0024..dba50a5625db 100644 --- a/trunk/fs/nfs/dns_resolve.c +++ b/trunk/fs/nfs/dns_resolve.c @@ -6,6 +6,29 @@ * Resolves DNS hostnames into valid ip addresses */ +#ifdef CONFIG_NFS_USE_KERNEL_DNS + +#include +#include + +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 #include #include @@ -346,3 +369,4 @@ void nfs_dns_resolver_destroy(void) nfs_cache_unregister(&nfs_dns_resolve); } +#endif diff --git a/trunk/fs/nfs/dns_resolve.h b/trunk/fs/nfs/dns_resolve.h index a3f0938babf7..199bb5543a91 100644 --- a/trunk/fs/nfs/dns_resolve.h +++ b/trunk/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);