qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO
@ 2019-05-13  9:06 Andreas Schwab
  2019-05-13 10:59 ` Laurent Vivier
  2020-02-18 21:33 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Schwab @ 2019-05-13  9:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d113a65831..ba5775a94e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2171,10 +2171,42 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         level = SOL_SOCKET;
         switch (optname) {
         /* These don't just return a single integer */
-        case TARGET_SO_RCVTIMEO:
-        case TARGET_SO_SNDTIMEO:
         case TARGET_SO_PEERNAME:
             goto unimplemented;
+        case TARGET_SO_RCVTIMEO: {
+            struct timeval tv;
+            socklen_t tvlen;
+
+            optname = SO_RCVTIMEO;
+
+get_timeout:
+            if (get_user_u32(len, optlen)) {
+                return -TARGET_EFAULT;
+            }
+            if (len < 0) {
+                return -TARGET_EINVAL;
+            }
+
+            tvlen = sizeof(tv);
+            ret = get_errno(getsockopt(sockfd, level, optname,
+                                       &tv, &tvlen));
+            if (ret < 0) {
+                return ret;
+            }
+            if (len > sizeof(struct target_timeval)) {
+                len = sizeof(struct target_timeval);
+            }
+            if (copy_to_user_timeval(optval_addr, &tv)) {
+                return -TARGET_EFAULT;
+            }
+            if (put_user_u32(len, optlen)) {
+                return -TARGET_EFAULT;
+            }
+            break;
+        }
+        case TARGET_SO_SNDTIMEO:
+            optname = SO_SNDTIMEO;
+            goto get_timeout;
         case TARGET_SO_PEERCRED: {
             struct ucred cr;
             socklen_t crlen;
-- 
2.21.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO
  2019-05-13  9:06 [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO Andreas Schwab
@ 2019-05-13 10:59 ` Laurent Vivier
  2020-02-18 21:33 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2019-05-13 10:59 UTC (permalink / raw)
  To: Andreas Schwab, qemu-devel; +Cc: Riku Voipio

On 13/05/2019 11:06, Andreas Schwab wrote:
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>   linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++--
>   1 file changed, 34 insertions(+), 2 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO
  2019-05-13  9:06 [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO Andreas Schwab
  2019-05-13 10:59 ` Laurent Vivier
@ 2020-02-18 21:33 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-02-18 21:33 UTC (permalink / raw)
  To: Andreas Schwab, qemu-devel; +Cc: Riku Voipio

Le 13/05/2019 à 11:06, Andreas Schwab a écrit :
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
>  linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index d113a65831..ba5775a94e 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2171,10 +2171,42 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
>          level = SOL_SOCKET;
>          switch (optname) {
>          /* These don't just return a single integer */
> -        case TARGET_SO_RCVTIMEO:
> -        case TARGET_SO_SNDTIMEO:
>          case TARGET_SO_PEERNAME:
>              goto unimplemented;
> +        case TARGET_SO_RCVTIMEO: {
> +            struct timeval tv;
> +            socklen_t tvlen;
> +
> +            optname = SO_RCVTIMEO;
> +
> +get_timeout:
> +            if (get_user_u32(len, optlen)) {
> +                return -TARGET_EFAULT;
> +            }
> +            if (len < 0) {
> +                return -TARGET_EINVAL;
> +            }
> +
> +            tvlen = sizeof(tv);
> +            ret = get_errno(getsockopt(sockfd, level, optname,
> +                                       &tv, &tvlen));
> +            if (ret < 0) {
> +                return ret;
> +            }
> +            if (len > sizeof(struct target_timeval)) {
> +                len = sizeof(struct target_timeval);
> +            }
> +            if (copy_to_user_timeval(optval_addr, &tv)) {
> +                return -TARGET_EFAULT;
> +            }
> +            if (put_user_u32(len, optlen)) {
> +                return -TARGET_EFAULT;
> +            }
> +            break;
> +        }
> +        case TARGET_SO_SNDTIMEO:
> +            optname = SO_SNDTIMEO;
> +            goto get_timeout;
>          case TARGET_SO_PEERCRED: {
>              struct ucred cr;
>              socklen_t crlen;
> 

Applied to my linux-user branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-18 21:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13  9:06 [Qemu-devel] [PATCH] linux-user: implement getsockopt SO_RCVTIMEO and SO_SNDTIMEO Andreas Schwab
2019-05-13 10:59 ` Laurent Vivier
2020-02-18 21:33 ` 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).