mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: [musl] TCP support in the stub resolver (was: Re: Outgoing DANE not working)
Date: Sat, 18 Apr 2020 19:14:24 +0200	[thread overview]
Message-ID: <87o8ro67in.fsf_-_@mid.deneb.enyo.de> (raw)
In-Reply-To: <20200417160726.GG11469@brightrain.aerifal.cx> (Rich Felker's message of "Fri, 17 Apr 2020 12:07:26 -0400")

* Rich Felker:

> On Fri, Apr 17, 2020 at 11:22:34AM +0200, Florian Weimer wrote:
>> >> > However it's not clear how "fallback to tcp" logic should interact
>> >> > with such concurrent requests -- switch to tcp for everything and
>> >> > just one nameserver as soon as we get any TC response?
>> >> 
>> >> It's TCP for this query only, not all subsequent queries.  It makes
>> >> sense to query the name server that provided the TC response: It
>> >> reduces latency because that server is more likely to have the large
>> >> response in its cache.
>> >
>> > I'm not talking about future queries but other unfinished queries that
>> > are part of the same operation (presently just concurrent A and AAAA
>> > lookups).
>> 
>> If the second response has TC set (but not the first), you can keep
>> the first response.  Re-querying both over TCP increases the
>> likelihood that you get a response from the same cluster node (so more
>> consistency), but you won't get that over UDP, ever, so I don't think
>> it matters.
>> 
>> If the first response has TC set, you have an open TCP connection you
>> could use for the second query as well.  Pipelining of DNS requests
>> has compatibility issues because there is no application-layer
>> connection teardown (an equivalent to HTTP's Connection: close).  If
>> the server closes the connection after sending the response to the
>> first query, without reading the second, this is a TCP data loss
>> event, which results in an RST segment and potentially, loss of the
>> response to the first query.  Ideally, a client would wait for the
>> second UDP response and the TCP response to arrive.  If the second UDP
>> response is TC as well, the TCP query should be delayed until the
>> first TCP response came back.

> Indeed it sounds like one TCP connection would be needed per request,
> so switchover would just be per-request if done.

No, you can reuse the connection for the second query (in most cases).
However, for maximum robustness, you should not send the second query
until the first response has arrived (no pipelining).  You may still
need a new connection for the second query if the TCP stream ends
without a response, though.

> My leaning is probably not to do fallback at all (complex logic,
> potential for unexpected slowness, not needed by vast majority of
> users) and just add TCP support with option use-vc for users who
> really want complete replies. All of this would be contingent anyway
> on making internal mechanisms able to handle variable result size
> rather than fixed-size 512 bytes so it's not happening right away.
> Doing it carelessly would create possibly dangerous bugs.

I still think it's wrong.  The protocol says that you must perform TCP
fallback.  If you don't, it's rather confusing for the libresolv
interfaces.

> I'm still also somewhat of the opinion that users who want a resolver
> library (res_* API) with lots of features should just link BIND's, but
> it would be nice not to have to do that.

You could drop the res_* interfaces from musl.  They are mostly needed
for non-address queries, and those are the ones that tend to be larger
than 512 bytes.

Then it might be possible that no one will notice the missing TCP
fallback.

  reply	other threads:[~2020-04-18 17:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fce05ab0ed102dec10e4163dd4ce5d8095d2ffd7.camel@web.de>
     [not found] ` <20200412211807.GC41308@straasha.imrryr.org>
     [not found]   ` <d64b1b8801cc5350e9d27dd109dd2446e7d4b860.camel@web.de>
     [not found]     ` <20200413024746.GD41308@straasha.imrryr.org>
     [not found]       ` <b38668e94b2781003a14c6dca3d41edf33e347e2.camel@web.de>
     [not found]         ` <A2FE67B5-A9A9-4A0F-A59D-78FF2AB992B7@dukhovni.org>
     [not found]           ` <f79a9f0c369607fc38bef06fec521eaf3ab23d8c.camel@web.de>
     [not found]             ` <6E8A9D4F-18CE-4ADA-A5B4-D14DB30C99E5@dukhovni.org>
     [not found]               ` <25e70f31f0c4629f7a7d3957649d08be06144067.camel@web.de>
     [not found]                 ` <CECAFB36-DA1B-4EFB-ACD1-294E3B121B2E@dukhovni.org>
2020-04-13 18:35                   ` [musl] Re: Outgoing DANE not working Rich Felker
     [not found]                     ` <20200413190412.GF41308@straasha.imrryr.org>
     [not found]                       ` <20200413193505.GY11469@brightrain.aerifal.cx>
     [not found]                         ` <20200413214138.GG41308@straasha.imrryr.org>
     [not found]                           ` <20200414035303.GZ11469@brightrain.aerifal.cx>
     [not found]                             ` <87v9m0hdjk.fsf@mid.deneb.enyo.de>
     [not found]                               ` <20200415180149.GH11469@brightrain.aerifal.cx>
     [not found]                                 ` <87imi0haf7.fsf@mid.deneb.enyo.de>
     [not found]                                   ` <20200417034059.GF11469@brightrain.aerifal.cx>
     [not found]                                     ` <878siucvqd.fsf@mid.deneb.enyo.de>
2020-04-17 16:07                                       ` Rich Felker
2020-04-18 17:14                                         ` Florian Weimer [this message]
2020-04-19  0:03                                           ` [musl] TCP support in the stub resolver (was: Re: Outgoing DANE not working) Rich Felker
2020-04-19  8:12                                             ` [musl] TCP support in the stub resolver Florian Weimer
2020-04-20  1:24                                               ` Rich Felker
2020-04-20  6:26                                                 ` Florian Weimer
2020-04-20 17:39                                                   ` Rich Felker
2020-04-21  9:48                                                     ` Florian Weimer
2020-04-21 15:02                                                       ` Rich Felker
2020-04-21 17:26                                                         ` Florian Weimer
2020-05-01 22:02                                                           ` Rich Felker
2020-05-02 15:28                                                             ` Florian Weimer
2020-05-02 15:44                                                               ` Rich Felker
2020-05-02 22:52                                                                 ` Bartosz Brachaczek
2020-05-03  8:46                                                                   ` Florian Weimer
2020-05-03 16:51                                                                     ` Rich Felker
2020-05-03 17:19                                                                       ` Florian Weimer
2020-05-03 18:18                                                                 ` Florian Weimer
2020-05-03 19:09                                                                   ` Rich Felker
2020-05-03 19:34                                                                     ` Florian Weimer
2020-05-03 19:45                                                                       ` Rich Felker
     [not found]                             ` <20200414061620.GI41308@straasha.imrryr.org>
     [not found]                               ` <20200414160641.GC11469@brightrain.aerifal.cx>
     [not found]                                 ` <20200414215951.GJ41308@straasha.imrryr.org>
2020-05-19  1:37                                   ` [musl] Re: Outgoing DANE not working Rich Felker
     [not found]                                     ` <20200519023814.GN68966@straasha.imrryr.org>
2020-05-19  5:44                                       ` Rich Felker
     [not found]                                         ` <20200519090610.GO68966@straasha.imrryr.org>
2020-05-19 14:00                                           ` Rich Felker
2020-05-19 14:23                                             ` Wietse Venema
2020-05-19 14:28                                               ` 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=87o8ro67in.fsf_-_@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=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).