diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-07-29 07:50:02 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-07-29 07:50:02 +0300 |
commit | 37e26188345b454aaffe05d651ada0dd7f470234 (patch) | |
tree | a1bfe1d82845b51a78ff8c12ef85df6965f13986 /net | |
parent | efe3e6b5aeefaabed9ad5dcb3682b581bf34c187 (diff) | |
parent | e20691fa36c42ff89c2b582f38ca0cc9e3d043ba (diff) | |
download | linux-37e26188345b454aaffe05d651ada0dd7f470234.tar.xz |
Merge branch 'tls-rx-follow-ups-to-rx-work'
Jakub Kicinski says:
====================
tls: rx: follow ups to rx work
A selection of unrelated changes. First some selftest polishing.
Next a change to rcvtimeo handling for locking based on an exchange
with Eric. Follow up to Paolo's comments from yesterday. Last but
not least a fix to a false positive warning, turns out I've been
testing with DEBUG_NET=n this whole time.
====================
Link: https://lore.kernel.org/r/20220727031524.358216-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/tls/tls_strp.c | 2 | ||||
-rw-r--r-- | net/tls/tls_sw.c | 39 |
2 files changed, 21 insertions, 20 deletions
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c index b945288c312e..3f1ec42a5923 100644 --- a/net/tls/tls_strp.c +++ b/net/tls/tls_strp.c @@ -480,7 +480,7 @@ void tls_strp_done(struct tls_strparser *strp) int __init tls_strp_dev_init(void) { - tls_strp_wq = create_singlethread_workqueue("kstrp"); + tls_strp_wq = create_workqueue("tls-strp"); if (unlikely(!tls_strp_wq)) return -ENOMEM; diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 0fc24a5ce208..17db8c8811fa 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1283,11 +1283,14 @@ int tls_sw_sendpage(struct sock *sk, struct page *page, static int tls_rx_rec_wait(struct sock *sk, struct sk_psock *psock, bool nonblock, - bool released, long timeo) + bool released) { struct tls_context *tls_ctx = tls_get_ctx(sk); struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); DEFINE_WAIT_FUNC(wait, woken_wake_function); + long timeo; + + timeo = sock_rcvtimeo(sk, nonblock); while (!tls_strp_msg_ready(ctx)) { if (!sk_psock_queue_empty(psock)) @@ -1308,7 +1311,7 @@ tls_rx_rec_wait(struct sock *sk, struct sk_psock *psock, bool nonblock, if (sock_flag(sk, SOCK_DONE)) return 0; - if (nonblock || !timeo) + if (!timeo) return -EAGAIN; released = true; @@ -1842,8 +1845,8 @@ tls_read_flush_backlog(struct sock *sk, struct tls_prot_info *prot, return sk_flush_backlog(sk); } -static long tls_rx_reader_lock(struct sock *sk, struct tls_sw_context_rx *ctx, - bool nonblock) +static int tls_rx_reader_lock(struct sock *sk, struct tls_sw_context_rx *ctx, + bool nonblock) { long timeo; int err; @@ -1874,7 +1877,7 @@ static long tls_rx_reader_lock(struct sock *sk, struct tls_sw_context_rx *ctx, WRITE_ONCE(ctx->reader_present, 1); - return timeo; + return 0; err_unlock: release_sock(sk); @@ -1913,8 +1916,7 @@ int tls_sw_recvmsg(struct sock *sk, struct tls_msg *tlm; ssize_t copied = 0; bool async = false; - int target, err = 0; - long timeo; + int target, err; bool is_kvec = iov_iter_is_kvec(&msg->msg_iter); bool is_peek = flags & MSG_PEEK; bool released = true; @@ -1925,9 +1927,9 @@ int tls_sw_recvmsg(struct sock *sk, return sock_recv_errqueue(sk, msg, len, SOL_IP, IP_RECVERR); psock = sk_psock_get(sk); - timeo = tls_rx_reader_lock(sk, ctx, flags & MSG_DONTWAIT); - if (timeo < 0) - return timeo; + err = tls_rx_reader_lock(sk, ctx, flags & MSG_DONTWAIT); + if (err < 0) + return err; bpf_strp_enabled = sk_psock_strp_enabled(psock); /* If crypto failed the connection is broken */ @@ -1954,8 +1956,8 @@ int tls_sw_recvmsg(struct sock *sk, struct tls_decrypt_arg darg; int to_decrypt, chunk; - err = tls_rx_rec_wait(sk, psock, flags & MSG_DONTWAIT, released, - timeo); + err = tls_rx_rec_wait(sk, psock, flags & MSG_DONTWAIT, + released); if (err <= 0) { if (psock) { chunk = sk_msg_recvmsg(sk, psock, msg, len, @@ -2024,7 +2026,7 @@ put_on_rx_list_err: bool partially_consumed = chunk > len; struct sk_buff *skb = darg.skb; - DEBUG_NET_WARN_ON_ONCE(darg.skb == tls_strp_msg(ctx)); + DEBUG_NET_WARN_ON_ONCE(darg.skb == ctx->strp.anchor); if (async) { /* TLS 1.2-only, to_decrypt must be text len */ @@ -2131,13 +2133,12 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, struct tls_msg *tlm; struct sk_buff *skb; ssize_t copied = 0; - int err = 0; - long timeo; int chunk; + int err; - timeo = tls_rx_reader_lock(sk, ctx, flags & SPLICE_F_NONBLOCK); - if (timeo < 0) - return timeo; + err = tls_rx_reader_lock(sk, ctx, flags & SPLICE_F_NONBLOCK); + if (err < 0) + return err; if (!skb_queue_empty(&ctx->rx_list)) { skb = __skb_dequeue(&ctx->rx_list); @@ -2145,7 +2146,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, struct tls_decrypt_arg darg; err = tls_rx_rec_wait(sk, NULL, flags & SPLICE_F_NONBLOCK, - true, timeo); + true); if (err <= 0) goto splice_read_end; |