Skip to content

Commit

Permalink
SUNRPC: Ignore data_ready callbacks during TLS handshakes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Jun 19, 2023
1 parent 1207265 commit 0d3ca07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/sunrpc/xprtsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
6 changes: 6 additions & 0 deletions net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 0d3ca07

Please sign in to comment.