* [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int
@ 2012-12-31 19:53 Laurent Vivier
2012-12-31 21:40 ` Peter Maydell
2013-01-01 18:24 ` [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() Laurent Vivier
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Vivier @ 2012-12-31 19:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier
From: Laurent Vivier <Laurent@Vivier.EU>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e99adab..1530c8f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1491,6 +1491,25 @@ 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,13 +1561,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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int
2012-12-31 19:53 [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int Laurent Vivier
@ 2012-12-31 21:40 ` Peter Maydell
2013-01-01 18:24 ` [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() Laurent Vivier
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2012-12-31 21:40 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Riku Voipio, qemu-devel
On 31 December 2012 19:53, Laurent Vivier <laurent@vivier.eu> wrote:
> From: Laurent Vivier <Laurent@Vivier.EU>
Looks about right (though the goto is a little ugly). You have some
style issues you need to fix, though.
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt()
2012-12-31 19:53 [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int Laurent Vivier
2012-12-31 21:40 ` Peter Maydell
@ 2013-01-01 18:24 ` Laurent Vivier
2013-01-19 23:32 ` Laurent Vivier
1 sibling, 1 reply; 4+ messages in thread
From: Laurent Vivier @ 2013-01-01 18:24 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, qemu-devel, Laurent Vivier
From: Laurent Vivier <Laurent@Vivier.EU>
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 <laurent@vivier.eu>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt()
2013-01-01 18:24 ` [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() Laurent Vivier
@ 2013-01-19 23:32 ` Laurent Vivier
0 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2013-01-19 23:32 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, qemu-devel
ping ?
Le mardi 01 janvier 2013 à 19:24 +0100, Laurent Vivier a écrit :
> From: Laurent Vivier <Laurent@Vivier.EU>
>
> 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 <laurent@vivier.eu>
> ---
> 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;
--
"Just play. Have fun. Enjoy the game."
- Michael Jordan
"Just play. Have fun. Enjoy the game."
- Michael Jordan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-19 23:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-31 19:53 [Qemu-devel] [PATCH] linux-user: correct setsockopt() SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int Laurent Vivier
2012-12-31 21:40 ` Peter Maydell
2013-01-01 18:24 ` [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() Laurent Vivier
2013-01-19 23:32 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).