qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/3] linux-user: Modify 'sendmmsg()' and 'recvmmsg()' impleme


From: Laurent Vivier
Subject: Re: [PATCH 1/3] linux-user: Modify 'sendmmsg()' and 'recvmmsg()' implementation
Date: Mon, 24 Aug 2020 22:11:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Le 31/07/2020 à 21:06, Filip Bozuta a écrit :
> Implementations of 'sendmmsg()' and 'recvmmsg()' in 'syscall.c' use
> a loop over a host command of 'sendmsg()' and 'recvmsg()' respectively
> to send/receive individual messages from a socket. This patch changes
> these implementations to use the host commands 'sendmmsg()' and 'recvmmsg()'
> to send all messages without looping over 'sendmsg()' and 'recvmsg()'.
> 
> Implementation notes:
> 
>     Parts of code from 'do_sendrecvmsg_locked()', that are used to transfer
>     values of 'struct msghdr' between host and target, were moved to separate
>     functions 'target_to_host_msghdr()' and 'host_to_target_msghdr()'. These
>     functions are used in 'do_sendrecvmmsg()' to transfer the data of each
>     individual 'struct msghdr' from the 'msgvec' argument. Memory allocation
>     for the 'iovec' field is done outside of these functions as to ensure that
>     the memory is freed after the syscall execution.
> 
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> ---
>  linux-user/syscall.c | 243 ++++++++++++++++++++++++++++---------------
>  1 file changed, 159 insertions(+), 84 deletions(-)
> 

I'm sorry but after studying the changes needed I think it's better to
keep the existing code.

For instance, if we have a EFAULT (or EMSGSIZE) while reading the iovec
we must stop to send  data and exit with the error code.

Your code correctly manages the detection of the error and stops the
conversion of the iovec. Then it uses the converted iovecs with
sendmmsg() and recvmmsg(), but "ret" is overwritten and the error is lost.

So, in the end, and as it is done in kernel, the best is to loop around
sendmsg()... and this is what the existing code does.

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]