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 <[email protected]> > --- > 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
