aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-23 14:42:29 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-30 09:19:37 -0400
commite726340ac9cf6bb5b3f92a064664e10cd2b748de (patch)
tree0b0003144c4f1e174d8902eb35ecf6a54c2c43ee
parentc2190661039b3817b4cc1cbfea620b3f7dbe5cd8 (diff)
RPCSEC_GSS: Further cleanups
Don't pass the rpc_client as a parameter, when what we really want is the net namespace. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 672a67ff6449..632380336660 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -77,6 +77,7 @@ struct gss_auth {
77 struct gss_api_mech *mech; 77 struct gss_api_mech *mech;
78 enum rpc_gss_svc service; 78 enum rpc_gss_svc service;
79 struct rpc_clnt *client; 79 struct rpc_clnt *client;
80 struct net *net;
80 /* 81 /*
81 * There are two upcall pipes; dentry[1], named "gssd", is used 82 * There are two upcall pipes; dentry[1], named "gssd", is used
82 * for the new text-based upcall; dentry[0] is named after the 83 * for the new text-based upcall; dentry[0] is named after the
@@ -295,7 +296,7 @@ static void put_pipe_version(struct net *net)
295static void 296static void
296gss_release_msg(struct gss_upcall_msg *gss_msg) 297gss_release_msg(struct gss_upcall_msg *gss_msg)
297{ 298{
298 struct net *net = rpc_net_ns(gss_msg->auth->client); 299 struct net *net = gss_msg->auth->net;
299 if (!atomic_dec_and_test(&gss_msg->count)) 300 if (!atomic_dec_and_test(&gss_msg->count))
300 return; 301 return;
301 put_pipe_version(net); 302 put_pipe_version(net);
@@ -441,7 +442,7 @@ static void gss_encode_v1_msg(struct gss_upcall_msg *gss_msg,
441} 442}
442 443
443static struct gss_upcall_msg * 444static struct gss_upcall_msg *
444gss_alloc_msg(struct gss_auth *gss_auth, struct rpc_clnt *clnt, 445gss_alloc_msg(struct gss_auth *gss_auth,
445 kuid_t uid, const char *service_name) 446 kuid_t uid, const char *service_name)
446{ 447{
447 struct gss_upcall_msg *gss_msg; 448 struct gss_upcall_msg *gss_msg;
@@ -450,7 +451,7 @@ gss_alloc_msg(struct gss_auth *gss_auth, struct rpc_clnt *clnt,
450 gss_msg = kzalloc(sizeof(*gss_msg), GFP_NOFS); 451 gss_msg = kzalloc(sizeof(*gss_msg), GFP_NOFS);
451 if (gss_msg == NULL) 452 if (gss_msg == NULL)
452 return ERR_PTR(-ENOMEM); 453 return ERR_PTR(-ENOMEM);
453 vers = get_pipe_version(rpc_net_ns(clnt)); 454 vers = get_pipe_version(gss_auth->net);
454 if (vers < 0) { 455 if (vers < 0) {
455 kfree(gss_msg); 456 kfree(gss_msg);
456 return ERR_PTR(vers); 457 return ERR_PTR(vers);
@@ -472,14 +473,14 @@ gss_alloc_msg(struct gss_auth *gss_auth, struct rpc_clnt *clnt,
472} 473}
473 474
474static struct gss_upcall_msg * 475static struct gss_upcall_msg *
475gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cred *cred) 476gss_setup_upcall(struct gss_auth *gss_auth, struct rpc_cred *cred)
476{ 477{
477 struct gss_cred *gss_cred = container_of(cred, 478 struct gss_cred *gss_cred = container_of(cred,
478 struct gss_cred, gc_base); 479 struct gss_cred, gc_base);
479 struct gss_upcall_msg *gss_new, *gss_msg; 480 struct gss_upcall_msg *gss_new, *gss_msg;
480 kuid_t uid = cred->cr_uid; 481 kuid_t uid = cred->cr_uid;
481 482
482 gss_new = gss_alloc_msg(gss_auth, clnt, uid, gss_cred->gc_principal); 483 gss_new = gss_alloc_msg(gss_auth, uid, gss_cred->gc_principal);
483 if (IS_ERR(gss_new)) 484 if (IS_ERR(gss_new))
484 return gss_new; 485 return gss_new;
485 gss_msg = gss_add_msg(gss_new); 486 gss_msg = gss_add_msg(gss_new);
@@ -520,7 +521,7 @@ gss_refresh_upcall(struct rpc_task *task)
520 521
521 dprintk("RPC: %5u %s for uid %u\n", 522 dprintk("RPC: %5u %s for uid %u\n",
522 task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_uid)); 523 task->tk_pid, __func__, from_kuid(&init_user_ns, cred->cr_uid));
523 gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); 524 gss_msg = gss_setup_upcall(gss_auth, cred);
524 if (PTR_ERR(gss_msg) == -EAGAIN) { 525 if (PTR_ERR(gss_msg) == -EAGAIN) {
525 /* XXX: warning on the first, under the assumption we 526 /* XXX: warning on the first, under the assumption we
526 * shouldn't normally hit this case on a refresh. */ 527 * shouldn't normally hit this case on a refresh. */
@@ -559,7 +560,7 @@ out:
559static inline int 560static inline int
560gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) 561gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
561{ 562{
562 struct net *net = rpc_net_ns(gss_auth->client); 563 struct net *net = gss_auth->net;
563 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 564 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
564 struct rpc_pipe *pipe; 565 struct rpc_pipe *pipe;
565 struct rpc_cred *cred = &gss_cred->gc_base; 566 struct rpc_cred *cred = &gss_cred->gc_base;
@@ -576,7 +577,7 @@ retry:
576 timeout = 15 * HZ; 577 timeout = 15 * HZ;
577 if (!sn->gssd_running) 578 if (!sn->gssd_running)
578 timeout = HZ >> 2; 579 timeout = HZ >> 2;
579 gss_msg = gss_setup_upcall(gss_auth->client, gss_auth, cred); 580 gss_msg = gss_setup_upcall(gss_auth, cred);
580 if (PTR_ERR(gss_msg) == -EAGAIN) { 581 if (PTR_ERR(gss_msg) == -EAGAIN) {
581 err = wait_event_interruptible_timeout(pipe_version_waitqueue, 582 err = wait_event_interruptible_timeout(pipe_version_waitqueue,
582 sn->pipe_version >= 0, timeout); 583 sn->pipe_version >= 0, timeout);
@@ -832,7 +833,9 @@ err_unlink_pipe_1:
832static void gss_pipes_dentries_destroy_net(struct rpc_clnt *clnt, 833static void gss_pipes_dentries_destroy_net(struct rpc_clnt *clnt,
833 struct rpc_auth *auth) 834 struct rpc_auth *auth)
834{ 835{
835 struct net *net = rpc_net_ns(clnt); 836 struct gss_auth *gss_auth = container_of(auth, struct gss_auth,
837 rpc_auth);
838 struct net *net = gss_auth->net;
836 struct super_block *sb; 839 struct super_block *sb;
837 840
838 sb = rpc_get_sb_net(net); 841 sb = rpc_get_sb_net(net);
@@ -846,7 +849,9 @@ static void gss_pipes_dentries_destroy_net(struct rpc_clnt *clnt,
846static int gss_pipes_dentries_create_net(struct rpc_clnt *clnt, 849static int gss_pipes_dentries_create_net(struct rpc_clnt *clnt,
847 struct rpc_auth *auth) 850 struct rpc_auth *auth)
848{ 851{
849 struct net *net = rpc_net_ns(clnt); 852 struct gss_auth *gss_auth = container_of(auth, struct gss_auth,
853 rpc_auth);
854 struct net *net = gss_auth->net;
850 struct super_block *sb; 855 struct super_block *sb;
851 int err = 0; 856 int err = 0;
852 857
@@ -884,11 +889,12 @@ gss_create(struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
884 goto err_free; 889 goto err_free;
885 } 890 }
886 gss_auth->client = clnt; 891 gss_auth->client = clnt;
892 gss_auth->net = get_net(rpc_net_ns(clnt));
887 err = -EINVAL; 893 err = -EINVAL;
888 gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor); 894 gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor);
889 if (!gss_auth->mech) { 895 if (!gss_auth->mech) {
890 dprintk("RPC: Pseudoflavor %d not found!\n", flavor); 896 dprintk("RPC: Pseudoflavor %d not found!\n", flavor);
891 goto err_free; 897 goto err_put_net;
892 } 898 }
893 gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor); 899 gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor);
894 if (gss_auth->service == 0) 900 if (gss_auth->service == 0)
@@ -936,6 +942,8 @@ err_destroy_pipe_1:
936 rpc_destroy_pipe_data(gss_auth->pipe[1]); 942 rpc_destroy_pipe_data(gss_auth->pipe[1]);
937err_put_mech: 943err_put_mech:
938 gss_mech_put(gss_auth->mech); 944 gss_mech_put(gss_auth->mech);
945err_put_net:
946 put_net(gss_auth->net);
939err_free: 947err_free:
940 kfree(gss_auth->target_name); 948 kfree(gss_auth->target_name);
941 kfree(gss_auth); 949 kfree(gss_auth);
@@ -951,6 +959,7 @@ gss_free(struct gss_auth *gss_auth)
951 rpc_destroy_pipe_data(gss_auth->pipe[0]); 959 rpc_destroy_pipe_data(gss_auth->pipe[0]);
952 rpc_destroy_pipe_data(gss_auth->pipe[1]); 960 rpc_destroy_pipe_data(gss_auth->pipe[1]);
953 gss_mech_put(gss_auth->mech); 961 gss_mech_put(gss_auth->mech);
962 put_net(gss_auth->net);
954 kfree(gss_auth->target_name); 963 kfree(gss_auth->target_name);
955 964
956 kfree(gss_auth); 965 kfree(gss_auth);