summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorLevi Zim <rsworktech@outlook.com>2024-11-30 21:38:22 +0800
committerDaniel Borkmann <daniel@iogearbox.net>2024-12-20 22:53:36 +0100
commitfdf478d236dcf0f1f68534df5d456ced625195bd (patch)
tree22483cb4ffb1ac93b7b5f12a87a330ef2e24b626 /net/core
parentd888b7af7c149c115dd6ac772cc11c375da3e17c (diff)
downloadlwn-fdf478d236dcf0f1f68534df5d456ced625195bd.tar.gz
lwn-fdf478d236dcf0f1f68534df5d456ced625195bd.zip
skmsg: Return copied bytes in sk_msg_memcopy_from_iter
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@outlook.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Tested-by: Björn Töpel <bjorn@kernel.org> Reviewed-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20241130-tcp-bpf-sendmsg-v1-1-bae583d014f3@outlook.com
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skmsg.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 8ad7e6755fd6..61f3f3d4e528 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -369,8 +369,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 {
@@ -397,6 +397,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;
@@ -404,7 +405,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);