diff mbox series

SUNRPC: @clnt specifies auth flavor of RPC ping

Message ID 168479039188.9346.7280595186663128472.stgit@oracle-102.nfsv4bat.org (mailing list archive)
State New, archived
Headers show
Series SUNRPC: @clnt specifies auth flavor of RPC ping | expand

Commit Message

Chuck Lever May 22, 2023, 9:21 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

When connecting, we don't want to send both a NULL ping and an
RPC_AUTH_TLS probe, because, except for the detection of RPC-with-
TLS support, both serve effectively the same purpose.

Modify rpc_ping() so it can send a TLS probe when @clnt's flavor
is RPC_AUTH_TLS. All other callers continue to use AUTH_NONE.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/sunrpc/clnt.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Does it help to replace 4/12 with this?  Compile-tested only.

Comments

Chuck Lever May 23, 2023, 2:37 a.m. UTC | #1
On Mon, May 22, 2023 at 05:21:22PM -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> When connecting, we don't want to send both a NULL ping and an
> RPC_AUTH_TLS probe, because, except for the detection of RPC-with-
> TLS support, both serve effectively the same purpose.
> 
> Modify rpc_ping() so it can send a TLS probe when @clnt's flavor
> is RPC_AUTH_TLS. All other callers continue to use AUTH_NONE.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  net/sunrpc/clnt.c |   14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> Does it help to replace 4/12 with this?  Compile-tested only.
> 
> 
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index 4cdb539b5854..274ad74cb2bd 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -2826,10 +2826,22 @@ EXPORT_SYMBOL_GPL(rpc_call_null);
>  
>  static int rpc_ping(struct rpc_clnt *clnt)
>  {
> +	struct rpc_message msg = {
> +		.rpc_proc = &rpcproc_null,
> +	};
> +	struct rpc_task_setup task_setup_data = {
> +		.rpc_client = clnt,
> +		.rpc_message = &msg,
> +		.callback_ops = &rpc_null_ops,
> +		.flags = RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
> +	};
>  	struct rpc_task	*task;
>  	int status;
>  
> -	task = rpc_call_null_helper(clnt, NULL, NULL, 0, NULL, NULL);
> +	if (clnt->cl_auth->au_flavor != RPC_AUTH_TLS)
> +		flags |= RPC_TASK_NULLCREDS;

Obviously this needs to be:

		task_setup_data.flags |= RPC_TASK_NULLCREDS;

This has been fixed in the topic-rpc-with-tls-upcall branch.

> +
> +	task = rpc_run_task(&task_setup_data);
>  	if (IS_ERR(task))
>  		return PTR_ERR(task);
>  	status = task->tk_status;
> 
>
Trond Myklebust May 23, 2023, 4:04 a.m. UTC | #2
On Mon, 2023-05-22 at 22:37 -0400, Chuck Lever wrote:
> On Mon, May 22, 2023 at 05:21:22PM -0400, Chuck Lever wrote:
> > From: Chuck Lever <chuck.lever@oracle.com>
> > 
> > When connecting, we don't want to send both a NULL ping and an
> > RPC_AUTH_TLS probe, because, except for the detection of RPC-with-
> > TLS support, both serve effectively the same purpose.
> > 
> > Modify rpc_ping() so it can send a TLS probe when @clnt's flavor
> > is RPC_AUTH_TLS. All other callers continue to use AUTH_NONE.
> > 
> > Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> > ---
> >  net/sunrpc/clnt.c |   14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > Does it help to replace 4/12 with this?  Compile-tested only.
> > 
> > 
> > diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> > index 4cdb539b5854..274ad74cb2bd 100644
> > --- a/net/sunrpc/clnt.c
> > +++ b/net/sunrpc/clnt.c
> > @@ -2826,10 +2826,22 @@ EXPORT_SYMBOL_GPL(rpc_call_null);
> >  
> >  static int rpc_ping(struct rpc_clnt *clnt)
> >  {
> > +       struct rpc_message msg = {
> > +               .rpc_proc = &rpcproc_null,
> > +       };
> > +       struct rpc_task_setup task_setup_data = {
> > +               .rpc_client = clnt,
> > +               .rpc_message = &msg,
> > +               .callback_ops = &rpc_null_ops,
> > +               .flags = RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
> > +       };
> >         struct rpc_task *task;
> >         int status;
> >  
> > -       task = rpc_call_null_helper(clnt, NULL, NULL, 0, NULL,
> > NULL);
> > +       if (clnt->cl_auth->au_flavor != RPC_AUTH_TLS)
> > +               flags |= RPC_TASK_NULLCREDS;
> 
> Obviously this needs to be:
> 
>                 task_setup_data.flags |= RPC_TASK_NULLCREDS;
> 
> This has been fixed in the topic-rpc-with-tls-upcall branch.

rpc_ping() should not need to know about the existence of AUTH_TLS.

Let's rather add in a struct rpc_authops callback connect_ping() (?)
that knows how to call rpc_ping() with the appropriate creds. For the
AUTH types other than AUTH_TLS, that will be a generic call with the
AUTH_NULL cred.

Then let's get rid of the RPC_TASK_NULLCREDS wart altogether.

> 
> > +
> > +       task = rpc_run_task(&task_setup_data);
> >         if (IS_ERR(task))
> >                 return PTR_ERR(task);
> >         status = task->tk_status;
> > 
> >
diff mbox series

Patch

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4cdb539b5854..274ad74cb2bd 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -2826,10 +2826,22 @@  EXPORT_SYMBOL_GPL(rpc_call_null);
 
 static int rpc_ping(struct rpc_clnt *clnt)
 {
+	struct rpc_message msg = {
+		.rpc_proc = &rpcproc_null,
+	};
+	struct rpc_task_setup task_setup_data = {
+		.rpc_client = clnt,
+		.rpc_message = &msg,
+		.callback_ops = &rpc_null_ops,
+		.flags = RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
+	};
 	struct rpc_task	*task;
 	int status;
 
-	task = rpc_call_null_helper(clnt, NULL, NULL, 0, NULL, NULL);
+	if (clnt->cl_auth->au_flavor != RPC_AUTH_TLS)
+		flags |= RPC_TASK_NULLCREDS;
+
+	task = rpc_run_task(&task_setup_data);
 	if (IS_ERR(task))
 		return PTR_ERR(task);
 	status = task->tk_status;