NFS: Use kernel DNS resolver [ver #2]
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> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
committed by
Steve French
parent
3694b91a59
commit
c2e8139c9f
@@ -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
|
||||
|
Reference in New Issue
Block a user