mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Other DNS/stub resolver changes
@ 2022-09-21 16:08 Rich Felker
  2022-09-21 22:19 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2022-09-21 16:08 UTC (permalink / raw)
  To: musl

In the process of working out TCP fallback support, some other
potential/likely changes to the DNS/stub resolver behavior are
emerging, which I'd like to document here and open for feedback.

The EAI_NODATA is already covered in an existing thread.

One weird thing I noticed is that, while lookup_name.c's name_from_dns
is processing error RCODE values, it actually never sees them because
__res_msend just treats errors as non-answers. This probably doesn't
matter, but it does prevent us from ever issuing EAI_FAIL. And from
the standpoint of the res_* API (res_query/res_send) the caller may be
expecting to see specific errors and to be able to act on them (todo:
check what other implementations do here).

The reason __res_msend doesn't return errors packets is a consequence
of implementation details, specifically, that it considers erroring
slots unanswered, and reuses the buffer for them as temp space to
receive answers that might turn out to be for another query, which
clobbers them.

This is rather ugly, and I think I'd like to give __res_msend its own
512-byte receive buffer to receive into. This would give us the choice
to keep error results or not, as we see fit, rather than tying us to
the current behavior.

I almost said this would also avoid tying the receive logic to a
choice to use one socket per TCP query vs doing multiple queries over
the same TCP socket, since all reads could just take place into this
buffer. However, that ignores pathological partial reads, whereby we
might have to wait after receiving the first 1-3 bytes to get the 4th
byte and know which query the answer belongs to. So if we want to do
that, we need a 3-byte buffer for each tcp socket where we might have
received data but not yet know which query it goes with. However we
can still recv into the 512-byte receive buffer, and then only move to
a 3-byte pending buffer if it's <=3 bytes, and otherwise move to the
appropriate answer buffer.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-21 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 16:08 [musl] Other DNS/stub resolver changes Rich Felker
2022-09-21 22:19 ` 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).