Commit 7da18bcc authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

tls: rx: don't track the async count

We track both if the last record was handled by async crypto
and how many records were async. This is not necessary. We
implicitly assume once crypto goes async it will stay that
way, otherwise we'd reorder records. So just track if we're
in async mode, the exact number of records is not necessary.

This change also forces us into "async" mode more consistently
in case crypto ever decided to interleave async and sync.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc8da80f
...@@ -1751,13 +1751,13 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1751,13 +1751,13 @@ int tls_sw_recvmsg(struct sock *sk,
struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
struct tls_prot_info *prot = &tls_ctx->prot_info; struct tls_prot_info *prot = &tls_ctx->prot_info;
struct sk_psock *psock; struct sk_psock *psock;
int num_async, pending;
unsigned char control = 0; unsigned char control = 0;
ssize_t decrypted = 0; ssize_t decrypted = 0;
struct strp_msg *rxm; struct strp_msg *rxm;
struct tls_msg *tlm; struct tls_msg *tlm;
struct sk_buff *skb; struct sk_buff *skb;
ssize_t copied = 0; ssize_t copied = 0;
bool async = false;
int target, err = 0; int target, err = 0;
long timeo; long timeo;
bool is_kvec = iov_iter_is_kvec(&msg->msg_iter); bool is_kvec = iov_iter_is_kvec(&msg->msg_iter);
...@@ -1789,12 +1789,10 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1789,12 +1789,10 @@ int tls_sw_recvmsg(struct sock *sk,
timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
decrypted = 0; decrypted = 0;
num_async = 0;
while (len && (decrypted + copied < target || ctx->recv_pkt)) { while (len && (decrypted + copied < target || ctx->recv_pkt)) {
struct tls_decrypt_arg darg = {}; struct tls_decrypt_arg darg = {};
bool retain_skb = false; bool retain_skb = false;
int to_decrypt, chunk; int to_decrypt, chunk;
bool async;
skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err); skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err);
if (!skb) { if (!skb) {
...@@ -1834,10 +1832,8 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1834,10 +1832,8 @@ int tls_sw_recvmsg(struct sock *sk,
goto recv_end; goto recv_end;
} }
if (err == -EINPROGRESS) { if (err == -EINPROGRESS)
async = true; async = true;
num_async++;
}
/* If the type of records being processed is not known yet, /* If the type of records being processed is not known yet,
* set it to record type just dequeued. If it is already known, * set it to record type just dequeued. If it is already known,
...@@ -1911,7 +1907,9 @@ int tls_sw_recvmsg(struct sock *sk, ...@@ -1911,7 +1907,9 @@ int tls_sw_recvmsg(struct sock *sk,
} }
recv_end: recv_end:
if (num_async) { if (async) {
int pending;
/* Wait for all previously submitted records to be decrypted */ /* Wait for all previously submitted records to be decrypted */
spin_lock_bh(&ctx->decrypt_compl_lock); spin_lock_bh(&ctx->decrypt_compl_lock);
reinit_completion(&ctx->async_wait.completion); reinit_completion(&ctx->async_wait.completion);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment