|
Message-ID: <CAPDSy+52ffN_Rb8JsL8=F5oeTqGVWFcDVk0F-W_H8DvsWY8RCw@mail.gmail.com>
Date: Tue, 5 Mar 2024 23:29:03 -0800
From: David Schinazi <dschinazi.ietf@...il.com>
To: musl@...ts.openwall.com
Subject: mDNS in musl
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
Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.