aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlga Kornievskaia <aglo@citi.umich.edu>2008-12-23 16:17:40 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-12-23 16:17:40 -0500
commit608207e8884e083ad8b8d33eda868da70f0d63e8 (patch)
tree86073f5f2e4a550bb1efe395954abe3fa91a555e
parent68e76ad0baf8f5d5060377c2423ee6eed5c63057 (diff)
rpc: pass target name down to rpc level on callbacks
The rpc client needs to know the principal that the setclientid was done as, so it can tell gssd who to authenticate to. Signed-off-by: Olga Kornievskaia <aglo@citi.umich.edu> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfsd/nfs4callback.c6
-rw-r--r--include/linux/sunrpc/clnt.h2
-rw-r--r--net/sunrpc/clnt.c16
3 files changed, 24 insertions, 0 deletions
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 094747a1227c..3ca141782145 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -384,6 +384,7 @@ static int do_probe_callback(void *data)
384 .version = nfs_cb_version[1]->number, 384 .version = nfs_cb_version[1]->number,
385 .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */ 385 .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */
386 .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), 386 .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET),
387 .client_name = clp->cl_principal,
387 }; 388 };
388 struct rpc_message msg = { 389 struct rpc_message msg = {
389 .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], 390 .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
@@ -392,6 +393,11 @@ static int do_probe_callback(void *data)
392 struct rpc_clnt *client; 393 struct rpc_clnt *client;
393 int status; 394 int status;
394 395
396 if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5)) {
397 status = nfserr_cb_path_down;
398 goto out_err;
399 }
400
395 /* Initialize address */ 401 /* Initialize address */
396 memset(&addr, 0, sizeof(addr)); 402 memset(&addr, 0, sizeof(addr));
397 addr.sin_family = AF_INET; 403 addr.sin_family = AF_INET;
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 6f0ee1b84a4f..c39a21040dcb 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -58,6 +58,7 @@ struct rpc_clnt {
58 struct rpc_timeout cl_timeout_default; 58 struct rpc_timeout cl_timeout_default;
59 struct rpc_program * cl_program; 59 struct rpc_program * cl_program;
60 char cl_inline_name[32]; 60 char cl_inline_name[32];
61 char *cl_principal; /* target to authenticate to */
61}; 62};
62 63
63/* 64/*
@@ -108,6 +109,7 @@ struct rpc_create_args {
108 u32 version; 109 u32 version;
109 rpc_authflavor_t authflavor; 110 rpc_authflavor_t authflavor;
110 unsigned long flags; 111 unsigned long flags;
112 char *client_name;
111}; 113};
112 114
113/* Values for "flags" field */ 115/* Values for "flags" field */
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4895c341e46d..347f2a25abb6 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -197,6 +197,12 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
197 197
198 clnt->cl_rtt = &clnt->cl_rtt_default; 198 clnt->cl_rtt = &clnt->cl_rtt_default;
199 rpc_init_rtt(&clnt->cl_rtt_default, clnt->cl_timeout->to_initval); 199 rpc_init_rtt(&clnt->cl_rtt_default, clnt->cl_timeout->to_initval);
200 clnt->cl_principal = NULL;
201 if (args->client_name) {
202 clnt->cl_principal = kstrdup(args->client_name, GFP_KERNEL);
203 if (!clnt->cl_principal)
204 goto out_no_principal;
205 }
200 206
201 kref_init(&clnt->cl_kref); 207 kref_init(&clnt->cl_kref);
202 208
@@ -226,6 +232,8 @@ out_no_auth:
226 rpc_put_mount(); 232 rpc_put_mount();
227 } 233 }
228out_no_path: 234out_no_path:
235 kfree(clnt->cl_principal);
236out_no_principal:
229 rpc_free_iostats(clnt->cl_metrics); 237 rpc_free_iostats(clnt->cl_metrics);
230out_no_stats: 238out_no_stats:
231 if (clnt->cl_server != clnt->cl_inline_name) 239 if (clnt->cl_server != clnt->cl_inline_name)
@@ -354,6 +362,11 @@ rpc_clone_client(struct rpc_clnt *clnt)
354 new->cl_metrics = rpc_alloc_iostats(clnt); 362 new->cl_metrics = rpc_alloc_iostats(clnt);
355 if (new->cl_metrics == NULL) 363 if (new->cl_metrics == NULL)
356 goto out_no_stats; 364 goto out_no_stats;
365 if (clnt->cl_principal) {
366 new->cl_principal = kstrdup(clnt->cl_principal, GFP_KERNEL);
367 if (new->cl_principal == NULL)
368 goto out_no_principal;
369 }
357 kref_init(&new->cl_kref); 370 kref_init(&new->cl_kref);
358 err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name); 371 err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
359 if (err != 0) 372 if (err != 0)
@@ -366,6 +379,8 @@ rpc_clone_client(struct rpc_clnt *clnt)
366 rpciod_up(); 379 rpciod_up();
367 return new; 380 return new;
368out_no_path: 381out_no_path:
382 kfree(new->cl_principal);
383out_no_principal:
369 rpc_free_iostats(new->cl_metrics); 384 rpc_free_iostats(new->cl_metrics);
370out_no_stats: 385out_no_stats:
371 kfree(new); 386 kfree(new);
@@ -417,6 +432,7 @@ rpc_free_client(struct kref *kref)
417out_free: 432out_free:
418 rpc_unregister_client(clnt); 433 rpc_unregister_client(clnt);
419 rpc_free_iostats(clnt->cl_metrics); 434 rpc_free_iostats(clnt->cl_metrics);
435 kfree(clnt->cl_principal);
420 clnt->cl_metrics = NULL; 436 clnt->cl_metrics = NULL;
421 xprt_put(clnt->cl_xprt); 437 xprt_put(clnt->cl_xprt);
422 rpciod_down(); 438 rpciod_down();