All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] tests/socket-helpers: Only fail socket protocol check if it is really necessary
Date: Tue, 8 Sep 2020 12:41:53 +0100	[thread overview]
Message-ID: <20200908114153.GG899163@redhat.com> (raw)
In-Reply-To: <7a78c69d-28f4-e73b-4acc-fc8dd923db3e@redhat.com>

On Tue, Sep 08, 2020 at 01:27:46PM +0200, Thomas Huth wrote:
> On 08/09/2020 13.07, Daniel P. Berrangé wrote:
> > On Tue, Sep 08, 2020 at 12:54:35PM +0200, Thomas Huth wrote:
> >> The tests/test-char test is currently always failing on my system since
> >> socket_can_bind_connect("::1", PF_INET6) fails with EINVAL and thus
> >> socket_check_protocol_support() is returning -1 for an error. But IPv4
> >> is working fine. The logic in socket_check_protocol_support() seems to
> >> be wrong here, if either IPv6 or IPv4 is working, we should not return
> >> an error here. Thus rework the function to only return errors if both
> >> checks failed.
> > 
> > Can you tell me which exact syscall is giving EINVAL in this scenario ?
> 
> getaddrinfo() fails with -2 (EAI_NONAME ?). The logic in
> socket_can_bind_connect() then translates this into EINVAL.

Ok, lets just translate EAI_NONAME into  EADDRNOTAVAIL as we do for
the other getaddrinfo errors we want to treat as soft-failures

> 
> [...]
> >> -    if (socket_can_bind_connect("::1", PF_INET6) < 0) {
> >> -        if (errno != EADDRNOTAVAIL) {
> >> -            return -1;
> >> -        }
> >> -    } else {
> >> -        *has_ipv6 = true;
> >> +    errv6 = socket_can_bind_connect("::1", PF_INET6);
> >> +    *has_ipv6 = (errv6 == 0);
> >> +
> >> +    if (!*has_ipv4 && !*has_ipv6 &&
> >> +        (errv4 != EADDRNOTAVAIL || errv6 != EADDRNOTAVAIL)) {
> >> +        return -1;
> >>      }
> > 
> > The return value of socket_can_bind_connect is either 0 or -1,
> > but you're treating it an errno which isn't right.
> 
> Uh, where's my brown paperbag? ... looks like I need more coffee today...
> 
>  Thomas
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2020-09-08 11:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 10:54 [PATCH] tests/socket-helpers: Only fail socket protocol check if it is really necessary Thomas Huth
2020-09-08 11:07 ` Daniel P. Berrangé
2020-09-08 11:27   ` Thomas Huth
2020-09-08 11:41     ` Daniel P. Berrangé [this message]

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=20200908114153.GG899163@redhat.com \
    --to=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.