SUNRPC: Ignore data_ready callbacks during TLS handshakes
authorChuck Lever <chuck.lever@oracle.com>
Wed, 7 Jun 2023 13:58:22 +0000 (09:58 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 19 Jun 2023 16:19:16 +0000 (12:19 -0400)
The RPC header parser doesn't recognize TLS handshake traffic, so it
will close the connection prematurely with an error. To avoid that,
shunt the transport's data_ready callback when there is a TLS
handshake in progress.

The XPRT_SOCK_IGNORE_RECV flag will be toggled by code added in a
subsequent patch.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
include/linux/sunrpc/xprtsock.h
net/sunrpc/xprtsock.c

index 38284f25eddfd3eedbaea20d978095e59ccfdb97..daef030f4848af9b43ea878704eb4330f9becf27 100644 (file)
@@ -90,5 +90,6 @@ struct sock_xprt {
 #define XPRT_SOCK_WAKE_DISCONNECT      (7)
 #define XPRT_SOCK_CONNECT_SENT (8)
 #define XPRT_SOCK_NOSPACE      (9)
+#define XPRT_SOCK_IGNORE_RECV  (10)
 
 #endif /* _LINUX_SUNRPC_XPRTSOCK_H */
index 515328a8dafe1d389bb36aae394dafb5f1ae93cf..0b2739d6e1a095355673b2feae3913142a3cf6f0 100644 (file)
@@ -700,6 +700,8 @@ static void xs_poll_check_readable(struct sock_xprt *transport)
 {
 
        clear_bit(XPRT_SOCK_DATA_READY, &transport->sock_state);
+       if (test_bit(XPRT_SOCK_IGNORE_RECV, &transport->sock_state))
+               return;
        if (!xs_poll_socket_readable(transport))
                return;
        if (!test_and_set_bit(XPRT_SOCK_DATA_READY, &transport->sock_state))
@@ -1385,6 +1387,10 @@ static void xs_data_ready(struct sock *sk)
                trace_xs_data_ready(xprt);
 
                transport->old_data_ready(sk);
+
+               if (test_bit(XPRT_SOCK_IGNORE_RECV, &transport->sock_state))
+                       return;
+
                /* Any data means we had a useful conversation, so
                 * then we don't need to delay the next reconnect
                 */