Skip to content

C01 - Network and DNS

Purpose: The test cases for the guest’s network path: the link endpoint, addressing, and the DNS gateway with its hold, quiet refusals, and negative answers.

Verifies: S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections. (“Addressing”), S07-18-build-networkS07-18-build-network: Build NetworkThe build VM's network: what its wb-netd serves, the one connection to the guest's port 22, and its refusal for session VMs., S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget. (“Messages”, “Order of checks”, “Name form”, “Synthetic pool”, “Local answers”, “Negative answers”, “Wildcard budget”), S07-04-dns-refusalsS07-04-dns-refusals: DNS RefusalsHow wb-netd refuses a name: approval events, the hold before each refusal, quiet refusals, and the answer that is the same for every reason. (“Hold”, “Widening during the hold”), S04-02-vm-providerS04-02-vm-provider: VM Provider and StreamsHow wb-vmd hands guest connections and the NIC endpoint to other processes, the fixed device set of a VM, and where wb-proxyd takes a stream's identity from. (“The device set is fixed and checked”)

Negative answers and approvals during a lookup

Section titled “Negative answers and approvals during a lookup”
  • Resolve a name that isn’t allowlisted, approve it within 4 seconds, and see the same lookup answered with an address.
  • Resolve another, leave it unanswered, and see NXDOMAIN after 4 seconds with an SOA record of TTL 0 and MINIMUM 0. Then approve it, resolve it again within 1 second of the approval, and see it succeed, so the guest didn’t cache the refusal. A guest resolver that keeps a minimum negative cache time despite the zero TTL fails this check, and the delay it adds after a late approval is then written into S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget., “Negative answers”.
  • See that an empty AAAA answer for an allowed name has the TTL of its A answer.

The host-side parts of “Lookups”, “Negative answers and approvals during a lookup” and “Hold” run as Go tests in internal/netd/dns, with fakes and testing/synctest as the clock:

  • TestAllowedA, TestOtherTypes and TestPoolFull: the answers to an allowed name, and REFUSED at once for TXT.
  • TestLocalAnswers: the local answers, at once with the zero SOA.
  • TestRefusalsAreAlike: every refusal reason gives the same bytes, sent at 4 seconds and not before, also with each accounting write taking 99 ms.
  • TestBackground and TestBackgroundPastBudget: quiet refusals in mixed case and past the budget, and an approval event for a name one label longer.
  • TestBudgetDebits, TestBudgetSpent and TestKeptBudget: which lookups debit the wildcard budget, and what is refused once it is used up.
  • TestHoldFull and TestClose: the hold limit, and no held refusal sent after the server closes.
  • TestFormFloodSpendsRate: a name that fails the form spends a rate token.
  • TestRateDrops and TestRateFloodLeavesHoldRoom: a query over the rate is dropped at once, logged and counted with dns-query-rate, and a flood over the rate leaves room in the held-query table for a name that raises an approval event, at the smallest cap.
  • TestHeldQueriesMinimum: a held-query cap the rate could fill in one hold is refused.
  • TestParseQueryRefuses: every dns-message-form case is dropped without an answer.

TestDNSOverUDP (internal/netd/stack) sends real UDP queries through the stack: an allowed name resolves at the gateway, and a query to another server is dropped with udp-not-dns.

  • Start wb-netd with no mode, and with an unknown one, and ask each for the connection to the guest’s port 22. See each refused and logged with build-connect-refused and the check, with no SYN sent to the guest.
  • Send a build VM’s wb-netd a control message that names a mode, and see it refused with build-mode-refused and the mode unchanged.
  • Ask the build VM’s wb-netd with another VM’s name, with an older generation, and twice at once, and see each refused with build-connect-refused. After it has handed a socket, ask again and see that refused too.
  • With nothing listening on the guest’s port 22 at first, see wb-netd try again, then hand one socket and log build-connect once sshd answers. With nothing listening at all, see build-connect-timeout at the deadline and no socket.
  • From the build guest, open TCP to a raw IP address, the gateway and a synthetic address, and send a DNS query. See each reset or dropped and logged with build-egress-refused, and no stream handed to wb-proxyd.

These run as Go tests:

  • TestDecodeBuildMode (internal/egressmsg): a start whose mode is missing or unknown makes a session VM’s wb-netd, and a build start must name the VM build. FuzzControlMessage covers the new messages.
  • TestBuildConnectRefused (internal/netd/hostlink): a session VM’s wb-netd, another VM, an older and a newer generation, and a second connect while one runs are each refused with build-connect-refused, and none of them tries to connect. TestBuildConnect ends with the refusal after a socket was handed.
  • TestBuildModeRefuses and TestSecondStartMode: a hand-off socket, policy change, active period start or second start in build mode is refused with build-mode-refused. FuzzNetdControl checks that a session VM’s wb-netd never tries the connection.
  • TestBuildConnect and TestBuildConnectTimeout: tries until the guest answers, then build-connect and one socket, or build-connect-timeout and no socket at the deadline.
  • TestDialGuest, TestDialGuestRefusedByGuest, TestDialGuestNoAnswer and TestDialGuestSessionRefused (internal/netd/stack): the connection to the guest’s port 22. TestBuildRelay (internal/netd/handoff) relays it over the socketpair.
  • TestBuildEgressRefused (internal/netd/stack) and TestFilterBuild (internal/netd/link): TCP from the build guest is reset and UDP from it dropped, DNS included, with build-egress-refused.
  • TestChildSessionRefusesBuild (cmd/wb-netd) runs the confined process with no mode and with an unknown one. Its refusal of the connection, with build-connect-refused, reaches the event channel, and wb-netd doesn’t send the guest a SYN.
  • TestStrayBuildSocketRefused (internal/hostd/netdproc): wb-hostd refuses a BuildSocket from a session VM’s wb-netd and closes its descriptor.
  • TestChildBuild (cmd/wb-netd) runs the confined process in build mode through a refused connect, a reset, and a SYN to port 22.

Status: Draft