Commit 4a02609d authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'fixes-for-ktls'

John Fastabend says:

====================
Couple fixes for TLS and BPF interactions.
====================

Link: https://lore.kernel.org/r/20231206232706.374377-1-john.fastabend@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4de75d3e bb9aefde
...@@ -2602,6 +2602,22 @@ BPF_CALL_2(bpf_msg_cork_bytes, struct sk_msg *, msg, u32, bytes) ...@@ -2602,6 +2602,22 @@ BPF_CALL_2(bpf_msg_cork_bytes, struct sk_msg *, msg, u32, bytes)
return 0; return 0;
} }
static void sk_msg_reset_curr(struct sk_msg *msg)
{
u32 i = msg->sg.start;
u32 len = 0;
do {
len += sk_msg_elem(msg, i)->length;
sk_msg_iter_var_next(i);
if (len >= msg->sg.size)
break;
} while (i != msg->sg.end);
msg->sg.curr = i;
msg->sg.copybreak = 0;
}
static const struct bpf_func_proto bpf_msg_cork_bytes_proto = { static const struct bpf_func_proto bpf_msg_cork_bytes_proto = {
.func = bpf_msg_cork_bytes, .func = bpf_msg_cork_bytes,
.gpl_only = false, .gpl_only = false,
...@@ -2721,6 +2737,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, ...@@ -2721,6 +2737,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start,
msg->sg.end - shift + NR_MSG_FRAG_IDS : msg->sg.end - shift + NR_MSG_FRAG_IDS :
msg->sg.end - shift; msg->sg.end - shift;
out: out:
sk_msg_reset_curr(msg);
msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset; msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset;
msg->data_end = msg->data + bytes; msg->data_end = msg->data + bytes;
return 0; return 0;
...@@ -2857,6 +2874,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start, ...@@ -2857,6 +2874,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
msg->sg.data[new] = rsge; msg->sg.data[new] = rsge;
} }
sk_msg_reset_curr(msg);
sk_msg_compute_data_pointers(msg); sk_msg_compute_data_pointers(msg);
return 0; return 0;
} }
...@@ -3025,6 +3043,7 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_msg *, msg, u32, start, ...@@ -3025,6 +3043,7 @@ BPF_CALL_4(bpf_msg_pop_data, struct sk_msg *, msg, u32, start,
sk_mem_uncharge(msg->sk, len - pop); sk_mem_uncharge(msg->sk, len - pop);
msg->sg.size -= (len - pop); msg->sg.size -= (len - pop);
sk_msg_reset_curr(msg);
sk_msg_compute_data_pointers(msg); sk_msg_compute_data_pointers(msg);
return 0; return 0;
} }
......
...@@ -952,6 +952,8 @@ static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg, ...@@ -952,6 +952,8 @@ static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg,
} }
sk_msg_page_add(msg_pl, page, part, off); sk_msg_page_add(msg_pl, page, part, off);
msg_pl->sg.copybreak = 0;
msg_pl->sg.curr = msg_pl->sg.end;
sk_mem_charge(sk, part); sk_mem_charge(sk, part);
*copied += part; *copied += part;
try_to_copy -= part; try_to_copy -= part;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment