[task #15104] DNS: Support look-up of other RR types

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[task #15104] DNS: Support look-up of other RR types

Jasper Verschueren
URL:
  <https://savannah.nongnu.org/task/?15104>

                 Summary: DNS: Support look-up of other RR types
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: cmcqueen1975
            Submitted on: Wed 05 Dec 2018 02:31:20 AM UTC
                Category: None
         Should Start On: Wed 05 Dec 2018 12:00:00 AM UTC
   Should be Finished on: Wed 05 Dec 2018 12:00:00 AM UTC
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
                  Effort: 0.00

    _______________________________________________________

Details:

Goals:

* Allow look-up of other DNS Resource Record (RR) types such as PTR, SRV, TXT,
MX.
* Allow reverse lookups (e.g. to get the host name associated with
192.168.1.2, do a PTR look-up of 2.1.168.192.in-addr.arpa.).
* For Zeroconf, allow mDNS look-up of DNS-SD advertisements. That requires
look-up of PTR, SRV and TXT records.

Considerations, complications:

* Multiple answers (many RR responses can include multiple answers, and the
client needs to process all of them).
* Multiple responses (in the case of mDNS look-ups of DNS-SD advertisements,
there can be an unbounded number of responses from multiple network devices).
* Caching. A lot more complicated than the current case of a hostname
resolving to a single IP address.




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/task/?15104>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[task #15104] DNS: Support look-up of other RR types

Jasper Verschueren
Follow-up Comment #1, task #15104 (project lwip):

Here are some design notes I've made while contemplating this feature
(MarkDown format):

## What lwIP dns.c provides

* Encoding of DNS queries
* Decoding of DNS responses, including name compression
* DNS table stores lookups in-progress
* DNS table is also a cache for A and AAAA records
* Multiple simultaneous requests
* Callback on result (called once only for each request)
* Randomised source port for each request (optional)
* Retries
    * Try multiple DNS servers
* mDNS lookups instead, for `.local.` domain
* Lookup A record, and fallback to AAAA record (and vice-versa) (according to
`addrtype`)

## What is different for other RRs

* Other RRs can have bigger responses (CNAME, MX, PTR, SRV and especially
TXT).
    * TXT records can potentially be large and unbounded (according to [DNS-SD
TXT records](http://www.zeroconf.org/Rendezvous/txtrecords.html), max 100...
or 400... or 1300), but each character-string within is a max of 256 bytes.
* We care about multiple answers in the DNS response.
    * e.g. for DNS SRV or NAPTR queries, multiple responses are
possible/likely.
    * Note that for A or AAAA queries, multiple responses are also possible
for load sharing. lwIP only saves one response in the cache.
* We care about additional answers.
    * e.g. SRV or MX responses might have target's A record in additional
answers.
    * Should such an A record IP address be stored in the cache?
* For mDNS DNS-SD queries, we care about multiple responses. There can be an
unbounded number of multiple responses.
* Call the callback function multiple times.
    * How does lwIP know when it's done? Hard to say for mDNS DNS-SD PTR query
of a service name; need a timeout)
    * How does user know when it's done? Hard to say unless lwIP calls it with
a NULL parameter when it's done.
* Responses being more than a simple IP address response, don't fit in
existing DNS table. Caching would require larger table(s) and more complex
structures.
* No fallback to a different RR type, according to `addrtype` mechanism.
* Callback function has different type for 2nd parameter.
    * The data is different depending on the RR type.
    * Several records contain a target name, which makes the data much larger
than A or AAAA records. But the target name would be expected to be max
`DNS_MAX_NAME_LENGTH`.
    * TXT records can potentially be large and unbounded, but each
character-string within is a max of 256 bytes, so it may be worth calling the
callback once for each character-string in the record.
* For reverse DNS query (look up IP address a.b.c.d to get host name), look up
is of form `d.c.b.a.in-addr.arpa` (for IPv4).
    * It's worth adding a new function to facilitate this reverse look-up.
    * Need a flag to select between DNS or mDNS, since there's no `.local` in
the host name to indicate it in the mDNS case.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/task/?15104>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[task #15104] DNS: Support look-up of other RR types

Jasper Verschueren
Follow-up Comment #2, task #15104 (project lwip):

I'm adding a patch for my experimental development work on this task. It's
reasonably functional, with the following caveats:

* For mDNS look-ups, only the first response is processed. This is a
limitation that limits its usefulness for DNS-SD queries (e.g. doing a PTR
lookup of _http._tcp.local.). It should be expanded to process multiple
responses, with a timeout and/or a "cancel" function as needed.
* In future, it would be good to add a function specifically for doing reverse
DNS look-ups. E.g. looking up the hostname for 192.168.1.2, it would do a PTR
look-up for 2.1.168.192.in-addr.arpa. A flag would be needed to select between
DNS or mDNS.
* I haven't thoroughly reviewed it to consider packet handling for various
faulty/malicious packets.
* This change is functional, but I'm not happy with the readability and
maintainability of the code. I would like to refactor it if possible, to split
it into more succinct, comprehensible and maintainable functions.

(file #45583)
    _______________________________________________________

Additional Item Attachment:

File name: 0001-DNS-Initial-support-for-other-RR-lookups.patch Size:31 KB


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/task/?15104>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel