aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-31 06:07:48 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-02-15 00:19:46 -0500
commitc228fa2038a33bb3b87f567482124f452e162a71 (patch)
tree7d89404b7d9facf20487b782126ddfa5dfe14620 /fs/lockd
parent074d0f67cfe0af4927ce49560f403096b490c47f (diff)
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>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/svc.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index ff379ff7761f..cba35984dde7 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -189,27 +189,29 @@ lockd(void *vrqstp)
189} 189}
190 190
191static int create_lockd_listener(struct svc_serv *serv, const char *name, 191static int create_lockd_listener(struct svc_serv *serv, const char *name,
192 const int family, const unsigned short port) 192 struct net *net, const int family,
193 const unsigned short port)
193{ 194{
194 struct svc_xprt *xprt; 195 struct svc_xprt *xprt;
195 196
196 xprt = svc_find_xprt(serv, name, &init_net, family, 0); 197 xprt = svc_find_xprt(serv, name, net, family, 0);
197 if (xprt == NULL) 198 if (xprt == NULL)
198 return svc_create_xprt(serv, name, &init_net, family, port, 199 return svc_create_xprt(serv, name, net, family, port,
199 SVC_SOCK_DEFAULTS); 200 SVC_SOCK_DEFAULTS);
200 svc_xprt_put(xprt); 201 svc_xprt_put(xprt);
201 return 0; 202 return 0;
202} 203}
203 204
204static int create_lockd_family(struct svc_serv *serv, const int family) 205static int create_lockd_family(struct svc_serv *serv, struct net *net,
206 const int family)
205{ 207{
206 int err; 208 int err;
207 209
208 err = create_lockd_listener(serv, "udp", family, nlm_udpport); 210 err = create_lockd_listener(serv, "udp", net, family, nlm_udpport);
209 if (err < 0) 211 if (err < 0)
210 return err; 212 return err;
211 213
212 return create_lockd_listener(serv, "tcp", family, nlm_tcpport); 214 return create_lockd_listener(serv, "tcp", net, family, nlm_tcpport);
213} 215}
214 216
215/* 217/*
@@ -222,16 +224,16 @@ static int create_lockd_family(struct svc_serv *serv, const int family)
222 * Returns zero if all listeners are available; otherwise a 224 * Returns zero if all listeners are available; otherwise a
223 * negative errno value is returned. 225 * negative errno value is returned.
224 */ 226 */
225static int make_socks(struct svc_serv *serv) 227static int make_socks(struct svc_serv *serv, struct net *net)
226{ 228{
227 static int warned; 229 static int warned;
228 int err; 230 int err;
229 231
230 err = create_lockd_family(serv, PF_INET); 232 err = create_lockd_family(serv, net, PF_INET);
231 if (err < 0) 233 if (err < 0)
232 goto out_err; 234 goto out_err;
233 235
234 err = create_lockd_family(serv, PF_INET6); 236 err = create_lockd_family(serv, net, PF_INET6);
235 if (err < 0 && err != -EAFNOSUPPORT) 237 if (err < 0 && err != -EAFNOSUPPORT)
236 goto out_err; 238 goto out_err;
237 239
@@ -252,6 +254,7 @@ int lockd_up(void)
252{ 254{
253 struct svc_serv *serv; 255 struct svc_serv *serv;
254 int error = 0; 256 int error = 0;
257 struct net *net = current->nsproxy->net_ns;
255 258
256 mutex_lock(&nlmsvc_mutex); 259 mutex_lock(&nlmsvc_mutex);
257 /* 260 /*
@@ -275,7 +278,7 @@ int lockd_up(void)
275 goto out; 278 goto out;
276 } 279 }
277 280
278 error = make_socks(serv); 281 error = make_socks(serv, net);
279 if (error < 0) 282 if (error < 0)
280 goto destroy_and_out; 283 goto destroy_and_out;
281 284