aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/host.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-12-23 15:21:38 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-12-23 15:21:38 -0500
commit0cb2659b818eca99235e17c04291cfa9985c14f7 (patch)
tree48fc176e1e1e8a6f771e664799c26df1d72e9f69 /fs/lockd/host.c
parent50a737f86dbf99daf3a8dcbdf778a3be36bb2a39 (diff)
NLM: allow lockd requests from an unprivileged port
If the admin has specified the "noresvport" option for an NFS mount point, the kernel's NFS client uses an unprivileged source port for the main NFS transport. The kernel's lockd client should use an unprivileged port in this case as well. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/host.c')
-rw-r--r--fs/lockd/host.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 70fc63a1727b..acc2aa5021d1 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -48,6 +48,7 @@ struct nlm_lookup_host_info {
48 const size_t hostname_len; /* it's length */ 48 const size_t hostname_len; /* it's length */
49 const struct sockaddr *src_sap; /* our address (optional) */ 49 const struct sockaddr *src_sap; /* our address (optional) */
50 const size_t src_len; /* it's length */ 50 const size_t src_len; /* it's length */
51 const int noresvport; /* use non-priv port */
51}; 52};
52 53
53/* 54/*
@@ -222,6 +223,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
222 host->h_nsmstate = 0; /* real NSM state */ 223 host->h_nsmstate = 0; /* real NSM state */
223 host->h_nsmhandle = nsm; 224 host->h_nsmhandle = nsm;
224 host->h_server = ni->server; 225 host->h_server = ni->server;
226 host->h_noresvport = ni->noresvport;
225 hlist_add_head(&host->h_hash, chain); 227 hlist_add_head(&host->h_hash, chain);
226 INIT_LIST_HEAD(&host->h_lockowners); 228 INIT_LIST_HEAD(&host->h_lockowners);
227 spin_lock_init(&host->h_lock); 229 spin_lock_init(&host->h_lock);
@@ -272,6 +274,7 @@ nlm_destroy_host(struct nlm_host *host)
272 * @protocol: transport protocol to use 274 * @protocol: transport protocol to use
273 * @version: NLM protocol version 275 * @version: NLM protocol version
274 * @hostname: '\0'-terminated hostname of server 276 * @hostname: '\0'-terminated hostname of server
277 * @noresvport: 1 if non-privileged port should be used
275 * 278 *
276 * Returns an nlm_host structure that matches the passed-in 279 * Returns an nlm_host structure that matches the passed-in
277 * [server address, transport protocol, NLM version, server hostname]. 280 * [server address, transport protocol, NLM version, server hostname].
@@ -281,7 +284,9 @@ nlm_destroy_host(struct nlm_host *host)
281struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap, 284struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
282 const size_t salen, 285 const size_t salen,
283 const unsigned short protocol, 286 const unsigned short protocol,
284 const u32 version, const char *hostname) 287 const u32 version,
288 const char *hostname,
289 int noresvport)
285{ 290{
286 const struct sockaddr source = { 291 const struct sockaddr source = {
287 .sa_family = AF_UNSPEC, 292 .sa_family = AF_UNSPEC,
@@ -296,6 +301,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
296 .hostname_len = strlen(hostname), 301 .hostname_len = strlen(hostname),
297 .src_sap = &source, 302 .src_sap = &source,
298 .src_len = sizeof(source), 303 .src_len = sizeof(source),
304 .noresvport = noresvport,
299 }; 305 };
300 306
301 dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__, 307 dprintk("lockd: %s(host='%s', vers=%u, proto=%s)\n", __func__,
@@ -417,6 +423,8 @@ nlm_bind_host(struct nlm_host *host)
417 */ 423 */
418 if (!host->h_server) 424 if (!host->h_server)
419 args.flags |= RPC_CLNT_CREATE_HARDRTRY; 425 args.flags |= RPC_CLNT_CREATE_HARDRTRY;
426 if (host->h_noresvport)
427 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
420 428
421 clnt = rpc_create(&args); 429 clnt = rpc_create(&args);
422 if (!IS_ERR(clnt)) 430 if (!IS_ERR(clnt))