From: Jakub Kicinski <kuba@kernel.org>
To: tariqt@nvidia.com
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [RFC / RFT net 5/7] tls: rx: strp: factor out copying skb data
Date: Wed, 10 May 2023 18:20:32 -0700 [thread overview]
Message-ID: <20230511012034.902782-6-kuba@kernel.org> (raw)
In-Reply-To: <20230511012034.902782-1-kuba@kernel.org>
We'll need to copy input skbs individually in the next patch.
Factor that code out (without assuming we're copying a full record).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/tls/tls_strp.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
index 7b0c8145ace6..61fbf84baf9e 100644
--- a/net/tls/tls_strp.c
+++ b/net/tls/tls_strp.c
@@ -34,23 +34,22 @@ static void tls_strp_anchor_free(struct tls_strparser *strp)
strp->anchor = NULL;
}
-/* Create a new skb with the contents of input copied to its page frags */
-static struct sk_buff *tls_strp_msg_make_copy(struct tls_strparser *strp)
+static struct sk_buff *
+tls_strp_skb_copy(struct tls_strparser *strp, struct sk_buff *in_skb,
+ int offset, int len)
{
- struct strp_msg *rxm;
struct sk_buff *skb;
- int i, err, offset;
+ int i, err;
- skb = alloc_skb_with_frags(0, strp->stm.full_len, TLS_PAGE_ORDER,
+ skb = alloc_skb_with_frags(0, len, TLS_PAGE_ORDER,
&err, strp->sk->sk_allocation);
if (!skb)
return NULL;
- offset = strp->stm.offset;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
- WARN_ON_ONCE(skb_copy_bits(strp->anchor, offset,
+ WARN_ON_ONCE(skb_copy_bits(in_skb, offset,
skb_frag_address(frag),
skb_frag_size(frag)));
offset += skb_frag_size(frag);
@@ -58,7 +57,21 @@ static struct sk_buff *tls_strp_msg_make_copy(struct tls_strparser *strp)
skb->len = len;
skb->data_len = len;
- skb_copy_header(skb, strp->anchor);
+ skb_copy_header(skb, in_skb);
+ return skb;
+}
+
+/* Create a new skb with the contents of input copied to its page frags */
+static struct sk_buff *tls_strp_msg_make_copy(struct tls_strparser *strp)
+{
+ struct strp_msg *rxm;
+ struct sk_buff *skb;
+
+ skb = tls_strp_skb_copy(strp, strp->anchor, strp->stm.offset,
+ strp->stm.full_len);
+ if (!skb)
+ return NULL;
+
rxm = strp_msg(skb);
rxm->offset = 0;
return skb;
--
2.40.1
next prev parent reply other threads:[~2023-05-11 1:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 1:20 [RFC / RFT net 0/7] tls: rx: strp: fix inline crypto offload Jakub Kicinski
2023-05-11 1:20 ` [RFC / RFT net 1/7] tls: rx: device: fix checking decryption status Jakub Kicinski
2023-05-11 1:20 ` [RFC / RFT net 2/7] tls: rx: strp: set the skb->len of detached / CoW'ed skbs Jakub Kicinski
2023-05-11 13:45 ` Simon Horman
2023-05-11 1:20 ` [RFC / RFT net 3/7] tls: rx: strp: force mixed decrypted records into copy mode Jakub Kicinski
2023-05-11 1:20 ` [RFC / RFT net 4/7] tls: rx: strp: fix determining record length in " Jakub Kicinski
2023-05-11 1:20 ` Jakub Kicinski [this message]
2023-05-11 1:20 ` [RFC / RFT net 6/7] tls: rx: strp: preserve decryption status of skbs when needed Jakub Kicinski
2023-05-11 1:20 ` [RFC / RFT net 7/7] tls: rx: strp: don't use GFP_KERNEL in softirq context Jakub Kicinski
2023-05-11 10:17 ` [RFC / RFT net 0/7] tls: rx: strp: fix inline crypto offload Tariq Toukan
2023-05-16 12:27 ` Tariq Toukan
2023-05-17 1:52 ` Jakub Kicinski
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=20230511012034.902782-6-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tariqt@nvidia.com \
/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).