提交 66697bfd 编写于 作者: S Stanislav Kinsbursky 提交者: Trond Myklebust

LockD: make nlm hosts network namespace aware

This object depends on RPC client, and thus on network namespace.
So let's make it's allocation and lookup in network namespace context.
Signed-off-by: NStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 bb2224df
...@@ -62,7 +62,8 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init) ...@@ -62,7 +62,8 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen, host = nlmclnt_lookup_host(nlm_init->address, nlm_init->addrlen,
nlm_init->protocol, nlm_version, nlm_init->protocol, nlm_version,
nlm_init->hostname, nlm_init->noresvport); nlm_init->hostname, nlm_init->noresvport,
nlm_init->net);
if (host == NULL) { if (host == NULL) {
lockd_down(); lockd_down();
return ERR_PTR(-ENOLCK); return ERR_PTR(-ENOLCK);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <linux/lockd/lockd.h> #include <linux/lockd/lockd.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/sunrpc/svc_xprt.h>
#include <net/ipv6.h> #include <net/ipv6.h>
#define NLMDBG_FACILITY NLMDBG_HOSTCACHE #define NLMDBG_FACILITY NLMDBG_HOSTCACHE
...@@ -54,6 +56,7 @@ struct nlm_lookup_host_info { ...@@ -54,6 +56,7 @@ struct nlm_lookup_host_info {
const char *hostname; /* remote's hostname */ const char *hostname; /* remote's hostname */
const size_t hostname_len; /* it's length */ const size_t hostname_len; /* it's length */
const int noresvport; /* use non-priv port */ const int noresvport; /* use non-priv port */
struct net *net; /* network namespace to bind */
}; };
/* /*
...@@ -155,6 +158,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni, ...@@ -155,6 +158,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
INIT_LIST_HEAD(&host->h_reclaim); INIT_LIST_HEAD(&host->h_reclaim);
host->h_nsmhandle = nsm; host->h_nsmhandle = nsm;
host->h_addrbuf = nsm->sm_addrbuf; host->h_addrbuf = nsm->sm_addrbuf;
host->net = ni->net;
out: out:
return host; return host;
...@@ -206,7 +210,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, ...@@ -206,7 +210,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
const unsigned short protocol, const unsigned short protocol,
const u32 version, const u32 version,
const char *hostname, const char *hostname,
int noresvport) int noresvport,
struct net *net)
{ {
struct nlm_lookup_host_info ni = { struct nlm_lookup_host_info ni = {
.server = 0, .server = 0,
...@@ -217,6 +222,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, ...@@ -217,6 +222,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
.hostname = hostname, .hostname = hostname,
.hostname_len = strlen(hostname), .hostname_len = strlen(hostname),
.noresvport = noresvport, .noresvport = noresvport,
.net = net,
}; };
struct hlist_head *chain; struct hlist_head *chain;
struct hlist_node *pos; struct hlist_node *pos;
...@@ -231,6 +237,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, ...@@ -231,6 +237,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
chain = &nlm_client_hosts[nlm_hash_address(sap)]; chain = &nlm_client_hosts[nlm_hash_address(sap)];
hlist_for_each_entry(host, pos, chain, h_hash) { hlist_for_each_entry(host, pos, chain, h_hash) {
if (host->net != net)
continue;
if (!rpc_cmp_addr(nlm_addr(host), sap)) if (!rpc_cmp_addr(nlm_addr(host), sap))
continue; continue;
...@@ -318,6 +326,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, ...@@ -318,6 +326,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
struct nsm_handle *nsm = NULL; struct nsm_handle *nsm = NULL;
struct sockaddr *src_sap = svc_daddr(rqstp); struct sockaddr *src_sap = svc_daddr(rqstp);
size_t src_len = rqstp->rq_daddrlen; size_t src_len = rqstp->rq_daddrlen;
struct net *net = rqstp->rq_xprt->xpt_net;
struct nlm_lookup_host_info ni = { struct nlm_lookup_host_info ni = {
.server = 1, .server = 1,
.sap = svc_addr(rqstp), .sap = svc_addr(rqstp),
...@@ -326,6 +335,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, ...@@ -326,6 +335,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
.version = rqstp->rq_vers, .version = rqstp->rq_vers,
.hostname = hostname, .hostname = hostname,
.hostname_len = hostname_len, .hostname_len = hostname_len,
.net = net,
}; };
dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__, dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__,
...@@ -339,6 +349,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, ...@@ -339,6 +349,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
chain = &nlm_server_hosts[nlm_hash_address(ni.sap)]; chain = &nlm_server_hosts[nlm_hash_address(ni.sap)];
hlist_for_each_entry(host, pos, chain, h_hash) { hlist_for_each_entry(host, pos, chain, h_hash) {
if (host->net != net)
continue;
if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) if (!rpc_cmp_addr(nlm_addr(host), ni.sap))
continue; continue;
...@@ -431,7 +443,7 @@ nlm_bind_host(struct nlm_host *host) ...@@ -431,7 +443,7 @@ nlm_bind_host(struct nlm_host *host)
.to_retries = 5U, .to_retries = 5U,
}; };
struct rpc_create_args args = { struct rpc_create_args args = {
.net = &init_net, .net = host->net,
.protocol = host->h_proto, .protocol = host->h_proto,
.address = nlm_addr(host), .address = nlm_addr(host),
.addrsize = host->h_addrlen, .addrsize = host->h_addrlen,
......
...@@ -707,6 +707,7 @@ static int nfs_start_lockd(struct nfs_server *server) ...@@ -707,6 +707,7 @@ static int nfs_start_lockd(struct nfs_server *server)
.nfs_version = clp->rpc_ops->version, .nfs_version = clp->rpc_ops->version,
.noresvport = server->flags & NFS_MOUNT_NORESVPORT ? .noresvport = server->flags & NFS_MOUNT_NORESVPORT ?
1 : 0, 1 : 0,
.net = clp->net,
}; };
if (nlm_init.nfs_version > 3) if (nlm_init.nfs_version > 3)
......
...@@ -42,6 +42,7 @@ struct nlmclnt_initdata { ...@@ -42,6 +42,7 @@ struct nlmclnt_initdata {
unsigned short protocol; unsigned short protocol;
u32 nfs_version; u32 nfs_version;
int noresvport; int noresvport;
struct net *net;
}; };
/* /*
......
...@@ -67,6 +67,7 @@ struct nlm_host { ...@@ -67,6 +67,7 @@ struct nlm_host {
struct list_head h_reclaim; /* Locks in RECLAIM state */ struct list_head h_reclaim; /* Locks in RECLAIM state */
struct nsm_handle *h_nsmhandle; /* NSM status handle */ struct nsm_handle *h_nsmhandle; /* NSM status handle */
char *h_addrbuf; /* address eyecatcher */ char *h_addrbuf; /* address eyecatcher */
struct net *net; /* host net */
}; };
/* /*
...@@ -222,7 +223,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, ...@@ -222,7 +223,8 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
const unsigned short protocol, const unsigned short protocol,
const u32 version, const u32 version,
const char *hostname, const char *hostname,
int noresvport); int noresvport,
struct net *net);
void nlmclnt_release_host(struct nlm_host *); void nlmclnt_release_host(struct nlm_host *);
struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
const char *hostname, const char *hostname,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册