netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net, pabeni@redhat.com
Cc: netdev@vger.kernel.org, borisp@nvidia.com,
	john.fastabend@gmail.com, daniel@iogearbox.net,
	vfedorenko@novek.ru, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 10/11] tls: rx: clear ctx->recv_pkt earlier
Date: Fri,  8 Apr 2022 11:31:33 -0700	[thread overview]
Message-ID: <20220408183134.1054551-11-kuba@kernel.org> (raw)
In-Reply-To: <20220408183134.1054551-1-kuba@kernel.org>

Whatever we do in the loop the skb should not remain on as
ctx->recv_pkt afterwards. We can clear that pointer and
restart strparser earlier.

This adds overhead of extra linking and unlinking to rx_list
but that's not large (upcoming change will switch to unlocked
skb list operations).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/tls/tls_sw.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 3aa8fe1c6e77..71d8082647c8 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1826,6 +1826,10 @@ int tls_sw_recvmsg(struct sock *sk,
 		if (err <= 0)
 			goto recv_end;
 
+		ctx->recv_pkt = NULL;
+		__strp_unpause(&ctx->strp);
+		skb_queue_tail(&ctx->rx_list, skb);
+
 		if (async) {
 			/* TLS 1.2-only, to_decrypt must be text length */
 			chunk = min_t(int, to_decrypt, len);
@@ -1840,10 +1844,9 @@ int tls_sw_recvmsg(struct sock *sk,
 				if (err != __SK_PASS) {
 					rxm->offset = rxm->offset + rxm->full_len;
 					rxm->full_len = 0;
+					skb_unlink(skb, &ctx->rx_list);
 					if (err == __SK_DROP)
 						consume_skb(skb);
-					ctx->recv_pkt = NULL;
-					__strp_unpause(&ctx->strp);
 					continue;
 				}
 			}
@@ -1869,14 +1872,9 @@ int tls_sw_recvmsg(struct sock *sk,
 		len -= chunk;
 
 		/* For async or peek case, queue the current skb */
-		if (async || is_peek || retain_skb) {
-			skb_queue_tail(&ctx->rx_list, skb);
-			ctx->recv_pkt = NULL;
-			__strp_unpause(&ctx->strp);
-		} else {
+		if (!(async || is_peek || retain_skb)) {
+			skb_unlink(skb, &ctx->rx_list);
 			consume_skb(skb);
-			ctx->recv_pkt = NULL;
-			__strp_unpause(&ctx->strp);
 
 			/* Return full control message to
 			 * userspace before trying to parse
-- 
2.34.1


  parent reply	other threads:[~2022-04-08 18:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 18:31 [PATCH net-next 00/11] tls: rx: random refactoring part 2 Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 01/11] tls: rx: drop unnecessary arguments from tls_setup_from_iter() Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 02/11] tls: rx: don't report text length from the bowels of decrypt Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 03/11] tls: rx: wrap decryption arguments in a structure Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 04/11] tls: rx: simplify async wait Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 05/11] tls: rx: factor out writing ContentType to cmsg Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 06/11] tls: rx: don't handle async in tls_sw_advance_skb() Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 07/11] tls: rx: don't track the async count Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 08/11] tls: rx: pull most of zc check out of the loop Jakub Kicinski
2022-04-08 18:31 ` [PATCH net-next 09/11] tls: rx: inline consuming the skb at the end " Jakub Kicinski
2022-04-08 18:31 ` Jakub Kicinski [this message]
2022-05-18 12:43   ` [PATCH net-next 10/11] tls: rx: clear ctx->recv_pkt earlier Artem Savkov
2022-04-08 18:31 ` [PATCH net-next 11/11] tls: rx: jump out for cases which need to leave skb on list Jakub Kicinski
2022-04-08 19:03 ` [PATCH net-next 00/11] tls: rx: random refactoring part 2 John Fastabend
2022-04-10 16:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220408183134.1054551-11-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vfedorenko@novek.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).