Repository navigation
resolvectl: Add show-multicast verb to show discovered LLMNR/mDNS hosts - #18355
Conversation
From the UI point of view, this sounds a bit confusing to me - is there a different verb that could best describe what it does? show-discovered maybe? |
|
list-known maybe ? |
|
I suggest |
|
As Visual Studio Code now supports only formatting modified lines and we have a .clang-format config in the repository, I tried using clang-format while writing this PR, formatting only the modified lines. For tables, clang-format unfortunately doesn't do the right thing, so I added directives to turn off clang-format for the tables I touched to the source code. Let me know if we want to allow these directives in the source code to allow more seamless usage of clang-format or if these should be removed. The comma change is also done by clang-format as the comma's are part of the Maybe |
|
list-discovered is shorter, and in the context of resolvectl it's probably clear enough... |
68a1578 to
9475209
Compare
|
Renamed to list-discovered (D-Bus method to ListDiscovered) |
|
Two interesting things I noticed while testing this:
|
8d670d7 to
d9f45ad
Compare
keszybz
left a comment
There was a problem hiding this comment.
Looks all good, except for the name. I know naming is hard, but "discovered" is pretty much meaningless without explanation. In particular, classis DNS names we have in the cache have also been "discovered", and it wouldn't be clear why they are not included in this output. We call mDNS + LLMNR "multicast dns", but that name is very close to MulticastDNS/mDNS, so can't be used directly. My other idea would be something like "local hosts", but obviously that is too close to "localhost". But I think we need to find some word that emphasizes that this about non-unicast-dns names. Maybe "list-multicast-names" or "list-multicast-hosts"?
Another approach. We currently don't have a I don't think cache dumping should be totally unprivileged. It may create an information leak. It seems OK for mDNS/LLMNR names, but for classic DNS we should probably go through polkit. |
|
What about show-multicast? I agree that this is pretty narrow and maybe a larger dump-cache verb would be better but is dumping the entire dns cache really going to be useful for users? I'd think users would primarily be interested in the multicast hosts. For developers, having the dns cache could be useful but it's already possible to dump the cache by sending a signal to resolved. That should be sufficient for development purposes no? |
systemd is compiled with relative source file paths so we need to issue a directory command to make sure gdb can find systemd's source files. Let's put this in a .gdbinit file so it's executed automatically when we run gdb.
|
|
GetMulticastHosts() returns an array of hostnames/addresses discovered via LLMNR or Multicast DNS. It does not trigger any discovery on its own. Instead, it simply returns whatever is already in resolved's cache.
d9f45ad to
d7080f3
Compare
|
Renamed the verb to show-multicast and the D-Bus method to GetMulticastHosts(). |
d7080f3 to
52fd79f
Compare
I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by systemd#18355 (comment)
I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by #18355 (comment)
The show-multicast verb calls the GetMulticastHosts() D-Bus method and displays all its results formatted into a table.
52fd79f to
ad612eb
Compare
|
hmmpf, i am not sure i like this concept. the thing is that people might believe the shown list is comprehensive, but it really is not. it's just what is cached, i.e. what was recently asked for or recently announced. there might be a lot more on the network, and there's no guarantee whatsoever that this is complete. there's also the problem that dbus sucks for passing along huge amounts of data, and my guess is that a fully populated cache might hit the dbus message size limits if you have plenty of interfaces. quite frankly, i#d drop this again the way this is. what we can add is a "dump-cache" verb or so, (or "show-cache") but it should be able to dump all kinds of RRs and then hook this up with --type= and --class= to do filtering, as well as --interface= and --protocol= to limit things. You could then do "resolvectl dump-cache --protocol=mdns --type=A --type=AAAA" to get the data this command currently shows. And i figure to make this work via dbus one approach could be to serialize the RR data into JSON, and then pass a memfd over to it. sorry i didn't review this earlier. I know I am a bit late. But i don't think we should leave this in as it is right now. |
|
my key point really is: it needs to have "cache" in the name, so that people understand this is just cached info and not comprehensive. even if we wanted to neither llmnr nor mdns actually provide a way to get a complete dump of hosts. they simply don't describe a query like that. |
|
I'm just wondering if show-cache isn't too extensive. I think this approach is 20% of the work for 90% of the benefit. If we exclude DNS, are we really expecting so many entries that we'll reach the D-Bus message limit? I don't mind changing it to use a memory fd but I was thinking that'd be overkill. I really want to keep it to a single verb though without having to pass tons of options just to get the LLMNR/mDNS hosts that resolved knows out. I don't mind renaming to |
|
well, people run systems with thousands of interface, so yeah, i think this is a real problem. I'd be fine to add a shortcut like "-M" to mean the same as "--type=a --type=aaaa --protocol=mdns --protocol=llmnr" or so, then you could do "resolvectl show-cache -M", which should be shorter than your current verb |
|
I was assuming we'd hit resolved's cache size limit long before we'd ever run into problems. Or does that not apply to LLMNR/mDNS? But OK, I'll implement the full cache dump version when I get some time |
I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by systemd/systemd#18355 (comment)
I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by systemd/systemd#18355 (comment)
resolvectl currently lacks an easy way to list what hosts have been discovered on the local network via LLMNR or mDNS. With the show-multicast verb, this information is displayed (formatted in a table).
Fixes #14796
Depends on #18354
Test plan:
Output: