diff mbox series

SUNRPC: Handle -ETIMEDOUT return from tlshd

Message ID 614d3c3bcceeedb933400bdc00f812518c05a4a6.1739294902.git.bcodding@redhat.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series SUNRPC: Handle -ETIMEDOUT return from tlshd | expand

Commit Message

Benjamin Coddington Feb. 11, 2025, 5:31 p.m. UTC
If the TLS handshake attempt returns -ETIMEDOUT, we currently translate
that error into -EACCES.  This becomes problematic for cases where the RPC
layer is attempting to re-connect in paths that don't resonably handle
-EACCES, for example: writeback.  The RPC layer can handle -ETIMEDOUT quite
well, however - so if the handshake returns this error let's just pass it
along.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 net/sunrpc/xprtsock.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)


base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04

Comments

Anna Schumaker Feb. 12, 2025, 8:38 p.m. UTC | #1
Hi Ben,

On Tue, Feb 11, 2025 at 12:32 PM Benjamin Coddington
<bcodding@redhat.com> wrote:
>
> If the TLS handshake attempt returns -ETIMEDOUT, we currently translate
> that error into -EACCES.  This becomes problematic for cases where the RPC
> layer is attempting to re-connect in paths that don't resonably handle
> -EACCES, for example: writeback.  The RPC layer can handle -ETIMEDOUT quite
> well, however - so if the handshake returns this error let's just pass it
> along.

Do you think it would be reasonable to add:
        Fixes: 75eb6af7acdf ("SUNRPC: Add a TCP-with-TLS RPC transport class")
to this patch?

Thanks,
Anna

>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  net/sunrpc/xprtsock.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index c60936d8cef7..6b80b2aaf763 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -2581,7 +2581,15 @@ static void xs_tls_handshake_done(void *data, int status, key_serial_t peerid)
>         struct sock_xprt *lower_transport =
>                                 container_of(lower_xprt, struct sock_xprt, xprt);
>
> -       lower_transport->xprt_err = status ? -EACCES : 0;
> +       switch (status) {
> +       case 0:
> +       case -EACCES:
> +       case -ETIMEDOUT:
> +               lower_transport->xprt_err = status;
> +               break;
> +       default:
> +               lower_transport->xprt_err = -EACCES;
> +       }
>         complete(&lower_transport->handshake_done);
>         xprt_put(lower_xprt);
>  }
>
> base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
> --
> 2.47.0
>
Benjamin Coddington Feb. 12, 2025, 11:02 p.m. UTC | #2
On 12 Feb 2025, at 15:38, Anna Schumaker wrote:

> Hi Ben,
>
> On Tue, Feb 11, 2025 at 12:32 PM Benjamin Coddington
> <bcodding@redhat.com> wrote:
>>
>> If the TLS handshake attempt returns -ETIMEDOUT, we currently translate
>> that error into -EACCES.  This becomes problematic for cases where the RPC
>> layer is attempting to re-connect in paths that don't resonably handle
>> -EACCES, for example: writeback.  The RPC layer can handle -ETIMEDOUT quite
>> well, however - so if the handshake returns this error let's just pass it
>> along.
>
> Do you think it would be reasonable to add:
>         Fixes: 75eb6af7acdf ("SUNRPC: Add a TCP-with-TLS RPC transport class")
> to this patch?

Yes, that's probably reasonable.  Thanks Anna, I should have added it.

Ben
diff mbox series

Patch

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index c60936d8cef7..6b80b2aaf763 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2581,7 +2581,15 @@  static void xs_tls_handshake_done(void *data, int status, key_serial_t peerid)
 	struct sock_xprt *lower_transport =
 				container_of(lower_xprt, struct sock_xprt, xprt);
 
-	lower_transport->xprt_err = status ? -EACCES : 0;
+	switch (status) {
+	case 0:
+	case -EACCES:
+	case -ETIMEDOUT:
+		lower_transport->xprt_err = status;
+		break;
+	default:
+		lower_transport->xprt_err = -EACCES;
+	}
 	complete(&lower_transport->handshake_done);
 	xprt_put(lower_xprt);
 }