[lvc-project] [PATCH 6.12 v2 1/5] skmsg: Return copied bytes in sk_msg_memcopy_from_iter
Dmitry Antipov
dmantipov at yandex.ru
Mon Oct 19 12:52:35 MSK 2026
From: Levi Zim <rsworktech at outlook.com>
commit fdf478d236dcf0f1f68534df5d456ced625195bd upstream.
Previously sk_msg_memcopy_from_iter returns the copied bytes from the
last copy_from_iter{,_nocache} call upon success.
This commit changes it to return the total number of copied bytes on
success.
Signed-off-by: Levi Zim <rsworktech at outlook.com>
Signed-off-by: Daniel Borkmann <daniel at iogearbox.net>
Tested-by: Björn Töpel <bjorn at kernel.org>
Reviewed-by: John Fastabend <john.fastabend at gmail.com>
Link: https://lore.kernel.org/bpf/20241130-tcp-bpf-sendmsg-v1-1-bae583d014f3@outlook.com
Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
---
net/core/skmsg.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 6eca57da3cff..42e14d2f6966 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -371,8 +371,8 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
struct sk_msg *msg, u32 bytes)
{
int ret = -ENOSPC, i = msg->sg.curr;
+ u32 copy, buf_size, copied = 0;
struct scatterlist *sge;
- u32 copy, buf_size;
void *to;
do {
@@ -399,6 +399,7 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
goto out;
}
bytes -= copy;
+ copied += copy;
if (!bytes)
break;
msg->sg.copybreak = 0;
@@ -406,7 +407,7 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
} while (i != msg->sg.end);
out:
msg->sg.curr = i;
- return ret;
+ return (ret < 0) ? ret : copied;
}
EXPORT_SYMBOL_GPL(sk_msg_memcopy_from_iter);
--
2.56.0
More information about the lvc-project
mailing list