nx_netscope_dns.nx
buildroot/runtime/nx_netscope_dns.nx
about
nx_netscope_dns.nx -- NX-NETSCOPE L0 (timeout-recv keystone) + L1
(DNS multi-path parallel prober). The headline EXCEED + the <5s
one-shot diagnosis of the dual-homed split-horizon DNS race that makes
nishifamily.com / andelinwest.com resolve slowly (or NXDOMAIN) from the
LAN. See docs/NX_NETSCOPE_CHARTER.md sections 2/3/8.
REUSES (never reinvents -- standing rule): nx_dns_build_query,
nx_dns_parse_response_a, nx_dns_get_u16_be and the DNS flag/RCODE
constants from nx_dns.nx; the socket+sockaddr flow from
nx_dns_resolve_a_record.nx; the SO_RCVTIMEO timeval pattern from
nx_iot_set_rcvtimeo_ms (ported here to avoid dragging the announce
module's deps).
EXCEED vs dig/nslookup: those query ONE resolver (or the OS resolver,
which is the very thing that's broken). This fires a (server x host)
MATRIX, each cell SO_RCVTIMEO-bounded (never hangs), dissects the RCODE
(NXDOMAIN/SERVFAIL/REFUSED vs A), and flags the two failure modes the
OS hides: the WOULD-POISON race (one resolver answers NXDOMAIN while
another has the A -> Windows smart-multi-homed accepts the wrong one)
and the PUBLIC-vs-RFC1918 hairpin (an owned domain resolving to its
public IP instead of the internal 192.168.8.240).
license_tier: ORIGINAL
genealogy_id: nishi_nx_netscope_l0_l1
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_dns.nx
imported by: nx_netscope_dns_test.nxnx_netscope_verdict.nx
structs
| 59 | struct ProbeCell |
consts
| 28 | const NXNS_MAGIC_2048: i64 = 2048 |
| 32 | const NXNS_SO_RCVTIMEO: i64 = 20 // Linux SO_RCVTIMEO optname |
| 33 | const NXNS_DNS_PORT: i64 = 53 |
| 34 | const NXNS_EAGAIN: i64 = 0 - 11 // -EAGAIN/-EWOULDBLOCK = recv timed out |
| 37 | const NXNS_OK_A: i64 = 0 // got an A record (rcode 0, ancount>0) |
| 38 | const NXNS_NOERROR_NO_A: i64 = 1 // rcode 0 but no A (ancount 0 / only other types) |
| 39 | const NXNS_NXDOMAIN: i64 = 2 // rcode 3 |
| 40 | const NXNS_SERVFAIL: i64 = 3 // rcode 2 |
| 41 | const NXNS_REFUSED: i64 = 4 // rcode 5 |
| 42 | const NXNS_RCODE_OTHER: i64 = 5 // rcode 1/4/6+... |
| 43 | const NXNS_TIMEOUT: i64 = 6 // SO_RCVTIMEO fired -- THE no-hang guarantee |
| 44 | const NXNS_NOT_RESPONSE: i64 = 7 // QR=0 |
| 45 | const NXNS_TRUNCATED: i64 = 8 // TC=1 |
| 46 | const NXNS_TXID_MISMATCH: i64 = 9 // possible spoof / stale packet |
| 47 | const NXNS_SOCKET_FAIL: i64 = 10 |
| 48 | const NXNS_SEND_FAIL: i64 = 11 |
| 49 | const NXNS_BAD_HEADER: i64 = 12 |
| 50 | const NXNS_PENDING: i64 = 99 // L1.1 parallel: cell awaiting poll() response |
| 51 | const NXNS_POLLIN: i64 = 1 // poll() events/revents bit for "readable" |
| 54 | const NXNS_RCODE_SERVFAIL: i64 = 2 |
| 55 | const NXNS_RCODE_NXDOMAIN: i64 = 3 |
| 56 | const NXNS_RCODE_REFUSED: i64 = 5 |
| 70 | const NXNS_PROBECELL_BYTES: i64 = 64 |
functions
| 77 | func nxns_set_rcvtimeo_ms(fd: i64, ms: i64) -> i64 |
| 97 | func nx_dns_recv_timed(fd: i64, buf: *u8, cap: i64, timeout_ms: i64, |
| 106 | func nxns_is_rfc1918(ipv4: i64) -> i64 called by 1: nxns_dissect_response |
| 123 | func nxns_dissect_response(resp: *u8, got: i64, tx_id: i64, cell: *ProbeCell) -> i64 |
| 159 | func nx_dns_probe_one(server_ip: i64, host: *u8, host_len: i64, called by 2: nx_dns_probe_matrixmain calls 8: sys_mmapnx_dns_build_querysys_socketsys_now_mssys_sendtosys_close+2 |
| 221 | func nx_dns_probe_matrix(servers: *i64, n_servers: i64, calls 1: nx_dns_probe_one |
| 257 | func nxns_pollfd_set_fd(buf: *u8, i: i64, fd: i64) -> i64 |
| 265 | func nxns_pollfd_get_fd(buf: *u8, i: i64) -> i64 |
| 272 | func nxns_pollfd_set_events(buf: *u8, i: i64, ev: i64) -> i64 |
| 278 | func nxns_pollfd_get_revents(buf: *u8, i: i64) -> i64 called by 1: nx_dns_probe_matrix_parallel |
| 289 | func nx_dns_probe_matrix_parallel(servers: *i64, n_servers: i64, called by 2: mainmain calls 13: sys_mmapsys_now_msnxns_pollfd_set_fdnxns_pollfd_set_eventsnx_dns_build_querysys_socket+7 |
| 400 | func nx_dns_host_would_poison(cells: *ProbeCell, n_servers: i64, n_hosts: i64, |
| 425 | func nx_dns_host_hairpin_risk(cells: *ProbeCell, n_servers: i64, n_hosts: i64, |