Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions docs/netlink/events-export-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
test that pins them (`TestEventsExportPolicyInputs`, `pkg/xtcpnl`). One
plan premise was falsified by the measurement: the kernel sends **one
notification per datagram**, every corpus, both kernel eras, every family —
the flush policy is the batching. Next: Tier EXP, the proto.
the flush policy is the batching.
- Tier EXP is done (V404): `proto/xtcp_netlink_events/v1/` — the five family
messages in the 2100–2500 blocks (kernel member spelling, per-field
kernel-source comments, presence as `has_` pairs), the `NetlinkEvent`
wrapper (the nlmsghdr, the netns provenance, the action enum, the oneof)
and the `Envelope` — generated by `nix run .#regen-protos` into all five
`gen/` targets; the conversion (`pkg/xtcp/events_export_convert.go`) and
the round-trip gate over every committed event pcap and crafted blob
(458 link, 165 addr, 303 route, 107 neigh, 10 rule — all five families,
the totals pinned). Next: Tier EXD, the destination.

## Contents

Expand All @@ -35,7 +44,7 @@
| Phase | Work | Closed by | State | Evidence |
|---|---|---|---|---|
| [Tier EXM](events-export.md#tier-exm-the-policy-measured) | the constants, measured from the corpora | EXM-T02 | done | V403 |
| [Tier EXP](events-export.md#tier-exp-the-proto) | the messages, the generation, the conversion | EXP-T02 | not started | — |
| [Tier EXP](events-export.md#tier-exp-the-proto) | the messages, the generation, the conversion | EXP-T02 | done | V404 |
| [Tier EXD](events-export.md#tier-exd-the-destination) | the producer, the config, the self-test gate | EXD-T03 | not started | — |
| [Tier EXC](events-export.md#tier-exc-clickhouse) | the table, the topic, the flavor | EXC-T03 | not started | — |
| [Tier EXU](events-export.md#tier-exu-the-close) | §14 resolved, the deferrals unwound | EXU-T01 | not started | — |
Expand All @@ -46,8 +55,8 @@
|---|---|---|---|---|
| [x] | [EXM-T01](events-export.md#exm-t01-the-corpora-are-the-workload) | measure the corpora | done | V403 |
| [x] | [EXM-T02](events-export.md#exm-t02-the-constants-and-the-test-that-pins-them) | the constants, and the test that pins them | done | V403 |
| [ ] | [EXP-T01](events-export.md#exp-t01-the-messages) | the messages | not started | — |
| [ ] | [EXP-T02](events-export.md#exp-t02-generation-and-conversion) | generation and conversion | not started | — |
| [x] | [EXP-T01](events-export.md#exp-t01-the-messages) | the messages | done | V404 |
| [x] | [EXP-T02](events-export.md#exp-t02-generation-and-conversion) | generation and conversion | done | V404 |
| [ ] | [EXD-T01](events-export.md#exd-t01-the-producer) | the producer | not started | — |
| [ ] | [EXD-T02](events-export.md#exd-t02-the-config-and-the-flag) | the config and the flag | not started | — |
| [ ] | [EXD-T03](events-export.md#exd-t03-the-gate) | the self-test gate | not started | — |
Expand All @@ -60,10 +69,23 @@

| ID | Task | Evidence |
|---|---|---|
| V404 | EXP | **The proto:** `proto/xtcp_netlink_events/v1/xtcp_netlink_events.proto` — the five family messages in the record proto's own style (the header cites the allocation plan: 2100 ifinfomsg, 2200 ifaddrmsg, 2300 rtmsg, 2400 ndmsg, 2500 fib_rule_hdr; the blocks sit above 2047, so every payload field costs a 3-byte tag — §14 assigns the numbers, and EXM's measured low volume is what makes the cost immaterial). Every field carries a kernel-source comment with the attribute number read from `~/Downloads/linux/include/uapi/linux/{if_link,if_addr,rtnetlink,neighbour,fib_rules}.h` (IFLA_OPERSTATE 16, NDA_FDB_EXT_ATTRS 14, FRA_DSCP_MASK 30, …). Presence is a `has_`-prefixed bool beside the value — the structs' own Has* pairs, load-bearing for the events' render semantics. **The v1 surface:** the header structs and the scalar attributes; the nested payloads (the forty per-kind link nests, RTA_MULTIPATH, RTA_METRICS, the stats blocks) are presence bits, each a later block, never an epoch bump — the file header's scope note names the rule. `NetlinkEvent` carries the nlmsghdr, the timestamp, the netns provenance (the record's own netns/netns_inode/nsid/nsid_assigned contract), the derived action enum, and the oneof. `XtcpNetlinkEventsSchemaVersion = 1` lands in `pkg/xtcp/schema_version.go` beside the record's. **Generated** by `nix run .#regen-protos` (the regen re-resolves the protovalidate dep in `buf.lock` to a newer commit; the events proto imports nothing, so the outputs are lock-independent and the lock is reverted — the drift is the regen path's own behavior, noted for the next arc that regenerates). **The conversion** (`pkg/xtcp/events_export_convert.go`): a pure function per family plus the `ConvertNetlinkEvent` wrapper (any other payload is an error, never a silent drop). **The gate:** `TestEventsExportConvertRoundTrip` walks the 71 event pcaps and the 15 crafted `.nl` files — parse, convert, marshal, unmarshal, `proto.Equal` — **458 link, 165 addr, 303 route, 107 neigh, 10 rule**, the totals pinned; `TestEventsExportConvertSpotPins` compares the struct's own values against the converted fields for one corpus event per family (the round trip alone cannot catch a swapped mapping — both directions would carry the same wrong field). **The wire-contract finding, groundwork for EXC:** the committed `clickhouse_protolist` artifacts pin the ProtobufList framing — `insert4294967295.proto.bin` is `[varint][Record bytes]` (one length-delimited row per row) while `insert1_and_4294967295.bin` is `[varint][Envelope]` (rows wrapped) — and the record's kafka table names the ROW type with the comment "ClickHouse's ProtobufList handles the envelope framing internally". Which schema name the events' engine table names, and how the oneof's payloads map to columns, is EXC-T01's container probe. Gates: both full suites, vet both modes, gofmt, `lint-baseline`, `test-goip-docs`, `netlink-audit`, `nix-fmt`, `buf lint` (STANDARD, clean). |
| V403 | EXM | **Measured:** `TestEventsExportPolicyInputs` (`pkg/xtcpnl/xtcpnl_events_export_policy_test.go`) walks the committed event corpora — the five 7.1.4 oneshot pcaps (a 41-second boot window; the base pcap the union of the four family splits, 355 = 66+125+44+120) and the 66 ev rows at both iproute2 versions — and pins the measured shape: events, datagrams, the per-event body sizes, the peak 100 ms and 1 s windows, the quiet gaps. **The finding that reshaped the tier:** one notification per datagram, every corpus, both kernel eras, every family (max events per datagram = 1, asserted over all 71 pcaps) — the plan's premise that the kernel batches notifications into one recvmsg is falsified; the flush policy is the batching. **The numbers:** the boot flood peaks at 56 events in 100 ms (60 in the worst second); a churn row's whole window peaks at 17; the quiet gaps run to 16.69 s (steady state); the event bodies run 40 bytes (the smallest route/nsid event) to 1548 (a full link event), median 40-116. **The constants** (`pkg/xtcp/events_export_policy.go`): `EventsFlushIntervalCst` = 1 s (the locality consumer's own chosen latency, the §13 close's "within a 1s debounce"; a lone event waits at most this), `EventsFlushThresholdRowsCst` = 64 (above the 56-per-100 ms boot peak, ~4× the churn rows' worst window), `EventsFlushThresholdBytesCst` = 64 KiB (~41 of the widest 1548-byte rows; the record path's rows-primary/bytes-secondary pair). The queue needs no events-specific depth: the destination's default (16 envelopes) holds over 1.5 s of the measured worst flood, and drop-oldest is the record path's answer. The test's walk treats a zero nlmsghdr as end-of-datagram padding (the 7.1.4 oneshot zero-pads its records — measured at base-pcap record 515) and is manual, not `WalkNlMsgsHdr`, because the latter's seq filter drops exactly the userspace-caused notifications (`IsRtnetlinkNotification`'s own documented trap). The crafted monitor files carry no timestamps, so they are EXP's round-trip inputs, not this measurement's. Gates: `go test ./pkg/xtcpnl/ -run TestEventsExportPolicyInputs`, both full suites, vet both modes, gofmt, `lint-baseline`, `test-goip-docs`, `netlink-audit`, `nix-fmt`. |

## Decision log

- **2026-12-04: the nests are presence bits, not payloads (EXP, V404).** The
structs decode forty per-kind link nests and five route nests; the export's
v1 carries their presence and the kind strings, not their payloads — each
nest is a later block (the plan's "never twenty fields at once"), and the
IFLA_STATS counters are presence-only for the stronger reason that 200
bytes of counters moving with every packet are noise in an event stream.
- **2026-12-04: `stats_is64`, not `stats_is_64` (EXP, V404).** The proto
field `stats_is_64` generates the Go name `StatsIs_64` — the digits split
their own word. `stats_is64` generates `StatsIs64`; the rename is the
house's "fix it in the code, not around it" applied to the generator's own
naming rule.

- **2026-12-04: one notification per datagram — the premise corrected (EXM,
V403).** The tier expected the kernel to batch notifications into one
recvmsg. The corpora falsify it: every datagram in every committed event
Expand Down
29 changes: 29 additions & 0 deletions gen/cpp/xtcp_netlink_events/v1/xtcp_netlink_events.grpc.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions gen/cpp/xtcp_netlink_events/v1/xtcp_netlink_events.grpc.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading