mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Resolver overhaul concepts
Date: Sun, 4 May 2014 08:42:38 -0400	[thread overview]
Message-ID: <20140504124238.GA24010@brightrain.aerifal.cx> (raw)

Since resolver overhaul is up on the roadmap for 1.1.2, targetted for
sometime this month, I'd like to get a discussion of the proposed
design/behavior changes going.


The current behavior:

1. Determine a single matching port/protocol (if the protocol is
unspecified, only tcp is matched).

2. Special-case passive/local address requests (no host arg).

3. Try host as ip literal.

4. Parse hosts file and return a single (first matching) result from
it. (This will fail to produce multiple results, even in AF_UNSPEC
case where both v4 and v6 addresses are in the hosts file.)

5. DNS query (in parallel with multiple nameservers and possibly
v4/v6, but only a single name lookup) with results going into DNS
packet buffers.

6. Count results with a DNS packet pre-parse phase and allocate space.
Then parse the packet(s) and fill in the results. (Note: only in the
case where this step is reached can multiple results even be
returned.)


The new behavior:

1. From the beginning, have moderately large fixed-size automatic
(stack-based) buffers to store both service and address results into.

2. Find all matching services and store them into the service list.

3. If host is null or an ip literal, store a single address, as
appropriate, in the address list.

4. If address list is empty, try hosts file, inserting each matching
record into the address list. (A record only matches if the address
family matches, possibly with AF_V4MAPPED applied, or if the request
is for AF_UNSPEC.)

5. Transform hostname for IDN, if necessary.

6. If the address list is empty, perform DNS queries, but with a new
DNS query backend that's more flexible (to be described later) and
store results directly to the address list.

7. Possibly filter, transform, or sort address results. (e.g. applying
AI_V4MAPPED).

8. Allocate space for cross-product of service list and address list,
and if successful, copy the results into the allocated space.


The concepts of the new DNS query backend are not really solid yet.
One idea is that it should support the "search"/"domain" functionality
of resolv.conf to allow querying multiple seach suffixes in parallel
and returning as soon as there's a (possibly zero-length) initial run
of negative results followed immediately by a positive result. The
cleanest way to implement this kind of thing may be using a callback
function for writing each packet and for reading the responses;
otherwise, storing all the queries and responses as full DNS packets
would take an unwantedly-large amount of space.

Rich


             reply	other threads:[~2014-05-04 12:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-04 12:42 Rich Felker [this message]
2014-05-04 16:07 ` Laurent Bercot
2014-05-04 16:24   ` Rich Felker
2014-05-04 17:56     ` Laurent Bercot
2014-05-04 19:04       ` Rich Felker
2014-05-04 21:32         ` Laurent Bercot
2014-05-10  1:04     ` Andy Lutomirski
2014-05-10  2:36       ` Rich Felker
2014-05-10  9:26         ` Laurent Bercot
2014-05-10 17:41           ` 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=20140504124238.GA24010@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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).