qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Carlo Arenas <carenas@gmail.com>
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org,
	gang.chen.5i5j@gmail.com, riku.voipio@iki.fi, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt
Date: Wed, 20 Sep 2017 20:53:59 +0200	[thread overview]
Message-ID: <46de309a-ae79-e15c-6f34-c9b8cf458d6b@vivier.eu> (raw)
In-Reply-To: <CAPUEspjdyJ8_cwGPZFOAKs3NE83kdwXV-Ji6TTFYJf7MFQxvBg@mail.gmail.com>

Le 20/09/2017 à 19:29, Carlo Arenas a écrit :
> On Wed, Sep 20, 2017 at 1:39 AM, Laurent Vivier <laurent@vivier.eu
> <mailto:laurent@vivier.eu>> wrote:
> 
>     Why did you remove "optname = SO_LINGER" and "if (optlen !=
>     sizeof(struct target_linger))"?
> 
> 
> the optname assignment is not really needed, since it is only used for
> the setsockopt call and that call is clearer using SO_LINGER directly,
> so to avoid hard to see bugs like :
> 
>   http://lists.nongnu.org/archive/html/qemu-devel/2016-01/msg00980.html 

Okay

> the test for optlen is replaced by passing optlen to the underlying
> setsockopt call directly, who would do the test and return the right error.

You can't do that, because sizeof(struct linger) may be different from
sizeof(struct target_linger).

> as an interesting note, I noticed when testing (in ubuntu artful x86_64)
> that regardless of how you interpret the documentation, setsockopt won't
> fail just because the len is smaller than the size of the struct, and

Right, see:

http://elixir.free-electrons.com/linux/latest/source/net/core/sock.c#L830

> therefore that code was not equivalent to the setsockopt it was trying
> to emulate, and therefore this change doesn't only make the code simpler
> but also more correct IMHO
Next time add a revision history in your series explaining your changes
(and don't reply to the previous patch series for the new series, it's
better to start a new email thread).

Thanks,
Laurent

  reply	other threads:[~2017-09-20 18:54 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
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 [this message]
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=46de309a-ae79-e15c-6f34-c9b8cf458d6b@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).