qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, gang.chen.5i5j@gmail.com,
	riku.voipio@iki.fi, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v3] linux-user: syscall: Add SO_LINGER for setsockopt
Date: Tue, 19 Sep 2017 13:42:27 +0200	[thread overview]
Message-ID: <d137f607-aa48-e388-02b2-1f1b104439e2@vivier.eu> (raw)
In-Reply-To: <20170919081549.82541-1-carenas@gmail.com>

Le 19/09/2017 à 10:15, Carlo Marcelo Arenas Belón a écrit :
> Original implementation from Chen Gang; code moved around as per v2
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
>  linux-user/syscall.c      | 16 ++++++++++++++++
>  linux-user/syscall_defs.h |  5 +++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 9b6364a266..d3c500ca78 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2829,6 +2829,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
>      int val;
>      struct ip_mreqn *ip_mreq;
>      struct ip_mreq_source *ip_mreq_source;
> +    struct linger lg;
> +    struct target_linger *tlg;
>  
>      switch(level) {
>      case SOL_TCP:
> @@ -3071,6 +3073,20 @@ set_timeout:
>  		unlock_user (dev_ifname, optval_addr, 0);
>  		return ret;
>  	}
> +        case TARGET_SO_LINGER:
> +                optname = SO_LINGER;
> +                if (optlen != sizeof(struct target_linger)) {
> +                    return -TARGET_EINVAL;
> +                }
> +                if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) {
> +                    return -TARGET_EFAULT;
> +                }
> +                __get_user(lg.l_onoff, &tlg->l_onoff);
> +                __get_user(lg.l_linger, &tlg->l_linger);
> +                ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname,
> +                                &lg, sizeof(lg)));
> +                unlock_user_struct(tlg, optval_addr, 0);
> +                return ret;
>              /* Options with 'int' argument.  */

It looks good.

Could you also add it for getsockopt()?

>          case TARGET_SO_DEBUG:
>  		optname = SO_DEBUG;
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 40c5027e93..a60d6bb163 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -202,6 +202,11 @@ struct target_ip_mreq_source {
>      uint32_t imr_sourceaddr;
>  };
>  
> +struct target_linger {
> +    abi_int l_onoff;        /* Linger active                */
> +    abi_int l_linger;       /* How long to linger for       */
> +};
> +
>  struct target_timeval {
>      abi_long tv_sec;
>      abi_long tv_usec;
> 

Could you update the definition of TARGET_SO_LINGER for sparc (kernel
says 0x0080, and we use 13)

Thanks,
Laurent

  reply	other threads:[~2017-09-19 11:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19  8:15 [Qemu-devel] [PATCH v3] linux-user: syscall: Add SO_LINGER for setsockopt Carlo Marcelo Arenas Belón
2017-09-19 11:42 ` Laurent Vivier [this message]
2017-09-19 23:06   ` [Qemu-devel] [PATCH 1/3] linux-user: fix TARGET_SO_LINGER for sparc Carlo Marcelo Arenas Belón
2017-09-19 23:06     ` [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt Carlo Marcelo Arenas Belón
2017-09-20  8:39       ` Laurent Vivier
2017-09-20 17:29         ` Carlo Arenas
2017-09-20 18:53           ` Laurent Vivier
2017-09-20 23:03             ` Carlo Arenas
2017-09-19 23:06     ` [Qemu-devel] [PATCH 3/3] linux-user: add SO_LINGER to getsockopt Carlo Marcelo Arenas Belón
2017-09-20  9:09       ` Laurent Vivier
2017-09-20  8:26     ` [Qemu-devel] [PATCH 1/3] linux-user: fix TARGET_SO_LINGER for sparc Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d137f607-aa48-e388-02b2-1f1b104439e2@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=carenas@gmail.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).