8.3 The resolver channel

The channel's contract — that a resolver subscribes, and receives whole snapshots, never deltas — is PSPU §6.9. This article is netd's half of it.

8.3.1 Subscribing #

A subscribe request on the control socket (§9.2), which needs the query right, is answered with a snapshot at once, and the connection is kept: switched to non-blocking and added to the subscriber list. It is the one request that does not end its connection.

The first snapshot is the last one published, or, before any has been, one computed on the spot.

8.3.2 When snapshots are sent #

At every publish (§2.2) netd computes the snapshot and compares it with the last one sent. If it differs, it is sent to every subscriber. If it is equal, nothing is sent.

A subscriber that cannot take the whole frame at once — closed, or so far behind that its socket buffer is full — is dropped. A resolver reconnects and receives a fresh snapshot.

8.3.3 The snapshot #

A reply map with ok = true, kind = snapshot, hostname — the name netd last set (§8.4), empty if none — and scopes: one scope per joined interface whose level is above absent, ordered by the interface's metric, then its kernel index.

Each scope:

FieldContent
ifidthe interface id
namethe kernel name
serversDNS servers, as text, in the order to try them (below)
domainssearch domains, likewise
ntpthe lease's NTP servers (option 42)
addressesevery address the kernel holds on the interface, address/prefix, link-local ones included
default_routethe profile's Dns.Default when set; otherwise whether the interface's level is routed
exclusivethe profile's Dns.Exclusive
metricthe interface's metric (§4.2)
levelthe interface's level (§8.2)

8.3.4 Merging DNS facts #

Servers, in this order:

  1. the profile's Dns.Servers, always;
  2. with Dns.Offered: the lease's servers (option 6);
  3. with Dns.Offered: the routers' RDNSS servers, including link-local IPv6;
  4. with Dns.Offered: the DHCPv6 reply's servers, including link-local IPv6.

Domains, in this order:

  1. the profile's Dns.Domains, always;
  2. with Dns.Offered: the lease's domain search list (option 119) if it is not empty, otherwise its domain name (option 15);
  3. with Dns.Offered: the routers' DNSSL domains;
  4. with Dns.Offered: the DHCPv6 reply's domains.

Each list removes duplicates across the entire list, retaining the first occurrence and the source order above. This includes repeated values with other values between them.

The containing scope supplies the interface for link-local IPv6 servers. resolvd uses its index on UDP and TCP upstream sockets; the address text does not need a zone suffix. Deploy this publication change with a resolver that supports interface-scoped upstreams (resolvd TRM §4.7).

NTP servers are reported whatever Dns.Offered says. Whether to believe a lease's time servers is timed's decision, made against its own registry value. A snapshot describes what the network said.

The same merge feeds the dns and search fields of the status reply (§9.2), for every non-loopback interface, joined or not.

Edit this page