Lockd: create permanent lockd sockets in current network namespace
This patch parametrizes Lockd permanent sockets creation routine by network namespace context. It also replaces hard-coded init_net with current network namespace context in Lockd sockets creation routines. This approach looks safe, because Lockd is created during NFS mount (or NFS server start) and thus socket is required exactly in current network namespace context. But in the same time it means, that Lockd sockets inherits first Lockd requester network namespace. This issue will be fixed in further patches of the series. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Родитель
074d0f67cf
Коммит
c228fa2038
|
@ -189,27 +189,29 @@ lockd(void *vrqstp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_lockd_listener(struct svc_serv *serv, const char *name,
|
static int create_lockd_listener(struct svc_serv *serv, const char *name,
|
||||||
const int family, const unsigned short port)
|
struct net *net, const int family,
|
||||||
|
const unsigned short port)
|
||||||
{
|
{
|
||||||
struct svc_xprt *xprt;
|
struct svc_xprt *xprt;
|
||||||
|
|
||||||
xprt = svc_find_xprt(serv, name, &init_net, family, 0);
|
xprt = svc_find_xprt(serv, name, net, family, 0);
|
||||||
if (xprt == NULL)
|
if (xprt == NULL)
|
||||||
return svc_create_xprt(serv, name, &init_net, family, port,
|
return svc_create_xprt(serv, name, net, family, port,
|
||||||
SVC_SOCK_DEFAULTS);
|
SVC_SOCK_DEFAULTS);
|
||||||
svc_xprt_put(xprt);
|
svc_xprt_put(xprt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_lockd_family(struct svc_serv *serv, const int family)
|
static int create_lockd_family(struct svc_serv *serv, struct net *net,
|
||||||
|
const int family)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = create_lockd_listener(serv, "udp", family, nlm_udpport);
|
err = create_lockd_listener(serv, "udp", net, family, nlm_udpport);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
return create_lockd_listener(serv, "tcp", family, nlm_tcpport);
|
return create_lockd_listener(serv, "tcp", net, family, nlm_tcpport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -222,16 +224,16 @@ static int create_lockd_family(struct svc_serv *serv, const int family)
|
||||||
* Returns zero if all listeners are available; otherwise a
|
* Returns zero if all listeners are available; otherwise a
|
||||||
* negative errno value is returned.
|
* negative errno value is returned.
|
||||||
*/
|
*/
|
||||||
static int make_socks(struct svc_serv *serv)
|
static int make_socks(struct svc_serv *serv, struct net *net)
|
||||||
{
|
{
|
||||||
static int warned;
|
static int warned;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = create_lockd_family(serv, PF_INET);
|
err = create_lockd_family(serv, net, PF_INET);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
err = create_lockd_family(serv, PF_INET6);
|
err = create_lockd_family(serv, net, PF_INET6);
|
||||||
if (err < 0 && err != -EAFNOSUPPORT)
|
if (err < 0 && err != -EAFNOSUPPORT)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
|
@ -252,6 +254,7 @@ int lockd_up(void)
|
||||||
{
|
{
|
||||||
struct svc_serv *serv;
|
struct svc_serv *serv;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
struct net *net = current->nsproxy->net_ns;
|
||||||
|
|
||||||
mutex_lock(&nlmsvc_mutex);
|
mutex_lock(&nlmsvc_mutex);
|
||||||
/*
|
/*
|
||||||
|
@ -275,7 +278,7 @@ int lockd_up(void)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = make_socks(serv);
|
error = make_socks(serv, net);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto destroy_and_out;
|
goto destroy_and_out;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче