9.2 Requests

9.2.1 Framing #

The control socket is a PSPU observability query channel: one length-prefixed MessagePack map in each direction, one request and one reply per connection, except subscribe.

  • A frame is a 4-byte little-endian payload length, then the payload.
  • A length above 65536 is refused before any of the payload is read, with {ok: false, error: "message of <n> bytes exceeds the ceiling"}.
  • A request is a map with a string query. Unknown keys are ignored, and a key that appears twice refuses the request.
  • A reply is a map with a boolean ok, and either the result's fields or a string error.

An oversized, incomplete-at-EOF, or undecodable request is answered with an error reply and the connection ends:

Problemerror
no querymissing field query
an unknown queryunknown query "<query>"
a duplicate keyduplicate field <key>
renew without interfacemissing field interface
malformed MessagePackmalformed message: …

Expired client deadlines and failed socket I/O close the connection without a reply (§9.1). A normal reply that exceeds the message ceiling is replaced with an error reporting its size.

9.2.2 The requests #

queryRightDoesReply
statusNETWORK_QUERYnothingthe status (below)
subscribeNETWORK_QUERYkeeps the connection as a subscriber (§8.3)a snapshot now, and another on each change
reconcileNETWORK_CONTROLa full pass (§2.2){ok: true}
renew, with interfaceNETWORK_CONTROLthe client renews (§5.4){ok: true}, or an error

renew finds its interface by kernel name or by interface id. It answers no interface <name> when there is none, and <name> is not using DHCP when the interface has no DHCPv4 client.

9.2.3 The status reply #

FieldContent
hostnamethe name netd last set, empty if none (§8.4)
levelthe machine level (§8.2)
refusalwhy the newest generation was refused, or nil (§3.2)
interfacesone map per non-loopback interface netd has seen, joined or not, in kernel index order

Each interface:

FieldContent
ifid, name, indexthe interface id, kernel name and index
mac, path, driveridentity (§4.1); empty strings when absent
verdictJOIN, IGNORE or DOWN; nil when the backstop answered or rules tied
rulethe rule that spoke, backstop, or the tied rules <a> vs <b>
profilethe profile path, JOIN only
network, network_name, network_trustthe network identified now (§7)
warningdiscovery unanswered (§5.2), or a tie (§3.3); nil otherwise
up, carrierthe link's flags
levelthe interface's level (§8.2), computed for every interface
addressesevery address the kernel holds, address/prefix, link-local ones included
gateway, gateway6the gateway of the interface's first IPv4 and IPv6 default route, any owner's
dns, searchthe merged DNS facts (§8.3); empty for an interface not joined
leasewhile the client holds a lease: server, expires_in (whole seconds), state (§5.1), duration (the lease's length), and renew_at and rebind_at (T1 and T2), the last three in whole seconds after the lease was bound; nil otherwise. A client reading a netd that predates the last three finds them absent.

Edit this page