diff mbox series

[v8,06/14] net: stream: Don't ignore EINVAL on netdev socket connection

Message ID 20220913064000.79353-7-lvivier@redhat.com (mailing list archive)
State New, archived
Headers show
Series qapi: net: add unix socket type support to netdev backend | expand

Commit Message

Laurent Vivier Sept. 13, 2022, 6:39 a.m. UTC
From: Stefano Brivio <sbrivio@redhat.com>

Other errors are treated as failure by net_stream_client_init(),
but if connect() returns EINVAL, we'll fail silently. Remove the
related exception.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
[lvivier: applied to net/stream.c]
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 net/stream.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

David Gibson Sept. 14, 2022, 5:05 a.m. UTC | #1
On Tue, Sep 13, 2022 at 08:39:52AM +0200, Laurent Vivier wrote:
> From: Stefano Brivio <sbrivio@redhat.com>
> 
> Other errors are treated as failure by net_stream_client_init(),
> but if connect() returns EINVAL, we'll fail silently. Remove the
> related exception.

Is this also a bug in net_socket_connect_init()?  Is there an
equivalent bug in dgram.c?

> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> [lvivier: applied to net/stream.c]
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  net/stream.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/stream.c b/net/stream.c
> index 0851e90becca..e8afbaca50b6 100644
> --- a/net/stream.c
> +++ b/net/stream.c
> @@ -363,8 +363,7 @@ static int net_stream_client_init(NetClientState *peer,
>                  if (errno == EINTR || errno == EWOULDBLOCK) {
>                      /* continue */
>                  } else if (errno == EINPROGRESS ||
> -                           errno == EALREADY ||
> -                           errno == EINVAL) {
> +                           errno == EALREADY) {
>                      break;
>                  } else {
>                      error_setg_errno(errp, errno, "can't connect socket");
Laurent Vivier Sept. 23, 2022, 2:58 p.m. UTC | #2
On 9/14/22 07:05, David Gibson wrote:
> On Tue, Sep 13, 2022 at 08:39:52AM +0200, Laurent Vivier wrote:
>> From: Stefano Brivio <sbrivio@redhat.com>
>>
>> Other errors are treated as failure by net_stream_client_init(),
>> but if connect() returns EINVAL, we'll fail silently. Remove the
>> related exception.
> 
> Is this also a bug in net_socket_connect_init()?  Is there an
> equivalent bug in dgram.c?

Yes, the bug has been found by Stefano in socket.c, I'm adding his patch to the series.
There is no equivalent bug in dgram.c

Thanks,
Laurent
diff mbox series

Patch

diff --git a/net/stream.c b/net/stream.c
index 0851e90becca..e8afbaca50b6 100644
--- a/net/stream.c
+++ b/net/stream.c
@@ -363,8 +363,7 @@  static int net_stream_client_init(NetClientState *peer,
                 if (errno == EINTR || errno == EWOULDBLOCK) {
                     /* continue */
                 } else if (errno == EINPROGRESS ||
-                           errno == EALREADY ||
-                           errno == EINVAL) {
+                           errno == EALREADY) {
                     break;
                 } else {
                     error_setg_errno(errp, errno, "can't connect socket");