Skip to content

Commit fdf478d

Browse files
kxxtborkmann
authored andcommitted
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
1 parent d888b7a commit fdf478d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/core/skmsg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
369369
struct sk_msg *msg, u32 bytes)
370370
{
371371
int ret = -ENOSPC, i = msg->sg.curr;
372+
u32 copy, buf_size, copied = 0;
372373
struct scatterlist *sge;
373-
u32 copy, buf_size;
374374
void *to;
375375

376376
do {
@@ -397,14 +397,15 @@ int sk_msg_memcopy_from_iter(struct sock *sk, struct iov_iter *from,
397397
goto out;
398398
}
399399
bytes -= copy;
400+
copied += copy;
400401
if (!bytes)
401402
break;
402403
msg->sg.copybreak = 0;
403404
sk_msg_iter_var_next(i);
404405
} while (i != msg->sg.end);
405406
out:
406407
msg->sg.curr = i;
407-
return ret;
408+
return (ret < 0) ? ret : copied;
408409
}
409410
EXPORT_SYMBOL_GPL(sk_msg_memcopy_from_iter);
410411

0 commit comments

Comments
 (0)