Repository navigation
resolved: add ability for external programs to hook into name resolution (for machined+networkd to synthesize records) - #39293
Conversation
4bd03d1 to
8c7035c
Compare
|
Could you please add an integration test for this at TEST-75-RESOLVED? Thanks |
8c7035c to
f91d85e
Compare
Split out of #39293, but make a ton of sense on their own.
daandemeyer
left a comment
There was a problem hiding this comment.
As @bluca said, this really needs an integration test
it has already, both for the networkd and for the machined case! |
|
it's almost certainly going to be the new one, i.e. "/run/systemd/resolve.hook/io.systemd.Network" |
|
Yeah so if the socket unit is started it fails with: Wild, guess it has to do with the sd-run sandbox |
|
hmm, so i guess this is because of the fake networkd service run via systemd-run in NetworkdClientTest, it doesn't get a socket passed in, and it cannot create it itself because networkd is run unpriv |
|
Got the fix - ok if I push directly? |
|
sure |
It was this ^^ the test runs in a sd-run sandbox, and sets up some shimmed directory where the sockets are set up, but the new one is in a new dir that wasn't covered, so the directory from the host was passed through (hence why "already in use" if socket was running and "permission denied" if it was not, as it could not write to it) |
a87952a to
9976c7c
Compare
|
Other tests that use a different class (and run on networkd on the guest) also fail similarly: |
|
Pushed another test fix, should be ok now hopefully |
This introduces /run/systemd/resolve.hook/ as a new directory that local (privileged) programs can bind a Varlink socket into. If they do they'll get a method call for each attempted resolved lookup, which they can then either process themselves (and generate new records for, or return errors to block stuff) or let pass so that the regular resolution is done. Usecase for this is primarily two things: 1. in machined we can add local resolution of machine names to their IP addresses, similar in fashion to nss-mymachines, but working also if the non-NSS interfaces to name resolution are used, i.e. the local DNS responder. In fact, I think we should eventually remove nss-mymachines from our tree, as soon as this code in resolved is setlled. 2. in networkd we can add local resolution of names specified in DHCP leases we hand out. But beyond that there should be many other uses, for example people could write "dns firewalls" with this if they like where they dynamically block certain names from resolution. Fixes: systemd#8518
This basically implements nss-myhostname, but natively in systemd-resolved, so that the logic becomes available also for clients using the local DNS stub for resolution or the D-Bus or Varlink APIs.
Match the behaviour of the other test classes that use sd-run and always create the mock tmpfs runtime dirs. This will be needed as the new resolve.hook directory won't exist on boot but will be needed by the test case.
Let's synthesize DNS RRs for leases handed out by our DHCP server. This way local VMs can have resolvable hostnames locally. This does not implement reverse look ups for now. We can add this later in similar fashion.
This function doesn't "connect" to Varlink (i.e. it isn't a client) but it binds a Varlink socket (i.e. it is server), hence let's remove the verb "connect" from its name. let's copy how machined/resolved name the counterpart for this function: manager_varlink_init()
Let's expose local VMs/containers under ._dhcp by default. Let's also expose WIFI AP clients under .home.arpa (i.e. the RFC8375 domain for home networks).
Let's make our networkd sockets recognizable purely by name. It hink already for debugging it's a good idea to always set socket names, in particular for services that have multiple sockets they listen on. This adds a name to the rtnl socket, which so far missed one. Note that the C code won't look for it, for compat with older versions, but at least things are a bit more debuggable.
a1da5bc to
a719802
Compare
systemd-networkd-resolve-hook.socket will be introduced by systemd/systemd#39293 but we need the spec to handle the socket for the upgrade/downgrade test to pass so adding it early behind the upstream bcond.
systemd-networkd-resolve-hook.socket will be introduced by systemd/systemd#39293 but we need the spec to handle the socket for the upgrade/downgrade test to pass so adding it early behind the upstream bcond. (cherry picked from commit ea1d871)
Fixes: #8518