Skip to content

Commit ccdc28f

Browse files
Stanislav KinsburskyTrond Myklebust
authored andcommitted
SUNRPC: handle GSS AUTH pipes by network namespace aware routines
This patch makes RPC GSS PipeFs pipes allocated in it's RPC client owner network namespace context. Pipes creation and destruction now done in separated functions, which takes care about PipeFS superblock locking. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 0157d02 commit ccdc28f

1 file changed

Lines changed: 73 additions & 22 deletions

File tree

‎net/sunrpc/auth_gss/auth_gss.c‎

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,73 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg)
757757
}
758758
}
759759

760+
static void gss_pipes_dentries_destroy(struct rpc_auth *auth)
761+
{
762+
struct gss_auth *gss_auth;
763+
764+
gss_auth = container_of(auth, struct gss_auth, rpc_auth);
765+
rpc_unlink(gss_auth->pipe[0]->dentry);
766+
rpc_unlink(gss_auth->pipe[1]->dentry);
767+
}
768+
769+
static int gss_pipes_dentries_create(struct rpc_auth *auth)
770+
{
771+
int err;
772+
struct gss_auth *gss_auth;
773+
struct rpc_clnt *clnt;
774+
775+
gss_auth = container_of(auth, struct gss_auth, rpc_auth);
776+
clnt = gss_auth->client;
777+
778+
gss_auth->pipe[1]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
779+
"gssd",
780+
clnt, gss_auth->pipe[1]);
781+
if (IS_ERR(gss_auth->pipe[1]->dentry))
782+
return PTR_ERR(gss_auth->pipe[1]->dentry);
783+
gss_auth->pipe[0]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
784+
gss_auth->mech->gm_name,
785+
clnt, gss_auth->pipe[0]);
786+
if (IS_ERR(gss_auth->pipe[0]->dentry)) {
787+
err = PTR_ERR(gss_auth->pipe[0]->dentry);
788+
goto err_unlink_pipe_1;
789+
}
790+
return 0;
791+
792+
err_unlink_pipe_1:
793+
rpc_unlink(gss_auth->pipe[1]->dentry);
794+
return err;
795+
}
796+
797+
static void gss_pipes_dentries_destroy_net(struct rpc_clnt *clnt,
798+
struct rpc_auth *auth)
799+
{
800+
struct net *net = clnt->cl_xprt->xprt_net;
801+
struct super_block *sb;
802+
803+
sb = rpc_get_sb_net(net);
804+
if (sb) {
805+
if (clnt->cl_path.dentry)
806+
gss_pipes_dentries_destroy(auth);
807+
rpc_put_sb_net(net);
808+
}
809+
}
810+
811+
static int gss_pipes_dentries_create_net(struct rpc_clnt *clnt,
812+
struct rpc_auth *auth)
813+
{
814+
struct net *net = clnt->cl_xprt->xprt_net;
815+
struct super_block *sb;
816+
int err = 0;
817+
818+
sb = rpc_get_sb_net(net);
819+
if (sb) {
820+
if (clnt->cl_path.dentry)
821+
err = gss_pipes_dentries_create(auth);
822+
rpc_put_sb_net(net);
823+
}
824+
return err;
825+
}
826+
760827
/*
761828
* NOTE: we have the opportunity to use different
762829
* parameters based on the input flavor (which must be a pseudoflavor)
@@ -812,31 +879,16 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
812879
err = PTR_ERR(gss_auth->pipe[0]);
813880
goto err_destroy_pipe_1;
814881
}
815-
816-
gss_auth->pipe[1]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
817-
"gssd",
818-
clnt, gss_auth->pipe[1]);
819-
if (IS_ERR(gss_auth->pipe[1]->dentry)) {
820-
err = PTR_ERR(gss_auth->pipe[1]->dentry);
882+
err = gss_pipes_dentries_create_net(clnt, auth);
883+
if (err)
821884
goto err_destroy_pipe_0;
822-
}
823-
824-
gss_auth->pipe[0]->dentry = rpc_mkpipe_dentry(clnt->cl_path.dentry,
825-
gss_auth->mech->gm_name,
826-
clnt, gss_auth->pipe[0]);
827-
if (IS_ERR(gss_auth->pipe[0]->dentry)) {
828-
err = PTR_ERR(gss_auth->pipe[0]->dentry);
829-
goto err_unlink_pipe_1;
830-
}
831885
err = rpcauth_init_credcache(auth);
832886
if (err)
833-
goto err_unlink_pipe_0;
887+
goto err_unlink_pipes;
834888

835889
return auth;
836-
err_unlink_pipe_0:
837-
rpc_unlink(gss_auth->pipe[0]->dentry);
838-
err_unlink_pipe_1:
839-
rpc_unlink(gss_auth->pipe[1]->dentry);
890+
err_unlink_pipes:
891+
gss_pipes_dentries_destroy_net(clnt, auth);
840892
err_destroy_pipe_0:
841893
rpc_destroy_pipe_data(gss_auth->pipe[0]);
842894
err_destroy_pipe_1:
@@ -853,8 +905,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
853905
static void
854906
gss_free(struct gss_auth *gss_auth)
855907
{
856-
rpc_unlink(gss_auth->pipe[0]->dentry);
857-
rpc_unlink(gss_auth->pipe[1]->dentry);
908+
gss_pipes_dentries_destroy_net(gss_auth->client, &gss_auth->rpc_auth);
858909
rpc_destroy_pipe_data(gss_auth->pipe[0]);
859910
rpc_destroy_pipe_data(gss_auth->pipe[1]);
860911
gss_mech_put(gss_auth->mech);

0 commit comments

Comments
 (0)