#include <linux/module.h>
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/addr.h>
#include "dns_resolve.h"
#ifdef CONFIG_NFS_USE_KERNEL_DNS
#include <linux/dns_resolver.h>
ssize_t nfs_dns_resolve_name(struct net *net, char *name, size_t namelen,
struct sockaddr_storage *ss, size_t salen)
{
struct sockaddr *sa = (struct sockaddr *)ss;
ssize_t ret;
char *ip_addr = NULL;
int ip_len;
ip_len = dns_query(net, NULL, name, namelen, NULL, &ip_addr, NULL,
false);
if (ip_len > 0)
ret = rpc_pton(net, 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>
#include <linux/slab.h>
#include <linux/socket.h>
#include <linux/seq_file.h>
#include <linux/inet.h>
#include <linux/sunrpc/cache.h>
#include <linux/sunrpc/svcauth.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
#include <linux/nfs_fs.h>
#include "nfs4_fs.h"
#include "cache_lib.h"
#include "netns.h"
#define NFS_DNS_HASHBITS …
#define NFS_DNS_HASHTBL_SIZE …
struct nfs_dns_ent { … };
static void nfs_dns_ent_update(struct cache_head *cnew,
struct cache_head *ckey)
{ … }
static void nfs_dns_ent_init(struct cache_head *cnew,
struct cache_head *ckey)
{ … }
static void nfs_dns_ent_free_rcu(struct rcu_head *head)
{ … }
static void nfs_dns_ent_put(struct kref *ref)
{ … }
static struct cache_head *nfs_dns_ent_alloc(void)
{
struct nfs_dns_ent *item = kmalloc(sizeof(*item), GFP_KERNEL);
if (item != NULL) {
item->hostname = NULL;
item->namelen = 0;
item->addrlen = 0;
return &item->h;
}
return NULL;
};
static unsigned int nfs_dns_hash(const struct nfs_dns_ent *key)
{ … }
static void nfs_dns_request(struct cache_detail *cd,
struct cache_head *ch,
char **bpp, int *blen)
{ … }
static int nfs_dns_upcall(struct cache_detail *cd,
struct cache_head *ch)
{ … }
static int nfs_dns_match(struct cache_head *ca,
struct cache_head *cb)
{ … }
static int nfs_dns_show(struct seq_file *m, struct cache_detail *cd,
struct cache_head *h)
{ … }
static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd,
struct nfs_dns_ent *key)
{ … }
static struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd,
struct nfs_dns_ent *new,
struct nfs_dns_ent *key)
{ … }
static int nfs_dns_parse(struct cache_detail *cd, char *buf, int buflen)
{ … }
static int do_cache_lookup(struct cache_detail *cd,
struct nfs_dns_ent *key,
struct nfs_dns_ent **item,
struct nfs_cache_defer_req *dreq)
{ … }
static int do_cache_lookup_nowait(struct cache_detail *cd,
struct nfs_dns_ent *key,
struct nfs_dns_ent **item)
{ … }
static int do_cache_lookup_wait(struct cache_detail *cd,
struct nfs_dns_ent *key,
struct nfs_dns_ent **item)
{ … }
ssize_t nfs_dns_resolve_name(struct net *net, char *name,
size_t namelen, struct sockaddr_storage *ss, size_t salen)
{ … }
static struct cache_detail nfs_dns_resolve_template = …;
int nfs_dns_resolver_cache_init(struct net *net)
{ … }
void nfs_dns_resolver_cache_destroy(struct net *net)
{ … }
static int nfs4_dns_net_init(struct net *net)
{ … }
static void nfs4_dns_net_exit(struct net *net)
{ … }
static struct pernet_operations nfs4_dns_resolver_ops = …;
static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
void *ptr)
{ … }
static struct notifier_block nfs_dns_resolver_block = …;
int nfs_dns_resolver_init(void)
{ … }
void nfs_dns_resolver_destroy(void)
{ … }
#endif