qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt
Date: Wed, 20 Sep 2017 20:53:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

Le 20/09/2017 à 19:29, Carlo Arenas a écrit :
> On Wed, Sep 20, 2017 at 1:39 AM, Laurent Vivier <address@hidden
> <mailto:address@hidden>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]