Skip to contentSkip to conversation

lockd: separate client and server hosts

PATCH New Patrice DUMAS - DOCT 1 participant 1 message May 22, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockd: separate client and server hosts

Hi,
I implemented what Trond suggested for separating client and server hosts. A very basic test (all on the same host...) shown no problem.

It seems to me that the existing code should have been associated with bugs, as the hosts known by the server were registered in the hash with their clnt ref, or with the address of the host. There should have been trouble when the server found a bad one. Maybe it never showed up or in very rare cases (or maybe I misunderstand some part of the code) (it is only a supposition as I haven't thought about a real case where such a problem could happen).

Pat

fs/lockd/host.c +1 -1
diff -u --recursive --new-file linux-2.4.18.trond_patch/fs/lockd/host.c linux-2.4.18.clean-separated_hosts/fs/lockd/host.c
@@ -62,7 +62,7 @@
 nlm_match_host(struct nlm_host *host, struct svc_client *clnt,
 					struct sockaddr_in *sin)
 {
-	if (clnt)
+	if (clnt || host->h_exportent)
 		return host->h_exportent == clnt;
 	return nlm_cmp_addr(&host->h_addr, sin);
 }
fs/lockd/svc4proc.c +3 -1
diff -u --recursive --new-file linux-2.4.18.trond_patch/fs/lockd/svc4proc.c linux-2.4.18.clean-separated_hosts/fs/lockd/svc4proc.c
@@ -470,8 +470,10 @@
 	if (!(call = nlmclnt_alloc_call()))
 		return rpc_system_err;
 
-	host = nlmclnt_lookup_host(&rqstp->rq_addr,
+	if (proc == NLMPROC_GRANTED_RES)
+		host = nlmclnt_lookup_host(&rqstp->rq_addr,
 				rqstp->rq_prot, rqstp->rq_vers);
+	else host = nlmsvc_lookup_host(rqstp);
 	if (!host) {
 		kfree(call);
 		return rpc_system_err;
fs/lockd/svclock.c +1 -2
diff -u --recursive --new-file linux-2.4.18.trond_patch/fs/lockd/svclock.c linux-2.4.18.clean-separated_hosts/fs/lockd/svclock.c
@@ -176,8 +176,7 @@
 	struct nlm_rqst		*call;
 
 	/* Create host handle for callback */
-	host = nlmclnt_lookup_host(&rqstp->rq_addr,
-				rqstp->rq_prot, rqstp->rq_vers);
+	host = nlmsvc_lookup_host(rqstp);
 	if (host == NULL)
 		return NULL;
 
fs/lockd/svcproc.c +3 -1
diff -u --recursive --new-file linux-2.4.18.trond_patch/fs/lockd/svcproc.c linux-2.4.18.clean-separated_hosts/fs/lockd/svcproc.c
@@ -498,8 +498,10 @@
 	if (!(call = nlmclnt_alloc_call()))
 		return rpc_system_err;
 
-	host = nlmclnt_lookup_host(&rqstp->rq_addr,
+	if (proc == NLMPROC_GRANTED_RES)
+		host = nlmclnt_lookup_host(&rqstp->rq_addr,
 				rqstp->rq_prot, rqstp->rq_vers);
+	else host = nlmsvc_lookup_host(rqstp);
 	if (!host) {
 		kfree(call);
 		return rpc_system_err;