aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorOlaf Kirch <okir@suse.de>2006-10-04 05:15:52 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 10:55:16 -0400
commitdb4e4c9a9e741ee812e1febf5e386d6a24218a71 (patch)
tree92e59fba30edbf5e10908eb2952928a5e2a29adf /fs
parentcf712c24d72341effcfd28330b83b49f77cb627b (diff)
[PATCH] knfsd: when looking up a lockd host, pass hostname & length
This patch adds the peer's hostname (and name length) to all calls to nlm*_lookup_host functions. A subsequent patch will make use of these (is requested by a sysctl). Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/clntproc.c5
-rw-r--r--fs/lockd/host.c37
-rw-r--r--fs/lockd/svc4proc.c6
-rw-r--r--fs/lockd/svclock.c3
-rw-r--r--fs/lockd/svcproc.c6
5 files changed, 39 insertions, 18 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 5436be623e30..7e6f22e2a3b4 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -153,6 +153,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
153{ 153{
154 struct rpc_clnt *client = NFS_CLIENT(inode); 154 struct rpc_clnt *client = NFS_CLIENT(inode);
155 struct sockaddr_in addr; 155 struct sockaddr_in addr;
156 struct nfs_server *nfssrv = NFS_SERVER(inode);
156 struct nlm_host *host; 157 struct nlm_host *host;
157 struct nlm_rqst *call; 158 struct nlm_rqst *call;
158 sigset_t oldset; 159 sigset_t oldset;
@@ -166,7 +167,9 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
166 } 167 }
167 168
168 rpc_peeraddr(client, (struct sockaddr *) &addr, sizeof(addr)); 169 rpc_peeraddr(client, (struct sockaddr *) &addr, sizeof(addr));
169 host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers); 170 host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers,
171 nfssrv->nfs_client->cl_hostname,
172 strlen(nfssrv->nfs_client->cl_hostname));
170 if (host == NULL) 173 if (host == NULL)
171 return -ENOLCK; 174 return -ENOLCK;
172 175
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index bcc21b05808a..481ce7ee1002 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -39,19 +39,23 @@ static void nlm_gc_hosts(void);
39 * Find an NLM server handle in the cache. If there is none, create it. 39 * Find an NLM server handle in the cache. If there is none, create it.
40 */ 40 */
41struct nlm_host * 41struct nlm_host *
42nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version) 42nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
43 const char *hostname, int hostname_len)
43{ 44{
44 return nlm_lookup_host(0, sin, proto, version); 45 return nlm_lookup_host(0, sin, proto, version,
46 hostname, hostname_len);
45} 47}
46 48
47/* 49/*
48 * Find an NLM client handle in the cache. If there is none, create it. 50 * Find an NLM client handle in the cache. If there is none, create it.
49 */ 51 */
50struct nlm_host * 52struct nlm_host *
51nlmsvc_lookup_host(struct svc_rqst *rqstp) 53nlmsvc_lookup_host(struct svc_rqst *rqstp,
54 const char *hostname, int hostname_len)
52{ 55{
53 return nlm_lookup_host(1, &rqstp->rq_addr, 56 return nlm_lookup_host(1, &rqstp->rq_addr,
54 rqstp->rq_prot, rqstp->rq_vers); 57 rqstp->rq_prot, rqstp->rq_vers,
58 hostname, hostname_len);
55} 59}
56 60
57/* 61/*
@@ -59,14 +63,20 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp)
59 */ 63 */
60struct nlm_host * 64struct nlm_host *
61nlm_lookup_host(int server, const struct sockaddr_in *sin, 65nlm_lookup_host(int server, const struct sockaddr_in *sin,
62 int proto, int version) 66 int proto, int version,
67 const char *hostname,
68 int hostname_len)
63{ 69{
64 struct nlm_host *host, **hp; 70 struct nlm_host *host, **hp;
65 u32 addr; 71 u32 addr;
66 int hash; 72 int hash;
67 73
68 dprintk("lockd: nlm_lookup_host(%08x, p=%d, v=%d)\n", 74 dprintk("lockd: nlm_lookup_host(%u.%u.%u.%u, p=%d, v=%d, my role=%s, name=%.*s)\n",
69 (unsigned)(sin? ntohl(sin->sin_addr.s_addr) : 0), proto, version); 75 NIPQUAD(sin->sin_addr.s_addr), proto, version,
76 server? "server" : "client",
77 hostname_len,
78 hostname? hostname : "<none>");
79
70 80
71 hash = NLM_ADDRHASH(sin->sin_addr.s_addr); 81 hash = NLM_ADDRHASH(sin->sin_addr.s_addr);
72 82
@@ -267,19 +277,22 @@ void nlm_release_host(struct nlm_host *host)
267void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp) 277void nlm_host_rebooted(const struct sockaddr_in *sin, const struct nlm_reboot *argp)
268{ 278{
269 struct nlm_host *host; 279 struct nlm_host *host;
280 int server;
270 281
271 /* Obtain the host pointer for this NFS server and try to 282 /* Obtain the host pointer for this NFS server and try to
272 * reclaim all locks we hold on this server. 283 * reclaim all locks we hold on this server.
273 */ 284 */
274 if ((argp->proto & 1)==0) { 285 server = (argp->proto & 1)? 1 : 0;
286 host = nlm_lookup_host(server, sin, argp->proto >> 1, argp->vers,
287 argp->mon, argp->len);
288 if (host == NULL)
289 return;
290
291 if (server == 0) {
275 /* We are client, he's the server: try to reclaim all locks. */ 292 /* We are client, he's the server: try to reclaim all locks. */
276 if ((host = nlmclnt_lookup_host(sin, argp->proto >> 1, argp->vers)) == NULL)
277 return;
278 nlmclnt_recovery(host, argp->state); 293 nlmclnt_recovery(host, argp->state);
279 } else { 294 } else {
280 /* He's the client, we're the server: delete all locks held by the client */ 295 /* He's the client, we're the server: delete all locks held by the client */
281 if ((host = nlm_lookup_host(1, sin, argp->proto >> 1, argp->vers)) == NULL)
282 return;
283 nlmsvc_free_host_resources(host); 296 nlmsvc_free_host_resources(host);
284 } 297 }
285 nlm_release_host(host); 298 nlm_release_host(host);
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 97bd36c09a5b..7d835ad81074 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -38,7 +38,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
38 return nlm_lck_denied_nolocks; 38 return nlm_lck_denied_nolocks;
39 39
40 /* Obtain host handle */ 40 /* Obtain host handle */
41 if (!(host = nlmsvc_lookup_host(rqstp)) 41 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
42 || (argp->monitor && nsm_monitor(host) < 0)) 42 || (argp->monitor && nsm_monitor(host) < 0))
43 goto no_locks; 43 goto no_locks;
44 *hostp = host; 44 *hostp = host;
@@ -260,7 +260,9 @@ static int nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *a
260 struct nlm_rqst *call; 260 struct nlm_rqst *call;
261 int stat; 261 int stat;
262 262
263 host = nlmsvc_lookup_host(rqstp); 263 host = nlmsvc_lookup_host(rqstp,
264 argp->lock.caller,
265 argp->lock.len);
264 if (host == NULL) 266 if (host == NULL)
265 return rpc_system_err; 267 return rpc_system_err;
266 268
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 93c00ee7189d..3127ae9e435c 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -179,7 +179,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file,
179 struct nlm_rqst *call = NULL; 179 struct nlm_rqst *call = NULL;
180 180
181 /* Create host handle for callback */ 181 /* Create host handle for callback */
182 host = nlmsvc_lookup_host(rqstp); 182 host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
183 if (host == NULL) 183 if (host == NULL)
184 return NULL; 184 return NULL;
185 185
@@ -451,6 +451,7 @@ nlmsvc_testlock(struct nlm_file *file, struct nlm_lock *lock,
451 (long long)conflock->fl.fl_start, 451 (long long)conflock->fl.fl_start,
452 (long long)conflock->fl.fl_end); 452 (long long)conflock->fl.fl_end);
453 conflock->caller = "somehost"; /* FIXME */ 453 conflock->caller = "somehost"; /* FIXME */
454 conflock->len = strlen(conflock->caller);
454 conflock->oh.len = 0; /* don't return OH info */ 455 conflock->oh.len = 0; /* don't return OH info */
455 conflock->svid = conflock->fl.fl_pid; 456 conflock->svid = conflock->fl.fl_pid;
456 return nlm_lck_denied; 457 return nlm_lck_denied;
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 452eb5e5ea44..12291ab1e722 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -66,7 +66,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
66 return nlm_lck_denied_nolocks; 66 return nlm_lck_denied_nolocks;
67 67
68 /* Obtain host handle */ 68 /* Obtain host handle */
69 if (!(host = nlmsvc_lookup_host(rqstp)) 69 if (!(host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len))
70 || (argp->monitor && nsm_monitor(host) < 0)) 70 || (argp->monitor && nsm_monitor(host) < 0))
71 goto no_locks; 71 goto no_locks;
72 *hostp = host; 72 *hostp = host;
@@ -287,7 +287,9 @@ static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *ar
287 struct nlm_rqst *call; 287 struct nlm_rqst *call;
288 int stat; 288 int stat;
289 289
290 host = nlmsvc_lookup_host(rqstp); 290 host = nlmsvc_lookup_host(rqstp,
291 argp->lock.caller,
292 argp->lock.len);
291 if (host == NULL) 293 if (host == NULL)
292 return rpc_system_err; 294 return rpc_system_err;
293 295