Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8677226
test(nlcapgen): devlink read-only capture space (1C, V079)
randomizedcoder Nov 14, 2026
63f8be0
feat(xtcpnl): devlink genl parser, table tests and O3/O4 corpus (1P, …
randomizedcoder Nov 14, 2026
b56da87
feat(godevlink): read-only devlink render clone replaying the ws corp…
randomizedcoder Nov 14, 2026
ea3a7f3
docs(netlink): record two devlink.c print-path bugs (1B, DOC026)
randomizedcoder Nov 14, 2026
705ea9a
test(nlcapgen): vdpa read-only capture space in init_net (2C, V082)
randomizedcoder Nov 14, 2026
6a4045b
feat(xtcpnl): vdpa genl parser, request builder, table tests and O3/O…
randomizedcoder Nov 14, 2026
1850e2f
feat(govdpa): read-only vdpa render clone replaying the ws corpus (2R…
randomizedcoder Nov 14, 2026
f20cdb2
docs(netlink): record eight vdpa/vdpa.c print/argument findings (2B, …
randomizedcoder Nov 14, 2026
bba752b
test(nlcapgen): fou read-only show capture space, per-netns (3C, V085)
randomizedcoder Nov 14, 2026
676f49a
feat(xtcpnl): fou request builder, fuzz and O3/O4 corpus test (3P, V086)
randomizedcoder Nov 14, 2026
1bc8f83
feat(gofou): read-only ip-fou render clone replaying the ws corpus (3…
randomizedcoder Nov 14, 2026
f42e7de
docs(netlink): record three ip/ipfou.c print-path findings (3B, DOC028)
randomizedcoder Nov 14, 2026
c170050
fix(gofou): build test message fixtures as composite literals (lint p…
randomizedcoder Nov 22, 2026
919c23a
test(nlcapgen): mptcp read-only capture space on generic+route (4C, V…
randomizedcoder Nov 22, 2026
7c04c70
test(xtcpnl): mptcp ws corpus O3/O4 and FuzzParseMPTCPPM (4P, V090)
randomizedcoder Nov 22, 2026
0fb5b55
test(goip): replay the mptcp ws corpus through goip (4R, V091)
randomizedcoder Nov 22, 2026
bc0e808
docs(netlink): record seven ip/ipmptcp.c findings (4B, DOC029)
randomizedcoder Nov 22, 2026
3d31ced
refactor(gofou): retire gofou into goip's ip fou clone (V092)
randomizedcoder Nov 22, 2026
3124f2a
test(nlcapgen): tipc read-only capture space, 93 rows (5C, V093)
randomizedcoder Nov 23, 2026
b0c59ed
feat(xtcpnl): TIPC genl parser, request builders, O3/O4 corpus test (…
randomizedcoder Nov 23, 2026
b93e606
feat(gotipc): read-only tipc(8) clone replaying the ws corpus (5R, V095)
randomizedcoder Nov 23, 2026
0626867
docs(netlink): record sixteen tipc/ findings (5B, DOC030)
randomizedcoder Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .golangci-comprehensive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,19 @@ linters:
linters:
- misspell
text: "`neighbour` is a misspelling of `neighbor`"
# `flavour` is the devlink UAPI spelling: DEVLINK_ATTR_PORT_FLAVOUR and
# the DEVLINK_PORT_FLAVOUR_* enum (include/uapi/linux/devlink.h), and the
# literal token devlink(8) prints ("flavour physical" / "<unknown
# flavour>"), which internal/godevlink reproduces byte for byte over the
# ws corpus. Respelling it would both break the kernel-citation
# correspondence in pkg/xtcpnl's devlink decoder and make the clone's
# output diverge from the captured devlink stdout. Like `neighbour`
# above, scoped to the devlink files; British prose elsewhere still fails.
# Kept in step with the Tier 1 (.golangci.yml) rule per the note above.
- path: "(internal/godevlink/[^/]+|pkg/xtcpnl/xtcpnl_devlink(_test)?)\\.go"
linters:
- misspell
text: "`[Ff]lavour` is a misspelling of `[Ff]lavor`"
# The ten files below cite kernel paths that contain the word.
# net/core/neighbour.c and include/uapi/linux/neighbour.h are the real
# file names, so "correcting" them produces paths that do not exist and
Expand Down
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,20 @@ linters:
linters:
- misspell
text: "`neighbour` is a misspelling of `neighbor`"
# `flavour` is the devlink UAPI spelling: DEVLINK_ATTR_PORT_FLAVOUR and
# the DEVLINK_PORT_FLAVOUR_* enum (include/uapi/linux/devlink.h), and the
# literal token devlink(8) prints ("flavour physical" / "<unknown
# flavour>"), which internal/godevlink reproduces byte for byte over the
# ws corpus. Respelling it would both break the kernel-citation
# correspondence in pkg/xtcpnl's devlink decoder and make the clone's
# output diverge from the captured devlink stdout. Like `neighbour`
# above, it is scoped to the devlink files; British prose elsewhere still
# fails. The matching kernel-path citations are covered by
# tools/kernel-citation-audit.
- path: "(internal/godevlink/[^/]+|pkg/xtcpnl/xtcpnl_devlink(_test)?)\\.go"
linters:
- misspell
text: "`[Ff]lavour` is a misspelling of `[Ff]lavor`"
# The eleven files below cite kernel paths that contain the word.
# net/core/neighbour.c and include/uapi/linux/neighbour.h are the real
# file names, so "correcting" them produces paths that do not exist and
Expand Down
21 changes: 21 additions & 0 deletions cmd/godevlink/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Command godevlink is a read-only Go clone of devlink(8), iproute2 7.2.0's,
// for the dump/show subcommands captured in pkg/xtcpnl's workbench corpus.
//
// Like goip and gordma, it is a coverage test for pkg/xtcpnl rather than a
// replacement: replaying devlink's nlmon (ws) pcap corpus through it must
// reproduce devlink's stdout, stderr and exit code byte for byte. See
// internal/godevlink.
//
// godevlink never writes: its requests are the read-only DEVLINK_CMD_*_GET
// dumps and the dpipe-table gets `devlink resource show` issues.
package main

import (
"os"

"github.com/randomizedcoder/xtcp2/internal/godevlink"
)

func main() {
os.Exit(godevlink.Run(os.Args[1:], os.Stdout, os.Stderr))
}
21 changes: 21 additions & 0 deletions cmd/gotipc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Command gotipc is a read-only Go clone of tipc(8), iproute2 7.2.0's, for
// the read-only commands captured in pkg/xtcpnl's workbench corpus.
//
// Like godevlink and govdpa, it is a coverage test for pkg/xtcpnl rather
// than a replacement: replaying tipc's nlmon (ws) pcap corpus through it
// must reproduce tipc's stdout, stderr and exit code byte for byte. See
// internal/gotipc.
//
// gotipc never writes: its requests are the TIPC *_GET dumps and gets and
// the family lookups tipc makes.
package main

import (
"os"

"github.com/randomizedcoder/xtcp2/internal/gotipc"
)

func main() {
os.Exit(gotipc.Run(os.Args[1:], os.Stdout, os.Stderr))
}
21 changes: 21 additions & 0 deletions cmd/govdpa/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Command govdpa is a read-only Go clone of vdpa(8), iproute2 7.2.0's, for
// the show subcommands captured in pkg/xtcpnl's workbench corpus.
//
// Like goip, gordma and godevlink, it is a coverage test for pkg/xtcpnl
// rather than a replacement: replaying vdpa's nlmon (ws) pcap corpus through
// it must reproduce vdpa's stdout, stderr and exit code byte for byte. See
// internal/govdpa.
//
// govdpa never writes: its requests are the read-only VDPA_CMD_*_GET
// dumps and gets.
package main

import (
"os"

"github.com/randomizedcoder/xtcp2/internal/govdpa"
)

func main() {
os.Exit(govdpa.Run(os.Args[1:], os.Stdout, os.Stderr))
}
226 changes: 226 additions & 0 deletions docs/netlink/genl-clones-status.md

Large diffs are not rendered by default.

234 changes: 234 additions & 0 deletions docs/netlink/genl-clones.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# genl clones: devlink, vdpa, fou, mptcp, tipc — captures first

**Status doc:** [genl-clones-status.md](genl-clones-status.md) tracks progress against this plan.

## Context

The NX6–NX10 encap / name-table / nexthop-stats arc is merged (PR #302, merge
`70ea3a3a5`). The `ip`→`goip` rtnetlink clone is byte-for-byte complete across the
corpus. The next frontier is Phase 5 **generic netlink**
([coverage-status.md](coverage-status.md): "genetlink: nlctrl GETFAMILY first, then
ethtool/devlink/netdev/vdpa/fou/gtp"), of which only **ethtool** is done, and only as
decode + request checks, with no CLI clone.

This arc does **three increments**, one genl family each, each following the house
rhythm **captures → parser → table tests → read-only render clone**, and each
continuing the iproute2 bug hunt (recorded only, never sent).

- **devlink** — `devlink` CLI ships in iproute2 (`devlink/devlink.c`), backed
hardware-free by `netdevsim` (already used for the ethtool captures).
- **vdpa** — `vdpa` CLI ships in iproute2 (`vdpa/vdpa.c`), backed by `vdpa_sim_net`
(a software mgmtdev registered at module load, no hardware).
- **fou** (replacing **netdev**) — `netdev` genl has **no userspace CLI** (only the
kernel's unpackaged `tools/net/ynl`), which breaks both "capture from a real tool"
and the byte-for-byte clone. **fou** is the clean substitute: a genl family with the
`ip fou` CLI (`ip/ipfou.c`), a hardware-free module, and partial decode already in
the repo (`pkg/xtcpnl/xtcpnl_fou.go`).

Each increment adds a read-only render clone modeled on `gordma` (the read-only
`rdma(8)` clone): `godevlink`, `govdpa`, `gofou`. Each replays its own capture corpus
and must reproduce the real CLI's stdout/stderr/rc byte for byte. (`gofou` was later
retired into goip's `obj_fou.go`, which replays the same corpus; see 3P/3R/3B.)

**Scope guard:** the clones cover only the read-only dump/show subcommands actually
captured — not the full CLIs (devlink in particular is large). No writes, no
monitor-live.

**Out of scope:** netdev genl (no CLI — parked until ynl is packaged or a client
appears); gtp genl (iproute2 has only the gtp *link type*, not a genl client — same
problem as netdev); devlink/vdpa *write* paths; live `monitor`.

## Shared foundation (reuse — do not rebuild)

- **genl family-id resolution** already exists (built for ethtool):
`pkg/xtcpnl/xtcpnl_genetlink_requests.go` (`BuildGetFamilyRequest`,
`BuildGetFamilyRequestVersion`, `BuildGetFamilyByIDRequest`, `buildGenericGet`);
`pkg/xtcpnl/xtcpnl_genetlink.go` (`GenlControllerID` = 16, `ParseGenericNetlinkFamily`);
`pkg/linkmonitor/internal/linuxio/family_linux.go` (`DiscoverFamily`);
`pkg/nlparity/nlparity_genl.go` (`resolveGenl`). A clone resolves its family id **from
the capture**, the way `ethGenlID` does in `xtcpnl_ws_ethtool_test.go`.
- **genl decode precedent:** `pkg/xtcpnl/xtcpnl_ethtool.go` + `xtcpnl_ethtool_test.go`
(table tests + `FuzzParseEthtool`) + `xtcpnl_ws_ethtool_test.go` (O3/O4 corpus) +
`tools/nlcapgen/matrix_ethtool.go` (generator). Follow this shape.
- **render-clone template:** `cmd/gordma/main.go` (thin) + `internal/gordma/`
(`gordma.go` dispatch/`talk`, `obj_*.go` renderers, `print.go` dual text/JSON printer
mirroring iproute2's json_writer, `source.go` `Source`/`ReplaySource` byte-for-byte
replay, `corpus_test.go` sidecar parity over all kernels, `imports_test.go`).
**Difference:** gordma replays an nlstrace corpus because `NETLINK_RDMA` is untappable;
devlink/vdpa/fou are `NETLINK_GENERIC` and **are** tappable by nlmon, so their clones
replay the **ws pcap** corpus (like the ethtool ws tests and `internal/goip`'s ws
replay). `ReplaySource` is adapted to the ws capture format rather than nlstrace.
- **capture harness:** add `tools/nlcapgen/matrix_<fam>.go` + register in
`tools/nlcapgen/main.go`; generate `nix/microvms/workbench/<fam>.rows.jsonl`;
capture via `nix run .#nlcap-ws -- batch` into `pkg/xtcpnl/testdata/<kver>/ws/<fam>/`.
- **existing partial decode to finish, not duplicate:** `pkg/xtcpnl/xtcpnl_fou.go`,
`xtcpnl_gtp.go` and their tests already exist — the fou increment extends these.

## Increment 1 — devlink (genl, `devlink` CLI, netdevsim)

### 1C: capture (NC-DL)
- Guest readiness: `netdevsim` present; `DEVLINK=y` (netdevsim pulls it in — no kernel
change). A device is created by writing `/sys/bus/netdevsim/new_device` in each row's
`pre` step, with a **fixed bus id 0** so the printed handle (`netdevsim/netdevsim0`) is
deterministic; rows run **serial** so the device-creation order and the netdevsim
`index` counter are deterministic too. Module list `["netdevsim"]`.
- `matrix_devlink.go` space `devlink`: the read-only dumps, each plain and `-j`:
`dev show` (1), `port show` (5), `sb show` (11), `resource show` (40),
`dev param show` (44), `region show` (48), `dev info` (57), `health show` (58),
`trap show` (67), `trap group show` (71). netdevsim registers no shared buffer, so
`sb show` is an empty dump — a boundary the parser and clone must handle.
- Negatives: `nosuch show` (unknown object, iproute2 exits 1 before any request);
`dev show netdevsim/netdevsim999` (ENODEV from the kernel, exit 1).
- Gate: two fresh-boot batches agree row-for-row (byte-identical sidecars); the first
committed to `testdata/<kver>/ws/devlink/`.

### 1P: parser + tests (NP-DL)
- `pkg/xtcpnl/xtcpnl_devlink.go`: decode `genlmsghdr` + `DEVLINK_CMD_*` replies and the
`DEVLINK_ATTR_*` tree, following `xtcpnl_ethtool.go`'s classify→header→payload shape.
Attribute values are copies; `NLA_F_NESTED` masked; first-of-repeat wins; short scalars
dropped. Request builders via `buildGenericGet`.
- Table tests (`xtcpnl_devlink_test.go`), each row carrying `description` + `expected`,
across positive / negative / boundary / corner: dev-get, port show, resource nest;
truncated attr header; nested flag on a scalar; empty dump; max-length name; unknown
attr; unknown cmd.
- `FuzzParseDevlink`; O3/O4 corpus test `xtcpnl_ws_devlink_test.go`.

### 1R: render clone `godevlink` (NR-DL)
- `cmd/godevlink/main.go` (thin) + `internal/godevlink/` on the gordma template, ws-pcap
replay, dual text/JSON, renderers for the captured read-only subcommands only.
- `corpus_test.go` byte-parity over all kernels + replay guards; `imports_test.go`.

### 1B: bug hunt
- Audit `devlink/devlink.c` print paths for the known patterns (count-vs-loop, attribute
over-read, uninit request padding, JSON key bugs, print-width mismatches). Record any
finding in `docs/netlink/upstream/` only — never sent, no patch/PR/sign-off.

## Increment 2 — vdpa (genl, `vdpa` CLI, vdpa_sim_net)

### 2C: capture (NC-VD)
- Guest readiness: **add** `vdpa_sim_net` (and deps) to the workbench kernel; verify
`VDPA_SIM_NET`. `vdpa_sim_net` registers a software mgmtdev at module init, no
hardware. Module list `["vdpa_sim_net"]`.
- `matrix_vdpa.go` space `vdpa`, read-only rows + `-j`: `mgmtdev show` (works with no
device), and after `vdpa dev add … mgmtdev vdpasim_net` in `pre`: `dev show`,
`dev config show`, `dev vstats show`.
- Negatives (unknown mgmtdev, missing name); gate as 1C.

### 2P/2R/2B
- `pkg/xtcpnl/xtcpnl_vdpa.go` + table tests + `FuzzParseVdpa` + `xtcpnl_ws_vdpa_test.go`;
`cmd/govdpa` + `internal/govdpa/` on the gordma template; audit `vdpa/vdpa.c`, record
only.

## Increment 3 — fou (genl, `ip fou` CLI, fou module)

### 3C: capture (NC-FO)
- Guest readiness: **add** `fou` module; verify `NET_FOU`. Module list `["fou"]`.
- `matrix_fou.go` space `fou`, read-only `ip fou show` + `-j`; `pre` installs fou ports
via `ip fou add port … ipproto …`. Negatives (bad port, missing ipproto).

### 3P/3R/3B
- **Extend** the existing `pkg/xtcpnl/xtcpnl_fou.go` (do not duplicate) to the full
`FOU_ATTR_*` set; fill the positive/negative/boundary/corner grid; extend
`FuzzParseFou`; add `xtcpnl_ws_fou_test.go`; `cmd/gofou` + `internal/gofou/`; audit
`ip/ipfou.c`, record only.
- **Retired (2026-11-22):** `gofou` duplicated goip's `obj_fou.go`. It is deleted, and
`internal/goip/ws_fou_test.go` holds goip to the 13 fou ws rows instead.

## Increment 4 — mptcp (genl, `ip mptcp` CLI, built-in MPTCP)

Added on 2026-11-22, after the three-family arc closed and was pushed. Chosen by the user
over `l2tp` and `team`: like fou, it is an `ip` sub-command over a hardware-free,
`netnsok` genl family (`mptcp_pm`), and the repo already decodes it
(`xtcpnl_mptcp_pm.go`, from the older `link-write/genl` corpus), so 4P extends rather
than builds.

### 4C: capture (NC-MP)
- Guest readiness: none. `MPTCP` is a bool Kconfig (built in), so rows load no module.
- `matrix_mptcp.go` space `mptcp`, read-only: `endpoint show` (dump), `endpoint show id
N` (one GET_ADDR), bare `endpoint`, `limits show`, bare `limits`, and `limits show
subflows N` (a set spelled into a read), each plain and `-j`, over a dummy-`d0`
topology with endpoints added in `pre`. Negatives: help, unknown object/sub-commands,
a non-address show argument, `id 0`, an absent id (kernel EINVAL), a bad limit.
- ip's endpoint paths call `ll_init_map`, an RTM_GETLINK dump on its rtnetlink socket,
to name an endpoint's `dev`. The rows capture on a new **`generic+route`** protocol so
that dump is in the pcap and the clone can replay it.

### 4P/4R/4B (re-scoped 2026-11-22)

`goip` already clones `ip mptcp` whole (`internal/goip/obj_mptcp.go`, G6-T04), as it
does `ip fou` (`obj_fou.go`, G6-T05) — which the plan missed when it scoped 3R, so
`gofou` duplicated it (since retired into goip). With the user, increment 4 therefore builds no `gomptcp`; it
holds goip to the new ws corpus instead:

- **4P:** no new request builder: goip builds its mptcp requests with
`BuildGenlRequest`, and the O3 test does too. `FuzzParseMPTCPPM`;
`xtcpnl_ws_mptcp_test.go` (O3: every row's request byte for byte; O4: the `-j`
endpoint JSON and the limits text against the decoded answers).
- **4R:** `internal/goip/ws_mptcp_test.go` replays all 26 rows through goip over each
row's own generic+route pcap: stdout byte for byte, rc, every genl exchange replayed,
and ip's RTM_GETLINK dump request. A refusal keeps goip's own text (its `goip:`
prefix, no trailing period, no extack), so stderr is held byte for byte only where
ip printed nothing.
- **4B:** audit `ip/ipmptcp.c`, record only.

## Increment 5 — tipc (genl `TIPCv2`, `tipc` CLI, tipc module)

`tipc` is a standalone iproute2 binary (`tipc/`), not an `ip` sub-command. goip has no
clone of it, and the repo had no TIPC decode, so this is a full increment, ending in a
read-only clone, `gotipc`. The family is `netnsok = true`
(`net/tipc/netlink.c:309`), and the stock kernel builds `tipc` as a module with UDP
media. tipc resolves the family before it dispatches (`tipc/tipc.c:114`), so every
refusal after the options is an ack-then-fail, and `main` exits 255. Only `link` and
`nametable` print JSON.

### 5C: capture (NC-TI)

- `matrix_tipc.go`: 40 read-only commands over six namespace fixtures, each plain and
`-j`, plus 13 negatives (93 rows).
- The fixtures: `bare`, `ident` (identity 1001), `eth` (a dummy bearer, address
waited for), `udp`, `peer` (a second node behind a veth pair) and `sock` (held
bound and connected sockets).
- The peer is an unnamed `unshare -n` namespace named by its pid. Each pre step's
`ip netns exec` has a private mount namespace, which hides an `ip netns add`
from the next step.
- Determinism: fixed identities and MACs. Socket ports are random, so name-table and
socket rows vary, as do the peer link's counters. The two-boot rule allows those
rows to differ in their replies (and the socket rows in their per-socket PUBL_GET
requests).

### 5P/5R/5B

- **5P:** `xtcpnl_tipc.go` (`ParseTIPC`), table and fuzz tests, and an O3/O4 corpus
test.
- **5R:** `cmd/gotipc` + `internal/gotipc/` on the godevlink template, replaying the
ws pcap byte for byte.
- **5B:** audit `tipc/*.c`, record only.

## Verification

**Per task (hermetic):** `go test ./tools/nlcapgen/`; `go test ./pkg/xtcpnl/`;
`go test ./internal/{godevlink,govdpa,gotipc}/` (and `./internal/goip/` for fou and mptcp); `CGO_ENABLED=0 go build ./...`;
`nix build --no-link .#{godevlink,govdpa,gotipc}`; lint-baseline, netlink-audit,
kernel-citation-audit, statix, deadnix, nix-fmt, gofmt (fix findings in code — no
`nolint`/`#nosec`); mutants on new decode/render logic under
`systemd-run --user --scope -q -p MemoryMax=6G go test -timeout=180s`.

**Per task (live capture):** `free -g`, VM port + bracketed `pgrep` check, wait for load
to settle, prebuild; two fresh-boot batches per family agree row-for-row; the
kconfig/module sidecar confirms the family was present.

**Pre-push (whole arc):** `nix build --no-link .#checks.x86_64-linux.test-go-race` and a
full `go test ./...`. This arc adds **no** `goip-parity` VM matrix rows, so the
`microvm-x86_64-goip-parity` full run is **not** required.

## Process (standing rules)

- Work on `goip/genl-clones`; commit each verified task with the status doc updated in
the same commit; keep going without per-task approval.
- Each push or PR needs a fresh explicit OK.
- Stage files by name (or `git add -u` scoped to dirs without the user's edits). Never
stage the user's edited docs or untracked junk; add `docs/netlink/upstream/*` only for
new bug write-ups this arc creates, by name.
- Commit messages end with the `Co-Authored-By` line; PR bodies end with the
Generated-with line. gh via `GH_CONFIG_DIR=~/.config/gh-profiles/runpod-randomizedcoder`.
- iproute2 / devlink / vdpa bugs: recorded only, never sent to netdev.
Loading