Skip to content

Commit c1c607b

Browse files
kuba-moodavem330
authored andcommitted
tls: rx: strp: factor out copying skb data
We'll need to copy input skbs individually in the next patch. Factor that code out (without assuming we're copying a full record). Tested-by: Shai Amiram <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8b0c0dc commit c1c607b

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

net/tls/tls_strp.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,44 @@ static void tls_strp_anchor_free(struct tls_strparser *strp)
3434
strp->anchor = NULL;
3535
}
3636

37-
/* Create a new skb with the contents of input copied to its page frags */
38-
static struct sk_buff *tls_strp_msg_make_copy(struct tls_strparser *strp)
37+
static struct sk_buff *
38+
tls_strp_skb_copy(struct tls_strparser *strp, struct sk_buff *in_skb,
39+
int offset, int len)
3940
{
40-
struct strp_msg *rxm;
4141
struct sk_buff *skb;
42-
int i, err, offset;
42+
int i, err;
4343

44-
skb = alloc_skb_with_frags(0, strp->stm.full_len, TLS_PAGE_ORDER,
44+
skb = alloc_skb_with_frags(0, len, TLS_PAGE_ORDER,
4545
&err, strp->sk->sk_allocation);
4646
if (!skb)
4747
return NULL;
4848

49-
offset = strp->stm.offset;
5049
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
5150
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
5251

53-
WARN_ON_ONCE(skb_copy_bits(strp->anchor, offset,
52+
WARN_ON_ONCE(skb_copy_bits(in_skb, offset,
5453
skb_frag_address(frag),
5554
skb_frag_size(frag)));
5655
offset += skb_frag_size(frag);
5756
}
5857

59-
skb->len = strp->stm.full_len;
60-
skb->data_len = strp->stm.full_len;
61-
skb_copy_header(skb, strp->anchor);
58+
skb->len = len;
59+
skb->data_len = len;
60+
skb_copy_header(skb, in_skb);
61+
return skb;
62+
}
63+
64+
/* Create a new skb with the contents of input copied to its page frags */
65+
static struct sk_buff *tls_strp_msg_make_copy(struct tls_strparser *strp)
66+
{
67+
struct strp_msg *rxm;
68+
struct sk_buff *skb;
69+
70+
skb = tls_strp_skb_copy(strp, strp->anchor, strp->stm.offset,
71+
strp->stm.full_len);
72+
if (!skb)
73+
return NULL;
74+
6275
rxm = strp_msg(skb);
6376
rxm->offset = 0;
6477
return skb;

0 commit comments

Comments
 (0)