Skip to content

Commit 8b3c59a

Browse files
committed
tls: rx: device: add input CoW helper
Wrap the remaining skb_cow_data() into a helper, so it's easier to replace down the lane. The new version will change the skb so make sure relevant pointers get reloaded after the call. Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3f92a64 commit 8b3c59a

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

net/tls/tls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ int tls_sw_fallback_init(struct sock *sk,
127127
struct tls_offload_context_tx *offload_ctx,
128128
struct tls_crypto_info *crypto_info);
129129

130+
int tls_strp_msg_cow(struct tls_sw_context_rx *ctx);
130131
struct sk_buff *tls_strp_msg_detach(struct tls_sw_context_rx *ctx);
131132
int tls_strp_msg_hold(struct sock *sk, struct sk_buff *skb,
132133
struct sk_buff_head *dst);

net/tls/tls_device.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -894,27 +894,26 @@ static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx,
894894
static int
895895
tls_device_reencrypt(struct sock *sk, struct tls_sw_context_rx *sw_ctx)
896896
{
897-
int err = 0, offset, copy, nsg, data_len, pos;
898-
struct sk_buff *skb, *skb_iter, *unused;
897+
int err, offset, copy, data_len, pos;
898+
struct sk_buff *skb, *skb_iter;
899899
struct scatterlist sg[1];
900900
struct strp_msg *rxm;
901901
char *orig_buf, *buf;
902902

903-
skb = tls_strp_msg(sw_ctx);
904-
rxm = strp_msg(skb);
905-
offset = rxm->offset;
906-
903+
rxm = strp_msg(tls_strp_msg(sw_ctx));
907904
orig_buf = kmalloc(rxm->full_len + TLS_HEADER_SIZE +
908905
TLS_CIPHER_AES_GCM_128_IV_SIZE, sk->sk_allocation);
909906
if (!orig_buf)
910907
return -ENOMEM;
911908
buf = orig_buf;
912909

913-
nsg = skb_cow_data(skb, 0, &unused);
914-
if (unlikely(nsg < 0)) {
915-
err = nsg;
910+
err = tls_strp_msg_cow(sw_ctx);
911+
if (unlikely(err))
916912
goto free_buf;
917-
}
913+
914+
skb = tls_strp_msg(sw_ctx);
915+
rxm = strp_msg(skb);
916+
offset = rxm->offset;
918917

919918
sg_init_table(sg, 1);
920919
sg_set_buf(&sg[0], buf,

net/tls/tls_strp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ struct sk_buff *tls_strp_msg_detach(struct tls_sw_context_rx *ctx)
1313
return skb;
1414
}
1515

16+
int tls_strp_msg_cow(struct tls_sw_context_rx *ctx)
17+
{
18+
struct sk_buff *unused;
19+
int nsg;
20+
21+
nsg = skb_cow_data(ctx->recv_pkt, 0, &unused);
22+
if (nsg < 0)
23+
return nsg;
24+
return 0;
25+
}
26+
1627
int tls_strp_msg_hold(struct sock *sk, struct sk_buff *skb,
1728
struct sk_buff_head *dst)
1829
{

0 commit comments

Comments
 (0)