qqt

Address family

IPv6 as an ordinary address family

How -4 and -6 filter every lookup, bind and dial, what --listen [::] actually answers, and why the zone on a link-local literal matters.

|hadron|: QQT-011 the address family is one tri-state every lookup, bind and dial reads — a -4 that reached the tunnel’s dial but missed a -l listener, or a [::] bind that answered one family on one kernel and two on another, would each be a silent reachability hole no single flag could close.

IPv6 is a first-class address family in qqt, not a parsing afterthought. This file owns the two decisions that makes true, and the exemplar each one follows.

One recorded divergence from this exemplar: ssh accepts -4 -6 and lets the last one win. qqt refuses the pair, because a command line carrying both states no intent the tool can honour and a silent last-wins is the kind of thing an operator discovers from a packet capture.

The exemplar, per dimension

Behavior dimensions and the tool each one is taken from — one exemplar per dimension, never one tool for the whole mechanism:

  • CLI and failure — OpenSSH. -4 and -6 are one address_family tri-state, unset meaning “any”, and the unset value is normalised once at parse time rather than re-decided at each use. ssh threads that one value through its resolver (ssh.c’s getaddrinfo hints), its filters, and — the part that is easy to get wrong — its forwarding listeners (channels.c), so a -4 reaches the bind as surely as the dial. AddressFamily here is that shape, and run() reads it once and passes it to every surface.
  • Failure — OpenSSH’s connect loop. ssh walks every address the resolver returned, in order, before reporting failure (ssh_connect_direct). qqt does the same: resolve_remote returns the whole admitted list and the client walks it, one CONNECT_TIMEOUT per candidate, with --reconnect retrying the list rather than remembering a winner. A name with an A and an AAAA record is two chances to reach the box, not one.
  • Address grammar — OpenSSH’s hpdelim2/cleanhostname. ssh never routes a host through an address parser, which is why fe80::1%eth0 works there and did not work here: clap’s SocketAddr parses the numeric form only. HostPort splits outside brackets and defers resolution to the resolver, so the zone survives to the syscall.
  • Bind reach — no exemplar exists; stated instead. Nothing in Unix makes a wildcard bind dual-stack portably: bindv6only is a host sysctl, and both std and quinn’s Endpoint::server leave it alone. So the socket is built here and IPV6_V6ONLY is set explicitly on a [::] bind — cleared when the run admits both families, kept set under -6 — with a refusal being fatal rather than a silently one-family listener.

A recorded divergence: the empty bind

ssh -L 8080:host:80 with no bind host yields both loopback families. qqt’s empty bind means the loopback of the requested family — 127.0.0.1 by default, ::1 under -6 — so -l :18080:… keeps working in a v6-only run instead of failing on a v4 literal it never asked for. [::1] asks for the v6 loopback explicitly and [::] for every interface.

The distinction is tracked as a flag on the spec (bind_defaulted) rather than by the host string, because an explicit 127.0.0.1 under -6 is the operator’s choice and is refused: only a default may be re-pointed at the requested family.

Why IPV6_V6ONLY is set rather than trusted

The server, the metrics listener, the -l listeners and the server-side -R binds all take one helper each for UDP and TCP. Without it, whether --listen [::]:4433 serves an IPv4 client is a property of the host’s net.ipv6.bindv6only — and a tunnel that answers one family on one box and two on the next is exactly the kind of “it works on my machine” gate a first-class family cannot have. One flag, one meaning, every kernel: a bare [::] is dual-stack, and -6 with [::] is v6-only because narrowing exposure is what the flag is for.

A -R bind follows the server’s flag

The bind is made by the server, so the server’s -4/-6 decides it — the client’s flag governs the target that client dials. A control frame carrying the client’s family would be a second authority for one socket, and two senders of one pipe is the drift the contract exists to prevent.

What this deliberately does not do

No happy-eyeballs race, no preference ordering beyond the resolver’s own, and no per-forward family override. Those are preferences; -4/-6 is a filter, and a filter can be reasoned about where a preference cannot.

← All documentation