* [musl] Question about res_msend_rc
@ 2024-06-14 13:28 AK47
2024-06-14 17:40 ` Rich Felker
0 siblings, 1 reply; 2+ messages in thread
From: AK47 @ 2024-06-14 13:28 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 4126 bytes --]
Hi,
In __res_msend_rc functions, if we send two A queries to two nameservers, One server first replied with ret code "no such name"(answer length is greater than 4), while the other server subsequently replied with the correct IP address(behind the first server). Will the current musl only capture the first "no such name" reply and totally miss the correct IP address reply? Is there a bug or any special reason?
for (; t2-t0 < timeout; t2=mtime()) { /* This is the loop exit condition: that all queries
* have an accepted answer. */
for (i=0; i<nqueries && alens[i]>0; i++);
if (i==nqueries) break;
if (t2-t1 >= retry_interval) {
/* Query all configured namservers in parallel */
for (i=0; i<nqueries; i++)
if (!alens[i])
for (j=0; j<nns; j++) // 2 nameservers
sendto(fd, queries[i],
qlens[i], MSG_NOSIGNAL,
(void *)&ns[j], sl);
t1 = t2;
servfail_retry = 2 * nqueries;
}
switch (answers[next][3] & 15) { case 0:
case 3:
break;
case 2:
if (servfail_retry && servfail_retry--)
sendto(fd, queries[i],
qlens[i], MSG_NOSIGNAL,
(void *)&ns[j], sl);
default:
continue;
}
/* Store answer in the right slot, or update next
* available temp slot if it's already in place. */
alens[i] = rlen; // choose the reply with no such name and will ignore the reply later with right IP
if (i == next)
for (; next<nqueries && alens[next]; next++); // choose the reply with no such name ret code
else
memcpy(answers[i], answers[next], rlen);
/* Ignore further UDP if all slots full or TCP-mode */
if (next == nqueries) pfd[nqueries].events = 0;
Thanks
Li
[-- Attachment #2: Type: text/html, Size: 7082 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [musl] Question about res_msend_rc
2024-06-14 13:28 [musl] Question about res_msend_rc AK47
@ 2024-06-14 17:40 ` Rich Felker
0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2024-06-14 17:40 UTC (permalink / raw)
To: AK47; +Cc: musl
On Fri, Jun 14, 2024 at 09:28:18PM +0800, AK47 wrote:
> Hi,
> In __res_msend_rc functions, if we send two A queries to two
> nameservers, One server first replied with ret code "no such
> name"(answer length is greater than 4), while the other server
> subsequently replied with the correct IP address(behind the first
> server). Will the current musl only capture the first "no such name"
> reply and totally miss the correct IP address reply? Is there a bug
> or any special reason?
This is the expected behavior. Support for multiple nameservers is for
redundancy, not unioning of inconsistent DNS namespaces, and in fact
these behaviors are mutually exclusive: If we were performing
unioning, every query for a nonexistent name would have to wait for
all N nameservers to reply before it could be serviced, and would
tempfail whenever any one of the N was down, while the whole point of
having N nameservers was to handle the case where one or more might be
down or responding slowly.
If you want unioning, you want to point resolv.conf at a unioning DNS
proxy running on localhost or somewhere on your network that takes the
two inconsistent upstream sources and applies whatever rules you want
for unioning them.
Rich
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-14 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 13:28 [musl] Question about res_msend_rc AK47
2024-06-14 17:40 ` Rich Felker
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).