From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tq6Vi-0008Pl-Q8 for qemu-devel@nongnu.org; Tue, 01 Jan 2013 13:24:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tq6Vh-0005Fc-Jy for qemu-devel@nongnu.org; Tue, 01 Jan 2013 13:24:22 -0500 Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]:54893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tq6Vh-0005EX-0W for qemu-devel@nongnu.org; Tue, 01 Jan 2013 13:24:21 -0500 From: Laurent Vivier Date: Tue, 1 Jan 2013 19:24:11 +0100 Message-Id: <1357064651-30072-1-git-send-email-laurent@vivier.eu> In-Reply-To: <1356983610-14793-1-git-send-email-laurent@vivier.eu> References: <1356983610-14793-1-git-send-email-laurent@vivier.eu> Subject: [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , qemu-devel@nongnu.org, Laurent Vivier From: Laurent Vivier SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int To test this, you can use : QEMU_STRACE= ping localhost 2>&1 |grep TIMEO 568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) = 0 568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) = 0 Signed-off-by: Laurent Vivier --- v2: pass checkpatch.pl linux-user/syscall.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e99adab..2b2bd2b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1491,6 +1491,28 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, break; case TARGET_SOL_SOCKET: switch (optname) { + case TARGET_SO_RCVTIMEO: + { + struct timeval tv; + + optname = SO_RCVTIMEO; + +set_timeout: + if (optlen != sizeof(struct target_timeval)) { + return -TARGET_EINVAL; + } + + if (copy_from_user_timeval(&tv, optval_addr)) { + return -TARGET_EFAULT; + } + + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + &tv, sizeof(tv))); + return ret; + } + case TARGET_SO_SNDTIMEO: + optname = SO_SNDTIMEO; + goto set_timeout; /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; @@ -1542,12 +1564,6 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, case TARGET_SO_RCVLOWAT: optname = SO_RCVLOWAT; break; - case TARGET_SO_RCVTIMEO: - optname = SO_RCVTIMEO; - break; - case TARGET_SO_SNDTIMEO: - optname = SO_SNDTIMEO; - break; break; default: goto unimplemented; -- 1.7.10.4