mailing list of musl libc
 help / color / mirror / code / Atom feed
From: David Schinazi <dschinazi.ietf@gmail.com>
To: musl@lists.openwall.com
Subject: [musl] mDNS in musl
Date: Tue, 5 Mar 2024 23:29:03 -0800	[thread overview]
Message-ID: <CAPDSy+52ffN_Rb8JsL8=F5oeTqGVWFcDVk0F-W_H8DvsWY8RCw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2244 bytes --]

Hi everyone,

I was debugging a network connectivity issue on Alpine and have tracked it
down to lack of support for mDNS in musl gethostbyname / getaddrinfo [1]. I
looked through the musl codebase to understand why, and it would be pretty
straightforward to fix. I'd be interested in writing a patch for this, so I
was wondering: would you be at all interested in potentially taking such a
patch?

Some more info on mDNS: all names that end in ".local" are reserved for use
by mDNS, and instead of sending them to the DNS resolver, they're sent
locally over multicast - and the machine with that name replies with its IP
address. It's used today to discover printers and pretty much everything in
home networks.

From looking through musl, both gethostbyname() and getaddrinfo() route
through __lookup_name(), which eventually calls name_from_dns(). From
looking at that function, the issue is that it doesn't treat .local
specifically - instead of sending those queries to multicast, it sends them
to the regularly configured DNS nameservers.

The fix would be to modify name_from_dns() [2] such that if `name` ends in
".local", then pass in a different conf variable to __res_msend_rc(). The
conf variable contains (amongst other things) the DNS nameservers to send
the query to. So, when the name ends in .local, instead of passing in the
regular nameservers, we pass the multicast addresses and ports dedicated to
mDNS (224.0.0.251:5353 and [ff02::fb]:5353).

And that's it! This implementation is compatible with the "One-Shot
Multicast DNS Queries" mode of the mDNS RFC [3]. (Other versions of libc
have a mode to send the query over dbus to avahi so that it can cache mDNS
results locally. But that's the more complicated "Continuous Multicast DNS
Querying" mode of the RFC, and we don't need that here.)

So what do you think, would you be interested in support for mDNS? (In case
it matters, I've made changes in getaddrinfo inside Apple's libc, so I'm
comfortable in this kind of code even though I have zero prior experience
with musl)

Thanks,
David


[1] https://wiki.alpinelinux.org/wiki/MDNS
[2] https://git.musl-libc.org/cgit/musl/tree/src/network/lookup_name.c#n143
[3] https://www.rfc-editor.org/rfc/rfc6762.html#section-5.1

[-- Attachment #2: Type: text/html, Size: 2838 bytes --]

             reply	other threads:[~2024-03-06  7:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06  7:29 David Schinazi [this message]
2024-03-06 16:15 ` Rich Felker
2024-03-06 16:45   ` Jeffrey Walton
2024-03-07  0:17   ` David Schinazi
2024-03-07  2:43     ` Rich Felker
2024-03-07 22:50       ` David Schinazi
2024-03-08  0:08         ` Rich Felker
2024-03-08  1:30           ` David Schinazi
2024-03-08  2:06             ` David Schinazi
2024-03-08  2:52             ` Rich Felker
2024-03-08  3:34               ` David Schinazi
2024-03-08  3:47                 ` Rich Felker
2024-03-08  4:47                   ` David Schinazi
2024-03-08 13:31                     ` Rich Felker
2024-03-08 19:15                       ` David Schinazi
2024-03-08 20:31                         ` Rich Felker
2024-03-08 21:55                           ` David Schinazi
2024-03-08 22:54                             ` Rich Felker
2024-03-08 23:44                               ` David Schinazi
2024-03-21  9:21                                 ` David Schinazi
2024-03-21 12:07                                   ` Rich Felker
2024-03-21 13:50                                     ` David Schinazi
2024-03-21 17:45                                       ` Luca Barbato
2024-03-21 19:35                                       ` Rich Felker
2024-03-22  0:10                                         ` David Schinazi
2024-03-22  0:29                                           ` Tomas Volf
2024-03-22  0:36                                             ` David Schinazi
2024-03-22  0:38                                             ` Rich Felker
2024-03-09  0:23                               ` Jeffrey Walton
2024-03-08 15:31     ` Markus Wichmann
2024-03-08 17:22       ` Rich Felker
2024-03-06 16:15 ` Markus Wichmann

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='CAPDSy+52ffN_Rb8JsL8=F5oeTqGVWFcDVk0F-W_H8DvsWY8RCw@mail.gmail.com' \
    --to=dschinazi.ietf@gmail.com \
    --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).