mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Sascha Braun <sascha.braun.lpz@googlemail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Problably Issue in name_from_dns // __res_msend_rc (lookup_name.c)
Date: Wed, 1 Jun 2022 17:30:22 -0400	[thread overview]
Message-ID: <20220601213022.GX7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <CALATqH=jPtsqoPv5o1rxUWcGehvJrKcz6Jgv=ugL6h1VarPjQA@mail.gmail.com>

On Wed, Jun 01, 2022 at 10:35:52PM +0200, Sascha Braun wrote:
> Hi Rich,
> 
> Thanks for your time. The EADDRINUSE is in reality an EAGAIN, this is a
> glitch in the Emscripten/WASI modification for musl (there are different
> values for errnos per implementation):
> __WASI_ERRNO_ADDRINUSE == -3 == EAI_AGAIN.
> 
> My question currently breaks down to: Is it common for this implementation
> of getaddrinfo to return EAGAIN sometimes (I experience 1:100), even if
> answers from DNS servers came in?
> If not, I need to investigate much further. I really could not find issues
> with my sockets implementation, although your thought is of course very
> reasonable.

OK, looking at your code again, part of your problem is that you're
misusing perror. You need to save the return value of getaddrinfo.
Unless it's EAI_SYSTEM, errno is meaningless and you need to use
gai_strerror to get a string for the error code (the value that was
returned) rather than inspecting errno.

If getaddrinfo actually returned EAI_AGAIN, this probably means you
got an inconclusive result from one of the nameservers, probably
ServFail. However if your debug output is packet dumps, I'm not seeing
a ServFail there, and I'm not convinced it actually returned EAI_AGAIN
since you're not saving the value to check it. The value that happens
to be in errno is NOT the error getaddrinfo returned. Can you check
what it's actually returning?


> Am Mi., 1. Juni 2022 um 16:14 Uhr schrieb Rich Felker <dalias@libc.org>:
> 
> > On Tue, May 31, 2022 at 12:24:19PM +0200, Sascha Braun wrote:
> > > Hi everyone,
> > >
> > > I'm implementing a socket protocol with similar works to Emscripten - ok:
> > >
> > > Here's what I noticed
> > >
> > > - resolv.conf using multiple DNS servers
> > > options timeout:22 attempts:5
> > > nameserver 8.8.4.4
> > > nameserver 208.67.222.222
> > > nameserver 9.9.9.9
> > > nameserver 1.1.1.1
> > >
> > > - getaddrinfo with no hints, so that IPV6 and IPV4 is resolved
> > > void socketstest1_client_dnsonly(void) {
> > >
> > > struct addrinfo hints, * res;
> > > memset(&hints, 0, sizeof(hints));
> > > printf("begin lookup1...\n");
> > > if (getaddrinfo("www.web.de", "80", &hints, &res) != 0) {
> > > perror("getaddrinfo1");
> > > }
> > > printf("begin lookup2...\n");
> > > if (getaddrinfo("www.google.de", "80", &hints, &res) != 0) {
> > > perror("getaddrinfo2");
> > > }
> > > printf("begin lookup3...\n");
> > > if (getaddrinfo("www.google.com", "80", &hints, &res) != 0) {
> > > perror("getaddrinfo3");
> > > }
> > >
> > > }
> > >
> > > When repeating socketstest1_client_dnsonly often, it appears that IPV6
> > > answers for IPV4 requests to another server [or vice-versa] responses can
> > > get mixed up and getaddrinfo reports sometimes only an error where none
> > is.
> > >
> > > Below is a console dump of my test where you see the critical situation
> > > (end)
> > > 8.8.4.4:53 was queried, 9.9.9.9:53 responded for a (different IP Proto),
> > > resulting in error getaddrinfo1: Address in use
> > >
> > > This happens in about 1/100 tests. When you specify IPV4 or IPV6 in
> > hints,
> > > this issue does NOT show up.
> >
> > Can you provide more information on how to interpret the console dump,
> > and in particular, which of your syscalls is returning the EADDRINUSE
> > error? I'm pretty sure this is just a bug in your socket
> > stack/emulation. It looks like it's coming from recvfrom, and
> > EADDRINUSE is not a valid error for recvfrom to produce.
> >
> > Rich
> >

  reply	other threads:[~2022-06-01 21:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 10:24 Sascha Braun
2022-06-01 14:14 ` Rich Felker
2022-06-01 20:35   ` Sascha Braun
2022-06-01 21:30     ` Rich Felker [this message]
2022-06-01 21:52       ` Sascha Braun
2022-06-02 14:25         ` Rich Felker
2022-06-02 22:28           ` Sascha Braun
2022-06-03 12:27             ` Rich Felker
2022-06-03 12:34               ` Rich Felker
2022-06-03 13:44                 ` Sascha Braun
2022-06-05 18:14                 ` Sascha Braun
2022-06-05 18:47                   ` Rich Felker

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=20220601213022.GX7074@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=sascha.braun.lpz@googlemail.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).