From 920824efa65e7e319476b45bcbea6c3cd254ca71 Mon Sep 17 00:00:00 2001 From: randomizedcoder Date: Mon, 30 Nov 2026 10:17:08 -0800 Subject: [PATCH] =?UTF-8?q?feat(goiparity):=20the=20offline=20rows=20?= =?UTF-8?q?=E2=80=94=20monitor=20file=20replay=20at=20the=20knob=20(V400)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The EG2-T01 row kind: seventeen monitor-file rows, `ip -d monitor file` twice around `goip -d monitor file` at GOIP_IP730, each side a fresh namespace. The Command table grows Monfile/Knob/Golden (the row format's thirteenth field); compareMonfileRow holds the rc rule (agree, then equal the declared one), the stderr rule (rc 0 means empty, never compared) and the goldens per side — the ip sides the .ip730 record, the goip side the one its Knob names, so the =0 rows (hibyte, hionly) hold to the committed .ip720 goldens, the measurement of record. The pcap corner's input is committed beside the blobs: evnhb-bucket.nl, nlcapgen monfile -pcap's notifications-only write, with goldens measured at all four sides byte-identical (the render is the corpus .out's lines modulo -d's detail words and the ifname — ifindex 3 misses in an empty namespace, if3, the no-sandbox-index rule's own class). The text refusal is the seventeenth. The driver grows capture_monfile_triple and the wholesale monfile/ blob copy; the save-blobs machinery ships the blobs, the refusal and the goldens; T03 skips a .nl with no .spec (the spec golden's carve-out, the pcap corner's regeneration golden TestMonfileCommittedPcap instead) and replays the committed notnetlink.txt. The gate: the section's live run — GOIP_PARITY_OVERALL_PASS + GOIP_PARITY_DRIVER_PASS, thirty-two PASS, HYGIENE_PASS, CONTROL_NOISY 1, UNGATED_CLEAN. Both full suites; go vet; gofmt; the nine checks and test-focused-goip (one lint finding fixed in code: Render's dispatch chain, a switch); O5/O9/O10 regenerated, no drift; the docs check names the corner's four files (the blob file index grows evnhb-bucket and notnetlink). V400. --- docs/netlink/goip-parity-events-status.md | 9 +- docs/netlink/goip-parity-events.md | 4 + .../testdata/monitor/evnhb-bucket.ip720.out | 4 + .../testdata/monitor/evnhb-bucket.ip730.out | 4 + .../goip/testdata/monitor/evnhb-bucket.nl | Bin 0 -> 232 bytes internal/goip/testdata/monitor/notnetlink.txt | 1 + internal/goipparity/commands.go | 210 ++++++++++++++++- internal/goipparity/commands_test.go | 62 ++++- internal/goipparity/compare.go | 33 ++- internal/goipparity/compare_test.go | 6 + internal/goipparity/monitor.go | 163 +++++++++++++ internal/goipparity/monitor_test.go | 223 ++++++++++++++++++ nix/checks/goip-monitorfile.nix | 25 +- nix/microvms/default.nix | 11 + nix/microvms/scripts/goip-parity.exp | 105 ++++++++- tools/nlcapgen/monfile_test.go | 27 +++ 16 files changed, 864 insertions(+), 23 deletions(-) create mode 100644 internal/goip/testdata/monitor/evnhb-bucket.ip720.out create mode 100644 internal/goip/testdata/monitor/evnhb-bucket.ip730.out create mode 100644 internal/goip/testdata/monitor/evnhb-bucket.nl create mode 100644 internal/goip/testdata/monitor/notnetlink.txt diff --git a/docs/netlink/goip-parity-events-status.md b/docs/netlink/goip-parity-events-status.md index eeedc5bb4..7361e48a8 100644 --- a/docs/netlink/goip-parity-events-status.md +++ b/docs/netlink/goip-parity-events-status.md @@ -23,9 +23,9 @@ - EP2-T03 is done (V392): `nix/checks/goip-monitorfile.nix`, registered — **15 specs regenerated, 60 replays byte for byte, 4 refusals** green at HEAD, and the red run produced in a worktree at the pre-fix tree (`d30a4886c` plus the blob files and the check): **30 RED lines, every blob at both goip knobs, the two `ip` sides green throughout**, the three gaps in the got/want sizes (the hionly partner `256 <>` vs the 7.2.0 golden's `0 <>`, the `congctl cubic p` rows, the `state UNKNOWN` word). The sandbox's link set re-measured — a plan correction: the sandbox carries its OWN namespace (`lo`, `tunl0`, `ip6tnl0`), not the host's indices; the check asserts the no-sandbox-index rule before the first replay. The refusal row is measured into the check (rc 1, empty stdout, each tool's own complaint, goip's prefixed). The docs check names all 60 blob files (the plan's blob file index; the upstream notes' evidence lines) — the no-orphans rule the upstream index carries, extended to the blob set; and O5/O9/O10 regenerate with no drift. **Tier EP is closed.** - EG1-T01 is done (V393–V396): the monitor row kind landed in three halves — the `Command` table's fields (V393), the driver's monitor flow with the helper's monitor-only tool split (V394), the comparator's monitor branch (V395) — and the section's gate ran green through the harness three times, every run `GOIP_PARITY_OVERALL_PASS` + `GOIP_PARITY_DRIVER_PASS`; the rows gate (V396) on their first two clean live runs, the ungated surface `addr show dynamic` alone again. - EG1-T02 is done (V398–V399): the thirteen rows — the EP1 twelve's remainder and the two refusals — landed with the `netnsid` setup step (the nsid rows print the netns name, the driver's NSW), and the section's gate ran twice: the first `GOIP_PARITY_OVERALL_PASS` with thirteen `PASS` and two `WARN`s, both the canary retry's Deleted stanzas on the goip side the attach race hit — the retry prints four stanza shapes (V399's measurement: the mcast stanza, the /32 autojoin stanza, the local route, the IGMP neighbor on 224.0.0.22), not the one V395 knew — and the fixed comparator's rerun clean throughout (fifteen `PASS`, `HYGIENE_PASS`, `CONTROL_NOISY 1` — the all row's unpinned d0 MAC, the corpus's own evseq-mixed pre, mirrored — `UNGATED_CLEAN`). The thirteen stay ungated: they pass clean, the gated set unchanged. O5/O9/O10 regenerated with no drift. +- EG2-T01 is done (V400): the seventeen offline rows — the fourteen crafted blobs at `=1` (the bond partner states, the actor-stays-u8 pair, the P14 reason u32s, the three metrics shapes), hibyte and hionly at `=0` (the only two whose versions print differently, goip held to the committed `.ip720` record — the measurement of record, the guest carrying no 7.2.0 `ip`; T03 gates that knob against the real binary), and the text refusal — plus the pcap corner: `evnhb-bucket.nl`, what `nlcapgen monfile -pcap` writes from the committed capture (notifications only, 3 of 16 messages), with goldens measured at all four sides byte-identical — a plan correction on the record: the render is the corpus `.out`'s lines modulo `-d`'s detail words and the ifname (`if3`, the no-sandbox-index rule's own class; the corpus `.out`'s `c0` its own VM's name). The gate: the section's live run — `GOIP_PARITY_OVERALL_PASS`, thirty-two `PASS` (the EG1 fifteen and the seventeen), `HYGIENE_PASS`, `CONTROL_NOISY 1` (the all row's d0 MAC, EG1-T02's own accepted noise), `UNGATED_CLEAN`; the seventeen stay ungated, one clean run of the two V393's rule wants. The docs check names the corner's four files (the blob file index grows `evnhb-bucket` and `notnetlink`); O5/O9/O10 regenerated with no drift. - The first tasks left, in order (Tier EG, the plans now in [goip-parity-events.md](goip-parity-events.md#tier-eg-goip-and-the-matrix)): - 1. [EG2-T01](goip-parity-events.md#eg2-t01-the-offline-rows) — the offline rows (the blobs through `monitor file`, both tools), the `=0` knob held to the committed goldens. - 2. [EG2-T02](goip-parity-events.md#eg2-t02-the-tier-closes) — the tier closes, answering the two follow-up decisions the plan leaves to it (the kernel spread for events; the oneshot's retirement). + 1. [EG2-T02](goip-parity-events.md#eg2-t02-the-tier-closes) — the tier closes, answering the two follow-up decisions the plan leaves to it (the kernel spread for events; the oneshot's retirement). ## Contents @@ -48,7 +48,7 @@ |---|---|---|---|---| | [Tier EC](goip-parity-events.md#tier-ec-captures) | the event rows, both versions, verdiff | EC4-T01 | done | V383 | | [Tier EP](goip-parity-events.md#tier-ep-replay-and-parsers) | O10 and the crafted monitor files | closed at V392 | done | V384–V392 | -| [Tier EG](goip-parity-events.md#tier-eg-goip-and-the-matrix) | the monitor section | EG2-T01 | in progress | V391–V399 | +| [Tier EG](goip-parity-events.md#tier-eg-goip-and-the-matrix) | the monitor section | EG2-T02 | in progress | V391–V400 | | [Tier UB](goip-parity-events.md#tier-ub-the-iproute2-findings-record) | the three owed notes, the index, the check, the procedure | UB0-T03 | done | V376, DOC035–DOC037 | ## Task checklist @@ -70,7 +70,7 @@ | [x] | [EP2-T02](goip-parity-events.md#ep2-t02-the-blobs) | the blobs | done | V390 | | [ ] | [EP2-T03](goip-parity-events.md#ep2-t03-test-goip-monitorfile) | `test-goip-monitorfile` | done | V392 | | [x] | [EG1](goip-parity-events.md#tier-eg-goip-and-the-matrix) | the monitor section | done | V393–V399 | -| [ ] | [EG2](goip-parity-events.md#tier-eg-goip-and-the-matrix) | the offline section (outline until EC4) | not started | — | +| [ ] | [EG2](goip-parity-events.md#tier-eg-goip-and-the-matrix) | the offline section | EG2-T01 done | V400 | | [x] | [UB0-T01](goip-parity-events.md#ub0-t01-the-three-owed-notes) | the three owed notes | done | DOC036 | | [x] | [UB0-T02](goip-parity-events.md#ub0-t02-the-index-and-the-check) | the index, `test-goip-docs` | done | V376 | | [x] | [UB0-T03](goip-parity-events.md#ub0-t03-the-findings-procedure) | the findings procedure | done | DOC037 | @@ -106,6 +106,7 @@ | V397 | 2026-11-28 | PR 358 review fixes: the monitor gate's exit status and multicast groups | `go test -tags goip_write ./internal/goipparity/` (TestMonitorGateReview, 13 rows; the 8 fix rows fail on V396's comparator); the docs check's unit tests and the docs run; both golangci configs | Three review findings. (1) A monitor row declares its helper rc (`MonitorExpectRC`, 0 by default, 1 for a refusal row): the three sides must agree and equal it, so a killed (137), usage (2) or launch (126/127) failure no longer passes as three agreeing empty outputs (`ErrMonitorExit`). (2) The monitor comparison adds `FacetMcastGroups`, one element per `inet`/`inet6 mcast` stanza with its Deleted, ifindex and device; Presence class, under the same D_control subtraction, so a wrong IPv4 or IPv6 group fails a gated row. (3) The leftover `>>>>>>>` line in docs/netlink/README.md is gone, and the docs check refuses `<<<<<<< `/`>>>>>>> ` lines (a bare `=======` stays legal: it is a setext underline) | this commit | | V398 | 2026-11-28 | EG1-T02: the thirteen monitor rows and the netnsid step | both full suites (`go test -count=1 ./...` and `-tags goip_write ./...`); `go vet -tags goip_write ./...`; the checks lint-baseline, gofmt, nix-fmt, go-vet, test-goip-docs, test-goip-monitorfile, test-focused-goip, vm-lib-exp, cli-help-smoke-goip-parity; the section's first live run - `GOIP_PARITY_OVERALL_PASS` + `GOIP_PARITY_DRIVER_PASS`, thirteen `PASS`, two `WARN`, `HYGIENE_PASS`, `CONTROL_NOISY 11` | The `Command` table grows the thirteen rows - the EP1 twelve's remainder (`dad`, `route autoconf`, `neigh v4`, `nexthop bucket`, `netconf del`, `rule v4`, `stats l3`, `nsid live`, `prefix route ra`, `acaddress anycast`, `all mixed`) and the two refusals (`maddress esrch`, `nsid eexist`, both `MonitorExpectRC: 1`) - each the ev row's own Setup, Trigger and until-EREs, `Floor 1`, `Canary c0`. The nsid rows print the netns name (goip implements the name walk), so the driver grows the `netnsid` setup step - evSelfID's own shape - and its quoting comments now name the nsid rows' shell-escaped `$`/`"`. TestCommandTable grows the rc rule (every monitor row declares 0 or 1; the refusal rows 1), the thirteen in the ungated set, and the sysctl corner (RA rows 2, netconf-del/anycast/all-mixed 1); `writeCleanMonitorRow` writes the declared rc. The two `WARN`s - `monitor_address_dad`, `monitor_all_mixed` - are one noise: the canary retry's Deleted stanzas on the goip side the attach race hit, the same blocks the neigh and prefix rows' D_control carried on their ip_a sides (4 and 6, `CONTROL_NOISY 11` total). The findings are the comparator's own gap - V395's collapse knew one of the retry's stanza shapes - closed in V399 | `d069d3a11` | | V399 | 2026-11-28 | the canary retry's four stanza shapes; the section's gate clean | the monitor tests (TestCollapseCanary, TestCompareMonitorWithControl, 15 rows); both full suites; the checks lint-baseline, test-goip-docs, test-goip-monitorfile, test-focused-goip, vm-lib-exp, go-vet, gofmt, nix-fmt, cli-help-smoke-goip-parity; O5/O9/O10 regenerated (`-update-ws-*`), no drift; the section's second live run - `GOIP_PARITY_OVERALL_PASS` + `GOIP_PARITY_DRIVER_PASS`, fifteen `PASS`, `HYGIENE_PASS`, `CONTROL_NOISY 1`, `UNGATED_CLEAN` | The measured fix: the retry's `ip addr del` prints four stanza shapes, not the one V395's collapse knew - the mcast stanza, the `/32` autojoin stanza its RTM_NEWADDR prints, the local route the address brings, and the NOARP neighbor on `224.0.0.22` (the IGMPv3 report group the autojoin solicits, RFC 3376) on the canary device. `collapseCanary` drops every Deleted canary block and keeps the last run of consecutive undeleted canary blocks - the join the helper's loop broke on - which degenerates to V395's keep-last for the link rows' mcast-only shape; `isCanaryStanza` takes the canary device (the IGMP anchor, plumbed through `CompareMonitorWithControl` - the row's `Canary` field) and `isDeletedStanza` reads the `Deleted` prefix under the `all` banner. The join's own rendered text stays compared; the retry's twins go. The V398 capture's four shapes are the fixtures (each monitor kind's retry collapses to its join - the dad, prefix, neigh and all rows) and the two live `WARN`s are regression cases. The fixed comparator, run over the first live run's captured artifacts, passes all fifteen rows with no findings - the neigh and prefix rows' D_control dropped to 0 with it - and the second live run ran clean throughout (the `CONTROL_NOISY 1` is the all row's unpinned d0 MAC, the corpus's own evseq-mixed pre, mirrored; D_control subtracts it). The thirteen rows stay ungated: they pass clean, the gated set unchanged | `23399edcf` | +| V400 | 2026-11-30 | EG2-T01: the offline rows, the section's gate green | both full suites (`go test -count=1 ./...` and `-tags goip_write ./...`); `go vet -tags goip_write ./...`; the checks lint-baseline, gofmt, nix-fmt, go-vet, test-goip-docs, test-goip-monitorfile, test-focused-goip, vm-lib-exp, cli-help-smoke-goip-parity; O5/O9/O10 regenerated, no drift; the section's live run - `GOIP_PARITY_OVERALL_PASS` + `GOIP_PARITY_DRIVER_PASS`, thirty-two `PASS`, `HYGIENE_PASS`, `CONTROL_NOISY 1`, `UNGATED_CLEAN` | The monitor-file row kind: the `Command` table's `Monfile`/`Knob`/`Golden` (the row format's thirteenth field), the comparator's `compareMonfileRow` (the rc rule - agree, then equal the declared one; the stderr rule - rc 0 ↔ empty, rc ≠ 0 ↔ non-empty, never compared; the golden comparison naming the side, the golden and the first differing line; a `-` golden three-side equality, the monitor rows' own shape), `expectedFiles`' goldens per side (the ip sides always `.ip730`, the goip side the record its `Knob` names - the `.ip720` goldens the measurement of record for the `=0` rows, the guest carrying no 7.2.0 `ip`, T03's check what gates that knob against the real binary), and the driver's `capture_monfile_triple` (a fresh namespace per side, the Setup steps, `xtcp2-nlcap mon` running `ip -d monitor file` twice around `goip -d monitor file` at the knob - the first run's `MISSED FLOOR`, the input read against the console's CWD rather than the capture dir, the driver fix on the record). Seventeen rows: the bond partner states (hibyte and hionly at `=0`, the versions' u16 `319 <…,>` vs u8 `63` prints the rows' whole point; the rest `=1`), the actor-stays-u8 pair, the P14 reason u32s, the three metrics shapes (the plan's one padding row measured into all three committed shapes), the text refusal (`MonitorExpectRC: 1`) and the pcap corner - `evnhb-bucket.nl`, `nlcapgen monfile -pcap`'s 232-byte notifications-only write (3 of the capture's 16 messages; `TestMonfileCommittedPcap` the regeneration golden, T03's spec-golden check skipping a `.nl` with no `.spec`), its goldens measured at all four sides byte-identical. A plan correction on the record: the corner's render is the corpus `.out`'s lines modulo `-d`'s detail words and the ifname - ifindex 3 misses in an empty namespace, `if3` (the no-sandbox-index rule's own class), the corpus `.out`'s `c0` its own VM's name. The seventeen stay ungated, one clean live run of the two V393's rule wants; the gated set unchanged | this commit | ## Decision log diff --git a/docs/netlink/goip-parity-events.md b/docs/netlink/goip-parity-events.md index 2908fe1dd..5c3d1958a 100644 --- a/docs/netlink/goip-parity-events.md +++ b/docs/netlink/goip-parity-events.md @@ -295,9 +295,11 @@ The committed set, the blob file index the docs check names (EP2-T03's gate: eve - `bond-partner-slow`: `bond-partner-slow.spec` `bond-partner-slow.nl` `bond-partner-slow.ip720.out` `bond-partner-slow.ip730.out` - `bond-partner-trunc1`: `bond-partner-trunc1.spec` `bond-partner-trunc1.nl` `bond-partner-trunc1.ip720.out` `bond-partner-trunc1.ip730.out` - `bond-partner-zero`: `bond-partner-zero.spec` `bond-partner-zero.nl` `bond-partner-zero.ip720.out` `bond-partner-zero.ip730.out` +- `evnhb-bucket`: `evnhb-bucket.nl` `evnhb-bucket.ip720.out` `evnhb-bucket.ip730.out` (no `.spec` — the pcap corner's input, the real capture's bytes `nlcapgen monfile` writes, not a crafted spec's) - `linkpd-0009`: `linkpd-0009.spec` `linkpd-0009.nl` `linkpd-0009.ip720.out` `linkpd-0009.ip730.out` - `linkpd-0100`: `linkpd-0100.spec` `linkpd-0100.nl` `linkpd-0100.ip720.out` `linkpd-0100.ip730.out` - `linkpd-80000001`: `linkpd-80000001.spec` `linkpd-80000001.nl` `linkpd-80000001.ip720.out` `linkpd-80000001.ip730.out` +- `notnetlink.txt`: the text refusal's input, a file that is not netlink (no `.spec`, no goldens — the refusal's stdout is empty on every side, the complaint each tool's own) - `route-metrics-nested`: `route-metrics-nested.spec` `route-metrics-nested.nl` `route-metrics-nested.ip720.out` `route-metrics-nested.ip730.out` - `route-metrics-overlong`: `route-metrics-overlong.spec` `route-metrics-overlong.nl` `route-metrics-overlong.ip720.out` `route-metrics-overlong.ip730.out` - `route-metrics-v038pad`: `route-metrics-v038pad.spec` `route-metrics-v038pad.nl` `route-metrics-v038pad.ip720.out` `route-metrics-v038pad.ip730.out` @@ -366,6 +368,8 @@ The monitor-file row kind: an empty namespace per side (ifindex 7 misses — the Gates: every row green or its finding recorded; the committed `.nl` regenerated by the spec golden; O5/O9/O10 regenerated; the full suites; the checks; the docs check naming the pcap corner's committed files. +Done (V400). Seventeen rows: the bond partner states — fast, slow, zero, all, absent, trunc1 and the actor-stays-u8 pair at `=1`, hibyte and hionly at `=0` (the only two whose committed goldens differ across the versions, the u16 partner `319` with the trailing comma vs the u8 `63`, the versions' difference the row's whole point) — the P14 reason u32s (`0x9`, `0x100`, `0x80000001`), the metrics shapes (the plan's one padding row measured into all three committed shapes: nested, overlong, v038pad), the pcap corner and the text refusal (`MonitorExpectRC: 1`, `Golden: "-"` — three-side stdout equality, the complaint each tool's own, never compared). The `Command` table carries the kind's three fields (`Monfile`, `Knob`, `Golden`; `String()`'s thirteenth-field monfile branch, `GoldenName`), the comparator's `compareMonfileRow` (the rc rule — agree, then equal the declared one; the stderr rule — rc 0 ↔ empty, rc ≠ 0 ↔ non-empty, never compared; the golden comparison naming the side, the golden and the first differing line) and `expectedFiles`' nine side files plus the goldens the sides are held to (the ip sides always `.ip730`, the goip side the record its `Knob` names — the `.ip720` goldens the measurement of record for the `=0` rows, the guest carrying no 7.2.0 `ip`; T03's check gates that knob against the real 7.2.0 binary). The pcap corner, measured: `evnhb-bucket.nl` is what `nlcapgen monfile -pcap` writes from the committed capture (notifications only — 3 of the pcap's 16 messages, 232 bytes, `TestMonfileCommittedPcap` the regeneration golden; T03 skips a `.nl` with no `.spec`, the spec golden's own carve-out), and the render is measured at all four sides — the host's 7.2.0 `ip`, the pinned 7.3.0 `ip`, goip at both knobs — byte-identical, but NOT the corpus `.out`'s bytes: `-d` adds `scope global proto unspec` to the RTM_NEWNEXTHOP line (V390's measurement), and ifindex 3 misses in an empty namespace, so the record holds `if3` — the no-sandbox-index rule's own class — the corpus `.out`'s `c0` its own VM's name. A plan correction, recorded: "the same lines as the `.out`" is true modulo the `-d` words and the ifname. The driver: `capture_monfile_triple` (a fresh namespace per side, the row's Setup steps, `xtcp2-nlcap mon` running `ip -d monitor file` twice around `goip -d monitor file` at the knob), the blobs, the text refusal and the goldens copied wholesale to the capture dir before the first row — the first run's `MISSED FLOOR` (the replay's file read against the console's CWD rather than the capture dir) is the driver fix on the record. The gate: `nix run .#microvm-x86_64-goip-parity -- --section monitor` — `GOIP_PARITY_OVERALL_PASS` + `GOIP_PARITY_DRIVER_PASS`, thirty-two `PASS` (the EG1 fifteen and the seventeen), `HYGIENE_PASS`, `CONTROL_NOISY 1` (the all row's unpinned d0 MAC, EG1-T02's own accepted noise), `UNGATED_CLEAN`. The seventeen stay ungated — one clean live run, V393's rule wants two. O5/O9/O10 regenerated, no drift; both full suites; the nine checks and `test-focused-goip` (the one lint finding fixed in code: Render's dispatch chain, a switch); the docs check names the corner's four files (the blob file index grows `evnhb-bucket` and `notnetlink`). + #### EG2-T02 the tier closes The gates: O5/O9/O10 regenerated, `differs` and `sends` at 0, no row moved away from `same`; the full suites; the checks; the docs. The two decisions the plan's follow-ups leave to EG's close, answered in the task's own ledger row: the kernel spread for events (whether any decoder branch depends on a kernel-conditional attribute first — if none does, the spread is deferred with the reason recorded) and the oneshot's retirement (whether `nlmon-capture` stays as the one baked-in, zero-driver capture; if it goes, `flake.nix`'s header, `nix/README.md`'s fixture table and `docs/netlink/collection.md` name the retirement in the same task). diff --git a/internal/goip/testdata/monitor/evnhb-bucket.ip720.out b/internal/goip/testdata/monitor/evnhb-bucket.ip720.out new file mode 100644 index 000000000..43d681eb4 --- /dev/null +++ b/internal/goip/testdata/monitor/evnhb-bucket.ip720.out @@ -0,0 +1,4 @@ +3: if3 inet mcast 224.0.0.250 scope global + valid_lft forever preferred_lft forever +id 10 group 1,3/2 type resilient buckets 4 idle_timer 60 unbalanced_timer 1 unbalanced_time 0 scope global proto unspec +id 10 index 0 idle_time 0 nhid 1 diff --git a/internal/goip/testdata/monitor/evnhb-bucket.ip730.out b/internal/goip/testdata/monitor/evnhb-bucket.ip730.out new file mode 100644 index 000000000..43d681eb4 --- /dev/null +++ b/internal/goip/testdata/monitor/evnhb-bucket.ip730.out @@ -0,0 +1,4 @@ +3: if3 inet mcast 224.0.0.250 scope global + valid_lft forever preferred_lft forever +id 10 group 1,3/2 type resilient buckets 4 idle_timer 60 unbalanced_timer 1 unbalanced_time 0 scope global proto unspec +id 10 index 0 idle_time 0 nhid 1 diff --git a/internal/goip/testdata/monitor/evnhb-bucket.nl b/internal/goip/testdata/monitor/evnhb-bucket.nl new file mode 100644 index 0000000000000000000000000000000000000000..7ef71ffbd284d02d1c3f71242576656ab8d965c8 GIT binary patch literal 232 zcmX|)u@1s85JO*E8X^=rAtAPoT@ecd10TbH1Oo#fkWXdeBUr!=Z7n%>_T_vh;3!V0 z`%EJdS@MEUBvDCk2z*EEhYIs9|4Q4wyY_b2NsNfvSg8+6`tR1I*78haAmt!;p+3re kY+V~J(y6%qWv_F|XFX3!jP;D^R?oWRdEgx1P4hMQ0k^;sp8x;= literal 0 HcmV?d00001 diff --git a/internal/goip/testdata/monitor/notnetlink.txt b/internal/goip/testdata/monitor/notnetlink.txt new file mode 100644 index 000000000..d1e7866d6 --- /dev/null +++ b/internal/goip/testdata/monitor/notnetlink.txt @@ -0,0 +1 @@ +this is not a netlink file at all, just text diff --git a/internal/goipparity/commands.go b/internal/goipparity/commands.go index 4aa5f394d..70db79710 100644 --- a/internal/goipparity/commands.go +++ b/internal/goipparity/commands.go @@ -33,6 +33,7 @@ import ( "fmt" "slices" "sort" + "strconv" "strings" ) @@ -170,9 +171,33 @@ type Command struct { // means no canary: not a row the EG1 table holds. Canary string - // MonitorExpectRC is a monitor row's declared helper exit status: 0, the - // zero value, for a row whose trigger must succeed, and 1 for a refusal - // row whose trigger the kernel refuses. The three sides' rc must agree + // Monfile marks the row kind EG2-T01 adds: a monitor-file replay + // row — `ip -d monitor file ` against `goip -d monitor file + // ` at Knob, in an empty namespace per side (ifindex 7 misses + // — the if7 fallback, the no-sandbox-index rule), no canary and no + // trigger: the blob's bytes are the row's whole input. The plan's row + // kind (docs/netlink/goip-parity-events.md, "EG2-T01 the offline + // rows"). + Monfile bool + + // Knob is a monfile row's GOIP_IP730 value: 1, the parity release + // the guest's `ip` prints, or 0, the 7.2.0 behavior the .ip720.out + // goldens hold. + Knob int + + // Golden is a monfile row's committed golden stem: `-`, the + // three-side equality rows (the crafted inputs gated live), or the + // stem whose `.ip730.out` and `.ip720.out` files the driver ships + // beside the captures and the comparator holds each side to — the ip + // sides the .ip730 record always, the goip side the record its Knob + // names. + Golden string + + // MonitorExpectRC is a row's declared tool exit status: 0, the + // zero value, for a row whose run must succeed, and 1 for a refusal + // row — a monitor row's trigger the kernel refuses (the helper's own + // exit, V391's measured record), a monfile row's text file the tools' + // decoder refuses (the T03 record). The three sides' rc must agree // AND equal it, so a helper that was killed or never launched (rc 2, // 126, 127, 137) cannot pass as three agreeing empty outputs. MonitorExpectRC int @@ -561,6 +586,169 @@ var commands = withArgs([]Command{ // The refusal row's own rc: the helper's, not 0. MonitorExpectRC: 1, }, + { + // The EG2 rows, the offline section: EP2's crafted blobs joined to + // the matrix, each replayed through `ip -d monitor file` and + // `goip -d monitor file` in an empty namespace per side — ifindex 7 + // misses, so every crafted blob's dev prints if7, the + // no-sandbox-index rule the T03 sandbox relies on. The comparator + // holds the ip sides to the .ip730 record and the goip side to the + // record its Knob names; the two =0 rows are the blobs the versions + // print differently, so goip's 7.2.0 compat print is judged against + // the committed .ip720 goldens — the measurement of record, the + // guest carrying no 7.2.0 ip (T03's check is what gates that knob + // against the real 7.2.0 binary). + Name: "monitor file bond-partner-fast.nl", + Slug: "monitor_file_bond_partner_fast", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-fast.nl"}, + Golden: "bond-partner-fast", + }, + { + // 0x003d, every state bit but short_timeout. + Name: "monitor file bond-partner-slow.nl", + Slug: "monitor_file_bond_partner_slow", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-slow.nl"}, + Golden: "bond-partner-slow", + }, + { + // 0x0000, no LACP state bits at all. + Name: "monitor file bond-partner-zero.nl", + Slug: "monitor_file_bond_partner_zero", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-zero.nl"}, + Golden: "bond-partner-zero", + }, + { + // 0x00ff, all eight LACP names, defaulted and expired included. + Name: "monitor file bond-partner-all.nl", + Slug: "monitor_file_bond_partner_all", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-all.nl"}, + Golden: "bond-partner-all", + }, + { + // 0x013f on the wire (3f 01): the u8 read keeps 63, the u16 is 319 + // with a trailing comma — one of the two prints the versions hold + // differently, so the row runs goip at the =0 knob and holds it to + // the .ip720 record while the ip sides print the .ip730 one. + Name: "monitor file bond-partner-hibyte.nl", + Slug: "monitor_file_bond_partner_hibyte", + Floor: 1, Implemented: true, Monfile: true, + Args: []string{"monitor", "file", "bond-partner-hibyte.nl"}, + Knob: 0, Golden: "bond-partner-hibyte", + }, + { + // 0x0100 on the wire (00 01): no LACP name bit, 0 at u8 and 256 at + // u16 — the versions' other differing print, the =0 row's twin. + Name: "monitor file bond-partner-hionly.nl", + Slug: "monitor_file_bond_partner_hionly", + Floor: 1, Implemented: true, Monfile: true, + Args: []string{"monitor", "file", "bond-partner-hionly.nl"}, + Knob: 0, Golden: "bond-partner-hionly", + }, + { + // no partner attribute at all, the print's whole line absent. + Name: "monitor file bond-partner-absent.nl", + Slug: "monitor_file_bond_partner_absent", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-absent.nl"}, + Golden: "bond-partner-absent", + }, + { + // a one-byte partner attr 0x3f: 63 at both versions, the u16 takes + // the zero pad. + Name: "monitor file bond-partner-trunc1.nl", + Slug: "monitor_file_bond_partner_trunc1", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-partner-trunc1.nl"}, + Golden: "bond-partner-trunc1", + }, + { + // the actor attr is u8 at both versions; crafted pad garbage that + // an over-eager u16 read would print. + Name: "monitor file bond-actor-u8.nl", + Slug: "monitor_file_bond_actor_u8", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "bond-actor-u8.nl"}, + Golden: "bond-actor-u8", + }, + { + // reason VALUE 0x9: the u8 read prints <0,3> (P14, the u32 the + // kernel sends read as a u8). + Name: "monitor file linkpd-0009.nl", Slug: "monitor_file_linkpd_0009", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "linkpd-0009.nl"}, + Golden: "linkpd-0009", + }, + { + // reason VALUE 0x100: the u8 read prints no reasons. + Name: "monitor file linkpd-0100.nl", Slug: "monitor_file_linkpd_0100", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "linkpd-0100.nl"}, + Golden: "linkpd-0100", + }, + { + // reason VALUE 0x80000001: the u8 read prints <0> alone. + Name: "monitor file linkpd-80000001.nl", + Slug: "monitor_file_linkpd_80000001", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "linkpd-80000001.nl"}, + Golden: "linkpd-80000001", + }, + { + // the RTA_METRICS attr with NLA_F_NESTED set, which parse_rtattr + // does not mask so ip drops it whole. + Name: "monitor file route-metrics-nested.nl", + Slug: "monitor_file_route_metrics_nested", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "route-metrics-nested.nl"}, + Golden: "route-metrics-nested", + }, + { + // CC_ALG rta_len 12, cubic\0p\0 as eight data bytes past the first + // NUL — the C-string read prints the pad. + Name: "monitor file route-metrics-overlong.nl", + Slug: "monitor_file_route_metrics_overlong", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "route-metrics-overlong.nl"}, + Golden: "route-metrics-overlong", + }, + { + // CC_ALG rta_len 10, cubic\0, with crafted garbage p\0 in the + // alignment pad — the rta_addattr fault (UB0-T01). + Name: "monitor file route-metrics-v038pad.nl", + Slug: "monitor_file_route_metrics_v038pad", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "route-metrics-v038pad.nl"}, + Golden: "route-metrics-v038pad", + }, + { + // The pcap corner: a real capture's bytes, the fixture rule's own + // class — the evnhb-bucket migration (RTM_NEWNEXTHOPBUCKET with + // NLM_F_REPLACE), the .nl nlcapgen monfile writes from the committed + // pcap, notifications only. The render is the corpus .out's own + // lines with -d's detail words; the ifname is the no-sandbox-index + // rule's own class — ifindex 3 misses in an empty namespace, so the + // record holds if3, the corpus .out's c0 its own VM's name. + Name: "monitor file evnhb-bucket.nl", + Slug: "monitor_file_evnhb_bucket", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "evnhb-bucket.nl"}, + Golden: "evnhb-bucket", + }, + { + // The refusal: a file that is not netlink. No stdout and rc 1 on + // every tool, the complaint each tool's own (goip prefixes its + // name, so stderr is never compared) — the T03 record, gated live. + Name: "monitor file notnetlink.txt", Slug: "monitor_file_notnetlink", + Floor: 1, Implemented: true, Monfile: true, Knob: 1, + Args: []string{"monitor", "file", "notnetlink.txt"}, + Golden: "-", + // The refusal row's own rc: the replay's, not 0. + MonitorExpectRC: 1, + }, { Name: "link show", Slug: "link_show", // Two datagrams: the request and the multipart reply. `link show` @@ -9059,6 +9247,15 @@ func (c Command) ErrName(side string) string { return c.Slug + "." + side + ".err" } +// GoldenName is the basename of a monfile row's committed record in the +// capture dir: what `ip -d monitor file` printed at the release the suffix +// names, the driver shipping the store's copy beside the captures. The ip +// sides are held to the .ip730 record and the goip side to the one its Knob +// names. +func (c Command) GoldenName(release string) string { + return c.Golden + "." + release + ".out" +} + // ipStandInCst is String's impl field for an IPStandIn row. const ipStandInCst = "ip" @@ -9116,6 +9313,13 @@ func (c Command) String() string { fields = append(fields, "monitor", c.Canary, c.Trigger) fields = append(fields, c.Until...) } + // A monfile row grows the row to its fixed thirteen: the marker, the + // knob and the golden stem — the driver's lassign reads all three, and + // the golden field's `-` names the three-side equality rows (no + // golden), mirroring the setup field's `-`. + if c.Monfile { + fields = append(fields, "monfile", strconv.Itoa(c.Knob), c.Golden) + } return strings.Join(fields, "\t") } diff --git a/internal/goipparity/commands_test.go b/internal/goipparity/commands_test.go index ab50b20e5..85960d0b9 100644 --- a/internal/goipparity/commands_test.go +++ b/internal/goipparity/commands_test.go @@ -161,6 +161,41 @@ func TestCommandTable(t *testing.T) { } }, }, + { + description: "positive: a monfile row carries a golden or the three-side marker, no canary and no trigger, and the fields the driver reads", + check: func(t *testing.T) { + // The EG2 rows' own check on the fields past the ten fixed + // ones: the marker, the knob and the golden stem. The golden + // is `-` (the three-side equality rows) or a committed stem + // — never empty, which would name no record and pass nothing + // as a golden. The knob is 0 or 1 (GOIP_IP730's own values), + // a row is never both kinds, and a monfile row carries none of + // the monitor row's own machinery (canary, trigger, until): + // the blob's bytes are the row's whole input. + for _, c := range Commands() { + if c.Monitor && c.Monfile { + t.Errorf("%q is both a monitor and a monfile row", c.Name) + } + if !c.Monfile { + continue + } + if c.Golden == "" { + t.Errorf("%q has no golden stem and no `-`, so it names no record", c.Name) + } + if c.Knob != 0 && c.Knob != 1 { + t.Errorf("%q carries Knob %d, want 0 or 1 (GOIP_IP730's own values)", + c.Name, c.Knob) + } + if c.Canary != "" || c.Trigger != "" || len(c.Until) != 0 { + t.Errorf("%q carries the monitor row's machinery, which an offline row cannot use", c.Name) + } + if c.MonitorExpectRC != 0 && c.MonitorExpectRC != 1 { + t.Errorf("%q declares MonitorExpectRC %d, want 0 (the replay succeeds) or 1 (the refusal)", + c.Name, c.MonitorExpectRC) + } + } + }, + }, { description: "positive: Lookup finds an implemented command and returns its row", check: func(t *testing.T) { @@ -655,11 +690,16 @@ func TestCommandString(t *testing.T) { // (10+1 is the marker (`monitor`), 10+2 the canary device, 10+3 the // trigger, and each remaining field one until-ERE — the driver's // lassign reads the tail as the EREs, so the count is the row's own - // and cannot be one fixed number (V391, EG1-T01)). + // and cannot be one fixed number (V391, EG1-T01)). A monfile row + // carries the fixed thirteen: 10+1 the marker (`monfile`), 10+2 the + // knob, 10+3 the golden stem (EG2-T01). want := 10 if c.Monitor { want = 13 + len(c.Until) } + if c.Monfile { + want = 13 + } if n := len(strings.Split(c.String(), "\t")); n != want { t.Errorf("%q renders %d fields, want %d", c.Name, n, want) } @@ -1249,6 +1289,26 @@ func TestUngatedSurfaceIsNotVacuous(t *testing.T) { "monitor all mixed", "monitor maddress esrch", "monitor nsid maddress eexist", + // The seventeen EG2-T01 added (the offline rows) hold this list until + // theirs, the text refusal last: the refusal is the section's own + // negative, and the crafted rows land in the table's order. + "monitor file bond-partner-fast.nl", + "monitor file bond-partner-slow.nl", + "monitor file bond-partner-zero.nl", + "monitor file bond-partner-all.nl", + "monitor file bond-partner-hibyte.nl", + "monitor file bond-partner-hionly.nl", + "monitor file bond-partner-absent.nl", + "monitor file bond-partner-trunc1.nl", + "monitor file bond-actor-u8.nl", + "monitor file linkpd-0009.nl", + "monitor file linkpd-0100.nl", + "monitor file linkpd-80000001.nl", + "monitor file route-metrics-nested.nl", + "monitor file route-metrics-overlong.nl", + "monitor file route-metrics-v038pad.nl", + "monitor file evnhb-bucket.nl", + "monitor file notnetlink.txt", } tests := []struct { diff --git a/internal/goipparity/compare.go b/internal/goipparity/compare.go index d6004daf7..d41e07acb 100644 --- a/internal/goipparity/compare.go +++ b/internal/goipparity/compare.go @@ -142,7 +142,7 @@ func compareOne(dir string, c Command, al *nlparity.Allowlist) Result { // row's artifact is its stdout, not a pcap — it records none — so that // is the file whose presence this checks for it. art := c.CaptureName(SideGoip) - if c.Monitor { + if c.Monitor || c.Monfile { art = c.StdoutName(SideGoip) } if p := filepath.Join(dir, art); fileExists(p) { @@ -175,6 +175,14 @@ func compareOne(dir string, c Command, al *nlparity.Allowlist) Result { return compareMonitorRow(dir, c, al) } + // A monfile row is the offline twin: the blob's bytes are the row's + // whole input, so the comparison is the replay's own three sides and + // the committed records — monitor.go's again, and the netlink half is + // zero by the same construction. + if c.Monfile { + return compareMonfileRow(dir, c, al) + } + proto, ok := nlparity.ProtocolByName(c.Protocol()) if !ok { r.Status = StatusFail @@ -265,6 +273,13 @@ func (c Command) expectedFiles() []string { out = append(out, c.StdoutName(side), c.RCName(side), c.ErrName(side)) continue } + // A monfile row's are the same three — the replay's stdout, its rc + // and its stderr — and its goldens are named once, below: they are + // per-row, not per-side. + if c.Monfile { + out = append(out, c.StdoutName(side), c.RCName(side), c.ErrName(side)) + continue + } out = append(out, c.CaptureName(side), c.StdoutName(side)) if c.Write { out = append(out, c.RCName(side)) @@ -273,6 +288,14 @@ func (c Command) expectedFiles() []string { if c.Write { out = append(out, c.WriteName()) } + // The records a golden row is held to: the .ip730 one on every side but + // the goip side of a =0 row, whose compat print the .ip720 record holds. + if c.Monfile && c.Golden != "-" { + out = append(out, c.GoldenName(ip730Cst)) + if c.Knob == 0 { + out = append(out, c.GoldenName(ip720Cst)) + } + } return out } @@ -389,10 +412,14 @@ func Render(w io.Writer, results []Result) bool { // sides ran 2 transactions" is the statement that makes a clean // report believable. A monitor row has no netlink half, so it names // the floor it does have — the helper's rc, and the stdout control. - if c.Monitor { + switch { + case c.Monitor: fmt.Fprintf(w, " monitor: rc=%s control: stdout=%d\n", r.MonitorRC, r.Stdout.ControlSize) - } else { + case c.Monfile: + fmt.Fprintf(w, " monfile: rc=%s knob=%d golden=%s\n", + r.MonitorRC, c.Knob, c.Golden) + default: fmt.Fprintf(w, " txns: ip=%d goip=%d pids: ip=%v goip=%v control: nl=%d stdout=%d\n", r.Netlink.RefTxns, r.Netlink.SubTxns, r.Netlink.RefPids, r.Netlink.SubPids, diff --git a/internal/goipparity/compare_test.go b/internal/goipparity/compare_test.go index 79491c2d7..449c5ef74 100644 --- a/internal/goipparity/compare_test.go +++ b/internal/goipparity/compare_test.go @@ -827,6 +827,10 @@ func TestRender(t *testing.T) { writeCleanMonitorRow(t, dir, c) continue } + if c.Monfile { + writeCleanMonfileRow(t, dir, c) + continue + } if c.Proto != "" { writeGenlReadRow(t, dir, c) continue @@ -888,6 +892,8 @@ func TestRender(t *testing.T) { switch { case c.Write: writeCleanWriteRow(t, dir, c) + case c.Monfile: + writeCleanMonfileRow(t, dir, c) case c.Monitor: writeCleanMonitorRow(t, dir, c) case c.IPStandIn: diff --git a/internal/goipparity/monitor.go b/internal/goipparity/monitor.go index 041060420..c9a273d42 100644 --- a/internal/goipparity/monitor.go +++ b/internal/goipparity/monitor.go @@ -96,6 +96,21 @@ var ErrMonitorSide = fmt.Errorf("goiparity: monitor row exit status") // not the row's declared MonitorExpectRC. var ErrMonitorExit = fmt.Errorf("goipparity: monitor row unexpected exit status") +// ErrMonfileSide is a monfile row whose three sides' replay rc disagree. +var ErrMonfileSide = fmt.Errorf("goipparity: monfile row exit status") + +// ErrMonfileExit is a monfile row whose three sides agree on an rc that is +// not the row's declared one — the replay's own, the tools' decoder's. +var ErrMonfileExit = fmt.Errorf("goipparity: monfile row unexpected exit status") + +// ErrMonfileStderr is a monfile row whose stderr broke the rc rule: a side +// that complained on a clean replay, or a refusal side that did not. +var ErrMonfileStderr = fmt.Errorf("goipparity: monfile row stderr") + +// ErrMonfileGolden is a monfile row whose side did not print the committed +// record it is held to — the measurement of record, T03's hermetic twin. +var ErrMonfileGolden = fmt.Errorf("goipparity: monfile row golden") + // FacetMcastGroups is a monitor row's multicast group events: one element // per `inet mcast` or `inet6 mcast` stanza (print_addrinfo), as // `[Deleted ]IFINDEX: DEV FAMILY GROUP`. The dump facets do not see the @@ -343,3 +358,151 @@ func compareMonitorRow(dir string, c Command, al *nlparity.Allowlist) Result { } return r } + +// The golden release suffixes, the committed records' own naming. +const ( + ip730Cst = "ip730" + ip720Cst = "ip720" +) + +// compareMonfileRow is one monfile row's whole comparison: the replay's own +// rc, the stderr rule, then the stdout — held to the committed records when +// Golden names a stem (the ip sides the .ip730 one, the goip side the one +// its Knob names), compared three-side when it does not. The netlink half is +// zero by construction, as a monitor row's is, and there is no canary to +// collapse and no control to subtract: the blob's bytes are the row's whole +// input, so the three renders cannot legitimately differ. +func compareMonfileRow(dir string, c Command, al *nlparity.Allowlist) Result { + r := Result{Command: c, Status: StatusPass, MonitorRC: ""} + + rc := map[string]string{} + for _, side := range Sides() { + b, err := os.ReadFile(filepath.Join(dir, c.RCName(side))) + if err != nil { + r.Status = StatusFail + r.Err = fmt.Errorf("%s: %w", c.RCName(side), err) + return r + } + rc[side] = strings.TrimSpace(string(b)) + } + r.MonitorRC = rc[SideGoip] + + // The rc rule, the monitor row's own: the sides must agree and then + // equal the declared one, so a replay that was killed (rc 2, 126, 127, + // 137) cannot pass as three agreeing empty outputs. + if rc[SideIPA] != rc[SideGoip] || rc[SideIPA] != rc[SideIPB] { + r.Status = StatusFail + r.Err = fmt.Errorf("%w: ip_a=%s goip=%s ip_b=%s", + ErrMonfileSide, rc[SideIPA], rc[SideGoip], rc[SideIPB]) + return r + } + if want := strconv.Itoa(c.MonitorExpectRC); rc[SideIPA] != want { + r.Status = StatusFail + r.Err = fmt.Errorf("%w: rc %s on every side, want %s", + ErrMonfileExit, rc[SideIPA], want) + return r + } + + // The stderr rule, the rc's own: a clean replay (rc 0) complained about + // nothing on any side, and a refusal (rc 1) complained on every one — + // the complaint is the point, and it is never compared, goip prefixing + // its name (the T03 record). + for _, side := range Sides() { + b, err := os.ReadFile(filepath.Join(dir, c.ErrName(side))) + if err != nil { + r.Status = StatusFail + r.Err = fmt.Errorf("%s: %w", c.ErrName(side), err) + return r + } + complaint := strings.TrimSpace(string(b)) + switch { + case rc[side] == "0" && complaint != "": + r.Status = StatusFail + r.Err = fmt.Errorf("%w: %s complained on a clean replay: %s", + ErrMonfileStderr, side, complaint) + return r + case rc[side] != "0" && complaint == "": + r.Status = StatusFail + r.Err = fmt.Errorf("%w: %s refused without a complaint", + ErrMonfileStderr, side) + return r + } + } + + texts := map[string]string{} + for _, side := range Sides() { + b, err := os.ReadFile(filepath.Join(dir, c.StdoutName(side))) + if err != nil { + r.Status = StatusFail + r.Err = fmt.Errorf("%s: %w", c.StdoutName(side), err) + return r + } + texts[side] = string(b) + } + + // The stdout. A golden row is held to its records — each side its own — + // and a mismatch is a hard fail, T03's hermetic twin: there is no + // control noise to subtract and nothing to allowlist, the record is the + // row's whole claim. A `-` row is the three-side equality, the monitor + // row's own shape (the text refusal's stdouts are empty on every side). + if c.Golden != "-" { + for _, side := range Sides() { + release := ip730Cst + if side == SideGoip && c.Knob == 0 { + release = ip720Cst + } + b, err := os.ReadFile(filepath.Join(dir, c.GoldenName(release))) + if err != nil { + r.Status = StatusFail + r.Err = fmt.Errorf("%s: %w", c.GoldenName(release), err) + return r + } + if got, want := texts[side], string(b); got != want { + rec, printed := firstDiffLine(string(b), got) + r.Status = StatusFail + r.Err = fmt.Errorf("%w: %s vs %s: record %q, printed %q", + ErrMonfileGolden, side, c.GoldenName(release), + rec, printed) + return r + } + } + r.Stdout = StdoutReport{Command: c.Name, Compared: true} + return r + } + + r.Stdout = CompareStdoutWithControl( + c.Name, texts[SideIPA], texts[SideGoip], texts[SideIPB], al) + gated := al != nil && al.IsGated(c.Name) + switch { + case gated && r.Stdout.Failed(): + r.Status = StatusFail + case len(r.Stdout.Findings) != 0: + r.Status = StatusWarn + } + return r +} + +// firstDiffLine is the first pair of lines that differ, the golden mismatch's +// own evidence — the record's line and the side's, in that order. A side +// that ran out of lines first is named by its end, not by an empty string, +// which would read as "nothing on this side". +func firstDiffLine(record, printed string) (string, string) { + rs := strings.Split(record, "\n") + ps := strings.Split(printed, "\n") + n := len(rs) + if len(ps) < n { + n = len(ps) + } + for i := 0; i < n; i++ { + if rs[i] != ps[i] { + return rs[i], ps[i] + } + } + switch { + case len(rs) > n: + return rs[n], "" + case len(ps) > n: + return "", ps[n] + } + return "", "" +} diff --git a/internal/goipparity/monitor_test.go b/internal/goipparity/monitor_test.go index ac91c7cb6..d4e37c4bc 100644 --- a/internal/goipparity/monitor_test.go +++ b/internal/goipparity/monitor_test.go @@ -319,6 +319,229 @@ func writeCleanMonitorRow(t *testing.T, dir string, c Command) { writeMonRow(t, dir, c, monText("UP", 0), "", strconv.Itoa(c.MonitorExpectRC)) } +// monfileDirCst is the committed monitor files' directory: the EG2 rows' +// inputs and records. +const monfileDirCst = "../goip/testdata/monitor" + +// monfileRowsFor finds the table's carrier rows: the =1 crafted row, the =0 +// row the versions print differently, and the text refusal. +func monfileRowsFor(t *testing.T) (Command, Command, Command) { + t.Helper() + fast, err := Lookup("monitor file bond-partner-fast.nl") + if err != nil { + t.Fatalf("Lookup: %v", err) + } + hibyte, err := Lookup("monitor file bond-partner-hibyte.nl") + if err != nil { + t.Fatalf("Lookup: %v", err) + } + text, err := Lookup("monitor file notnetlink.txt") + if err != nil { + t.Fatalf("Lookup: %v", err) + } + return fast, hibyte, text +} + +// TestCompareMonfileRow holds the offline row's own floor: the rc rule +// (agree, then equal the declared one), the stderr rule (a clean replay +// complained about nothing, a refusal complained on every side), and the +// records (each side its own — the =0 row's goip side the .ip720 one, the +// versions' difference the row's whole point). +func TestCompareMonfileRow(t *testing.T) { + fast, hibyte, text := monfileRowsFor(t) + + t.Run("positive: a clean =1 row passes, every side its .ip730 record", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, fast) + r := compareMonfileRow(dir, fast, nil) + if r.Status != StatusPass { + t.Fatalf("Status = %s (%v), want PASS", r.Status, r.Err) + } + if !r.Stdout.Compared { + t.Error("the stdout report says it was not compared") + } + }) + + t.Run("positive: a clean =0 row passes, goip held to the .ip720 record the ip sides do not print", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, hibyte) + r := compareMonfileRow(dir, hibyte, nil) + if r.Status != StatusPass { + t.Fatalf("Status = %s (%v), want PASS", r.Status, r.Err) + } + }) + + t.Run("positive: the text refusal passes on the declared rc and the complaints", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, text) + r := compareMonfileRow(dir, text, nil) + if r.Status != StatusPass { + t.Fatalf("Status = %s (%v), want PASS", r.Status, r.Err) + } + if r.MonitorRC != "1" { + t.Errorf("MonitorRC = %q, want the declared 1", r.MonitorRC) + } + }) + + t.Run("negative: a golden mismatch fails naming the side and the first differing line", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, hibyte) + // goip prints the .ip730 record (319) where its knob's .ip720 one + // holds 63 — the exact shape the =0 row exists to catch. + rec := monfileRead(t, hibyte.GoldenName(ip730Cst)) + monfileWriteSide(t, dir, hibyte, SideGoip, string(rec), "", "0") + r := compareMonfileRow(dir, hibyte, nil) + if r.Status != StatusFail { + t.Fatalf("Status = %s, want FAIL", r.Status) + } + for _, want := range []string{ErrMonfileGolden.Error(), "goip", + "ad_partner_oper_port_state 63", "ad_partner_oper_port_state 319"} { + if !strings.Contains(r.Err.Error(), want) { + t.Errorf("error %q does not name %q", r.Err, want) + } + } + }) + + t.Run("negative: the three sides' rc disagree", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, fast) + monfileWriteSide(t, dir, fast, SideGoip, "", "", "1") + r := compareMonfileRow(dir, fast, nil) + if r.Status != StatusFail || !strings.Contains(r.Err.Error(), + ErrMonfileSide.Error()) { + t.Fatalf("Status = %s (%v), want the sides' disagreement", r.Status, r.Err) + } + }) + + t.Run("negative: the agreed rc is not the declared one", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, fast) + for _, side := range Sides() { + monfileWriteSide(t, dir, fast, side, "", "", "1") + } + r := compareMonfileRow(dir, fast, nil) + if r.Status != StatusFail || !strings.Contains(r.Err.Error(), + ErrMonfileExit.Error()) { + t.Fatalf("Status = %s (%v), want the unexpected exit", r.Status, r.Err) + } + }) + + t.Run("negative: a complaint on a clean replay fails naming it", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, fast) + rec := string(monfileRead(t, fast.GoldenName(ip730Cst))) + monfileWriteSide(t, dir, fast, SideGoip, rec, "goip: no", "0") + r := compareMonfileRow(dir, fast, nil) + if r.Status != StatusFail || !strings.Contains(r.Err.Error(), + ErrMonfileStderr.Error()) { + t.Fatalf("Status = %s (%v), want the stderr rule", r.Status, r.Err) + } + }) + + t.Run("negative: a refusal without a complaint fails naming the side", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, text) + monfileWriteSide(t, dir, text, SideIPB, "", "", "1") + r := compareMonfileRow(dir, text, nil) + if r.Status != StatusFail || !strings.Contains(r.Err.Error(), + ErrMonfileStderr.Error()) { + t.Fatalf("Status = %s (%v), want the stderr rule", r.Status, r.Err) + } + }) + + t.Run("boundary: the three-side row's divergence is a finding, the monitor row's own rule", func(t *testing.T) { + dir := t.TempDir() + writeCleanMonfileRow(t, dir, text) + // One side renders the text file's bytes (it cannot, which is the + // point — the stdout comparison is what would catch a goip that + // printed something anyway). The complaint stays, so the stderr + // rule holds and the divergence is the row's finding. + monfileWriteSide(t, dir, text, SideGoip, "something", + "goip: monitor file: !!!malformed message: len=16 @16", "1") + r := compareMonfileRow(dir, text, nil) + if r.Status != StatusWarn { + t.Fatalf("Status = %s (%v), want WARN", r.Status, r.Err) + } + if !r.Stdout.Failed() || len(r.Stdout.Findings) != 1 { + t.Errorf("findings = %v, want the one line-count divergence", r.Stdout.Findings) + } + }) +} + +// monfileWriteSide writes one side's three files — writeMonRow's shape, one +// side at a time, because a monfile row's three sides print three different +// texts (a =0 row's goip side its own record, the refusal's complaint its +// own name). +func monfileWriteSide(t *testing.T, dir string, c Command, + side, out, errText, rc string, +) { + t.Helper() + if err := os.WriteFile(filepath.Join(dir, c.StdoutName(side)), + []byte(out), 0o600); err != nil { + t.Fatalf("%s: %v", c.StdoutName(side), err) + } + if err := os.WriteFile(filepath.Join(dir, c.RCName(side)), + []byte(rc), 0o600); err != nil { + t.Fatalf("%s: %v", c.RCName(side), err) + } + if err := os.WriteFile(filepath.Join(dir, c.ErrName(side)), + []byte(errText), 0o600); err != nil { + t.Fatalf("%s: %v", c.ErrName(side), err) + } +} + +// writeCleanMonfileRow writes one monfile row's clean files — the row +// TestRender's "every implemented command clean" setup writes for the +// table's monfile rows. A golden row's three sides print their own records +// (the ip sides the .ip730 one, the goip side the one its knob names), and +// the records land beside the captures as the driver ships them — the +// committed files ARE the fixture, the row's whole claim being that the +// tools print them. The text refusal's stdout is empty, its rc the declared +// 1, its .err each side's own complaint (goip prefixing its name, which is +// why the comparator never compares them). +func writeCleanMonfileRow(t *testing.T, dir string, c Command) { + t.Helper() + if c.Golden == "-" { + for _, side := range Sides() { + complaint := "!!!malformed message: len=16 @16\n" + if side == SideGoip { + complaint = "goip: monitor file: " + complaint + } + monfileWriteSide(t, dir, c, side, "", complaint, + strconv.Itoa(c.MonitorExpectRC)) + } + return + } + for _, side := range Sides() { + release := ip730Cst + if side == SideGoip && c.Knob == 0 { + release = ip720Cst + } + rec := monfileRead(t, c.GoldenName(release)) + monfileWriteSide(t, dir, c, side, string(rec), "", "0") + } + for _, release := range []string{ip730Cst, ip720Cst} { + if release == ip720Cst && c.Knob != 0 { + continue + } + rec := monfileRead(t, c.GoldenName(release)) + if err := os.WriteFile(filepath.Join(dir, c.GoldenName(release)), + rec, 0o600); err != nil { + t.Fatalf("%s: %v", c.GoldenName(release), err) + } + } +} + +// monfileRead reads one committed monitor file by basename. +func monfileRead(t *testing.T, name string) []byte { + t.Helper() + b, err := os.ReadFile(filepath.Join(monfileDirCst, name)) + if err != nil { + t.Fatalf("%s: %v", name, err) + } + return b +} + // monitorRowFor finds the table's carrier row, the EG1-T01 probe's own. func monitorRowFor(t *testing.T) Command { t.Helper() diff --git a/nix/checks/goip-monitorfile.nix b/nix/checks/goip-monitorfile.nix index 9db277d0a..4bf3591a1 100644 --- a/nix/checks/goip-monitorfile.nix +++ b/nix/checks/goip-monitorfile.nix @@ -84,6 +84,15 @@ pkgs.runCommand "xtcp2-test-goip-monitorfile" replays=0 for nl in "$blobs"/*.nl; do stem=$(basename "$nl" .nl) + # The pcap corner's .nl has no spec — nlcapgen monfile writes it + # from the committed capture (its own test holds the two equal), + # and a real capture's bytes cannot move: its ifindex 3 is not the + # no-sandbox-index rule's 7, so the sandbox names it. The live + # row's own Setup is what the golden records — c0 at ifindex 3, + # the corpus layout — and that replay is the row's, gated there. + if [ ! -e "$blobs/$stem.spec" ]; then + continue + fi run() { label=$1 golden=$2 @@ -101,23 +110,25 @@ pkgs.runCommand "xtcp2-test-goip-monitorfile" run ip720-by-goip "$blobs/$stem.ip720.out" env GOIP_IP730=0 "$goip" done - # 3. The refusal row: a file that is not netlink. Both ips and goip, at - # both knobs — the monitor file walk is the parser's, not the - # release's. The parity claim is the empty stdout and rc 1; the - # stderr is each tool's own complaint (goip prefixes its name). - printf 'this is not a netlink file at all, just text\n' > not-nl.txt + # 3. The refusal row: the committed text file, the live row's own + # input (EG2-T01) — one source, the row's and the check's. Both + # ips and goip, at both knobs — the monitor file walk is the + # parser's, not the release's. The parity claim is the empty + # stdout and rc 1; the stderr is each tool's own complaint (goip + # prefixes its name). + notnl="$blobs/notnetlink.txt" for label in ip730 ip720; do ip=$ip730 [ "$label" = ip720 ] && ip=$ip720 rc=0 - "$ip" -d monitor file not-nl.txt >got.txt 2>err.txt || rc=$? + "$ip" -d monitor file "$notnl" >got.txt 2>err.txt || rc=$? [ "$rc" -eq 1 ] || red "refusal/$label: rc $rc, want 1" [ ! -s got.txt ] || red "refusal/$label: stdout is not empty" [ -s err.txt ] || red "refusal/$label: no complaint" done for knob in 1 0; do rc=0 - GOIP_IP730=$knob "$goip" -d monitor file not-nl.txt >got.txt 2>err.txt || rc=$? + GOIP_IP730=$knob "$goip" -d monitor file "$notnl" >got.txt 2>err.txt || rc=$? [ "$rc" -eq 1 ] || red "refusal/goip-knob$knob: rc $rc, want 1" [ ! -s got.txt ] || red "refusal/goip-knob$knob: stdout is not empty" [ -s err.txt ] || red "refusal/goip-knob$knob: no complaint" diff --git a/nix/microvms/default.nix b/nix/microvms/default.nix index 07cfcece4..2d8ce9f71 100644 --- a/nix/microvms/default.nix +++ b/nix/microvms/default.nix @@ -1142,6 +1142,7 @@ let let dir = ../../pkg/xtcpnl/testdata/7_1_4/link-write/addr-save; rtnl = ../../pkg/xtcpnl/testdata/7_1_4/link-write/rtnl; + monfile = ../../internal/goip/testdata/monitor; in pkgs.runCommand "xtcp2-goip-parity-save-blobs" { @@ -1156,6 +1157,16 @@ let cp $restoreExisting $out/restore_existing.save cp $routeSave $out/route_save.save cp $ruleSave $out/rule_save.save + # The EG2 monfile rows' own inputs and records, the same discipline + # the restore rows' .save files ride: the blobs the rows replay, the + # text refusal, and the committed goldens the comparator holds the + # sides to — the ip sides the .ip730 record, the goip side the one + # its knob names. The specs stay host-side: the .nl is the input, + # the spec its reviewable source (T03 regenerates the one from the + # other hermetically). + mkdir -p $out/monfile + cp ${monfile}/*.nl ${monfile}/*.txt $out/monfile/ + cp ${monfile}/*.ip730.out ${monfile}/*.ip720.out $out/monfile/ ''; # goip/ip parity runner (Tier C): boots the goip-parity VM, drives it with diff --git a/nix/microvms/scripts/goip-parity.exp b/nix/microvms/scripts/goip-parity.exp index 4136164e4..e5e98258d 100644 --- a/nix/microvms/scripts/goip-parity.exp +++ b/nix/microvms/scripts/goip-parity.exp @@ -231,10 +231,11 @@ proc read_command_table {} { continue } set f [split $line "\t"] - # Ten fields, or thirteen and more: a monitor row — the marker, the - # canary, the trigger, then each until-ERE its own field. Anything - # between 10 and 13 is a row the driver would misread, which is - # precisely the failure this check exists to catch. + # Ten fields, or thirteen and more: a monitor row (the marker, the + # canary, the trigger, then each until-ERE its own field) or a + # monfile row (the marker, the knob, the golden stem — always + # thirteen). Anything between 10 and 13 is a row the driver would + # misread, which is precisely the failure this check exists to catch. if {[llength $f] != 10 && [llength $f] < 13} { vmlib::log "FATAL: unparseable table row ([llength $f] fields): $line" puts "GOIP_PARITY_DRIVER_FAIL" @@ -271,7 +272,16 @@ proc capture_triple {row dev} { # check below because the monitor flow does its own. set tail [lassign $row slug floor impl needs_dev write proto setup stdin args name] if {[llength $tail] > 0} { - capture_monitor_triple $slug $impl $setup $args $tail + # The marker names the row kind: `monitor`, the EG1 rows (canary, + # trigger, then each until-ERE its own field), or `monfile`, the EG2 + # rows (the knob, then the golden stem). Anything else is a row this + # driver would misread — the pair rule's other half. + if {[lindex $tail 0] eq "monfile"} { + capture_monfile_triple $slug $impl $setup $args \ + [lindex $tail 1] [lindex $tail 2] + } else { + capture_monitor_triple $slug $impl $setup $args $tail + } return } @@ -440,6 +450,85 @@ proc capture_monitor_triple {slug impl setup args tail} { } } +############################################################################### +# capture_monfile_triple - one +# EG2 row's three replays, `ip -d monitor file` twice around +# `goip -d monitor file` at the knob, each side in a fresh namespace with the +# row's Setup applied (the pcap row's c0, landing at ifindex 3 as the corpus +# layout has it; the crafted blobs' rows carry none, an empty namespace, so +# ifindex 7 misses and prints if7 — the no-sandbox-index rule, the T03 +# sandbox's own). The blob, the text refusal and the goldens were copied to +# the capture dir before any row ran, so the replay's file name is bare and +# the evidence ships in the blob. No helper and no canary: the blob's bytes +# are the row's whole input, and the rc the tools exit is their own. +############################################################################### + +proc capture_monfile_triple {slug impl setup args knob golden} { + global NSW SUBDIR short_caps write_skipped capture_dir + + if {$impl ni {yes ip}} { + lappend skipped "$slug" + vmlib::log "SKIP $slug: goip does not implement the replay yet" + return + } + + # The pin's sbin, resolved once, before the sides, so a store path + # moving mid-row cannot hand one side a different binary than another. + lassign [vmlib::run_out "dirname \$(readlink -f \$(command -v ip))"] rc ipdir + set ipdir [string trim $ipdir] + if {$rc != 0 || $ipdir eq ""} { + lappend short_caps "$SUBDIR/$slug" + vmlib::log "MISSED FLOOR $SUBDIR/$slug: no ip on the guest PATH" + return + } + + # The row's input is its argv's last word, already copied to the + # capture dir — the replay runs from there (cmd_mon's own cd), so the + # floor check reads the path the same way. A missing one is a + # driver/setup disagreement, named rather than run. + set file [lindex $args end] + if {[vmlib::run "test -r $capture_dir/$file"] != 0} { + lappend short_caps "$SUBDIR/$slug" + vmlib::log "MISSED FLOOR $SUBDIR/$slug: the input $file is not readable" + return + } + + set steps {} + if {$setup ne "-"} { + set steps [split $setup ";"] + } + + set plan [list \ + ip_a "$ipdir/ip -d monitor file $file" \ + goip "GOIP_IP730=$knob goip -d monitor file $file" \ + ip_b "$ipdir/ip -d monitor file $file"] + + foreach {side command} $plan { + vmlib::must "xtcp2-nlcap ns-add $NSW" + set refused 0 + foreach step $steps { + if {[setup_step $NSW $step] != 0} { + set refused 1 + break + } + } + if {$refused} { + lappend write_skipped "$slug.$side" + continue + } + settle_links $NSW + lassign [vmlib::run_out \ + "xtcp2-nlcap mon $NSW $SUBDIR $slug.$side '$command'" \ + 120] mon_rc mon_out + if {$mon_rc != 0} { + lappend short_caps "$SUBDIR/$slug.$side" + vmlib::log "MISSED FLOOR $SUBDIR/$slug.$side: [string trim $mon_out]" + continue + } + vmlib::log [string trim $mon_out] + } +} + ############################################################################### # setup_step - one Setup step; 0 when it applied. # @@ -700,6 +789,12 @@ if {$dir_rc != 0 || $capture_dir eq ""} { # the captures. vmlib::must "cp $save_blobs/restore_fresh.save $save_blobs/restore_existing.save $save_blobs/route_save.save $save_blobs/rule_save.save $capture_dir/" +# The EG2 rows' inputs and records, the same discipline: the blobs the rows +# replay, the text refusal and the goldens the comparator holds the sides to, +# copied wholesale — the replay's file name is bare (the row's command runs +# from the capture dir) and the evidence ships in the blob. +vmlib::must "cp $save_blobs/monfile/* $capture_dir/" + set table [read_command_table] if {$section ne ""} { vmlib::log "=== section $section only: not the full gate ===" diff --git a/tools/nlcapgen/monfile_test.go b/tools/nlcapgen/monfile_test.go index bb6bad15e..4ddc1e2ca 100644 --- a/tools/nlcapgen/monfile_test.go +++ b/tools/nlcapgen/monfile_test.go @@ -230,6 +230,33 @@ func TestMonfileCommittedSpecs(t *testing.T) { } } +// TestMonfileCommittedPcap is the pcap corner's own half of the +// regeneration golden: the committed .nl (evnhb-bucket, the EG2-T01 row's +// input) is what monfile -pcap writes from the committed capture — +// TestMonfilePcap holds that stream to its hex golden, and this holds the +// committed FILE to it, the spec pairs' own discipline the crafted blobs +// ride. +// +// go test ./tools/nlcapgen/ -run TestMonfileCommittedPcap +func TestMonfileCommittedPcap(t *testing.T) { + const ( + pcap = "../../pkg/xtcpnl/testdata/7_3_1/ws/ev/evnhb-bucket/ip.pcap" + nl = "../../internal/goip/testdata/monitor/evnhb-bucket.nl" + ) + want, err := os.ReadFile(nl) + if err != nil { + t.Fatal(err) + } + out := filepath.Join(t.TempDir(), "regen.nl") + rc, stdout, stderr, got := monfileRun(t, "-pcap", pcap, "-out", out) + if rc != 0 || stdout != "3 of 16 messages\n" || stderr != "" { + t.Fatalf("rc %d, stdout %q, stderr %q", rc, stdout, stderr) + } + if !bytes.Equal(got, want) { + t.Errorf("regenerated %x, committed %x", got, want) + } +} + // walkMonfile walks .nl bytes as rtnl_from_file does — each header, then its // body to the 4-byte boundary — failing unless the walk ends exactly at the // end of the stream.